Skip to content

Instantly share code, notes, and snippets.

View AllanJeremy's full-sized avatar
🎧
Wired in

Allan N Jeremy AllanJeremy

🎧
Wired in
View GitHub Profile
@AllanJeremy
AllanJeremy / nestjs-debugger-launch.json
Last active June 28, 2024 06:27
Launch.json for debugging NestJS applications in VSCode
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Nest Framework",
@AllanJeremy
AllanJeremy / leetcode-1363. Largest Multiple of Three.ts
Created June 18, 2024 18:45
Leetcode [Hard] 1363. Largest Multiple of Three
function largestMultipleOfThree(digits: number[]): string {
// Digits sorted in ascending order
const digitsAsc = [...digits].sort((a, b) => a - b);
// Sorting the digits in descending order 9,8,7...
const digitsDesc = [...digits].sort((a, b) => b - a); // [8,7,6,1,0]
let sum = digits.reduce((prev, curr) => prev + curr, 0);
let remainder = sum % 3;
let result = digitsDesc;
@AllanJeremy
AllanJeremy / NavDrawer.vue
Created December 23, 2021 11:52
Quasar 2.x Vue 3 Nav drawer component (accepts children) - Remove injections to use in any project
<template>
<q-drawer v-model="leftDrawerIsOpen" show-if-above>
<q-scroll-area
class="flex column justify-between"
style="
height: calc(100% - 150px);
margin-top: 150px;
border-right: 1px solid #ddd;
"
content-style="display:flex; flex-direction:column;justify-content:space-between;"
@AllanJeremy
AllanJeremy / FirebaseUploader.js
Last active May 8, 2024 18:15
Firebase extension of Quasar's QUploader component (that performs firebase uploads)
/** This component is now maintained via the [quasar-helpers repo](https://github.com/AllanJeremy/quasar-helpers) */
import { createUploaderComponent } from "quasar";
import { computed, ref, watch } from "vue";
// Firebase stuff
import {
getDownloadURL,
ref as firebaseRef,
uploadBytesResumable,
} from "@firebase/storage";
@AllanJeremy
AllanJeremy / vue-getLinkWithQueryParams.js
Last active June 22, 2021 11:51
VueJS - Get a link with query params from the current url preserved
/** Get a link with query params from the current url preserved
* @param {String} redirectLink The link to append params to
* @param {Object} $route The VueJS route object. Should contain a `query` object
* @return {String} The redirect link with url params from the current page appended
*/
const getLinkWithQueryParams = (redirectLink, $route) => {
const { query } = $route
// Return the link as is if no query params were found
if (!Object.keys(query).length) {
@AllanJeremy
AllanJeremy / api.js
Last active November 8, 2020 15:44
A simple API response helper. Formats API responses in a consistent manner. Concepts and format borrowed from the telegram API.
/** Get an API response
* @param {String} message Message to return as part of the response
* @param {Object} data An object representing data returned as part of the API response. Default: `null`
* @param {Number} statusCode HTTP status code to be returned with this response. Default: `200`
* @return {Object} An API response object
*/
const getResponse = (ok, message, data = null, statusCode = 200) => {
let response = {
ok,
message,
@AllanJeremy
AllanJeremy / currency.sql
Last active February 21, 2018 10:23 — forked from allanlaal/currency.sql
SQL table of World currencies (even some expired ones)Source: http://bcmoney-mobiletv.com/blog/2008/12/30/currency-codes-dropdown-and-sql-table/Cleaned up a bit, uses InnoDB and iso currency code as the PRIMARY key
--
-- Table structure for table `currency`
--
CREATE TABLE IF NOT EXISTS `currency` (
`iso` char(3) CHARACTER SET utf8 NOT NULL DEFAULT '',
`name` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`iso`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@AllanJeremy
AllanJeremy / Contract Killer 3.md
Created August 24, 2017 12:13
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@AllanJeremy
AllanJeremy / animate.js
Created July 25, 2017 22:06
Animatable fontawesome icons
//need to figure way of fixing timeout in loop
function AnimateIcon(iconList,elementId,timeInSeconds)
{
timeInSeconds*=1000;//Convert the timeIn seconds to milliseconds
var element = document.getElementById(elementId);//Get the element
var totalAnimationTime = 0;
var i = 0;
element.innerHTML= iconList[i];
@AllanJeremy
AllanJeremy / countries.sql
Created July 25, 2017 16:31 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;