Skip to content

Instantly share code, notes, and snippets.

View akhoury's full-sized avatar
🏠
Working from home

Aziz Khoury akhoury

🏠
Working from home
View GitHub Profile
var path = require('path');
var nconf = require('nconf');
var async = require('async');
nconf.file({ file: path.join(__dirname, './config.json') });
var db = require('./src/database');
var S3_BASE_URL = 'https://nodebb-assests.s3-us-west-2.amazonaws.com/';
@akhoury
akhoury / cls-nodebb-testcase.js
Last active June 24, 2016 15:17
cls-nodebb-testcase
// this file is assumed to be in the root NodeBB directory
var continuationLocalStorage = require('continuation-local-storage');
var cls = continuationLocalStorage.createNamespace('test');
var async = require('async');
var path = require('path');
var nconf = require('nconf');
@akhoury
akhoury / NodeBB_src_middleware_cls2.js
Created June 24, 2016 01:26
use async-hook instead of continuation-local-storage
var asyncHook = require('async-hook');
var path = require('path');
var utils = require('../../public/src/utils');
function CLS() {
var mem = {};
var self = this;
this.storage = null;
@akhoury
akhoury / cls-minimal-test-case.js
Created May 20, 2016 17:26
must require continuation-local-storage before others
/*
You must require CLS first,
In this example if you require request first, it closes over some dep before CLS could rewrite it
1. run it as it the first time.
2. then uncomment the first request and comment out the one at Line 15, then run it again.
*/
// var request = require('request');
@akhoury
akhoury / wtf
Created January 27, 2016 03:12
markdown-it RangeError
This file has been truncated, but you can view the full file.
<p><a target=\"_blank\" href=\"www.youtube.com/watch?v=FMTDwAFk0cA\">fluxualte the impending desicion come forth wollow willing to juxtapost the danger days of a carrion fairy next to a unicorn in the back of the shed it is a sado macsohist anomanyus to situate forthcoming streams of desire flavored trees sapping and snorting in rainbow discharge talking like a mouldy yak infecting the demons **♣ lucky charms ♣ ** online profile eat a facebook field svksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksksvksvksvksvksvkssudghawdugh fluxualte the impending desicion come forth wollow willing to juxtapost the danger days of a carrion fairy next to a unicorn in the back of the shed it is a sado macsohist anomanyus to situate forthcoming streams of desire flavored trees sapping and snorting in rainbow discharge talking like a mouldy yak infecting the demons **♣ lucky charms ♣ ** online profile eat a facebook field svksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksvksv
// https://codility.com/programmers/task/odd_occurrences_in_array/
/*
A non-empty zero-indexed array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.
For example, in array A such that:
A[0] = 9 A[1] = 3 A[2] = 9
A[3] = 3 A[4] = 9 A[5] = 7
A[6] = 9
// https://codility.com/programmers/task/binary_gap/
/*
A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.
For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of length 3. The number 20 has binary representation 10100 and contains one binary gap of length 1. The number 15 has binary representation 1111 and has no binary gaps.
Write a function:
int solution(int N);
@akhoury
akhoury / palindromize.js
Last active December 22, 2015 03:23
palindromize a word if possible in O(n), if already a palindrom return it, otherwise return null
function palindromize(word) {
if (Array.isArray(word)) {
return word.map(palindromize);
};
if (!word) return null;
word = "" + word;
// single letter words? really? i don't know..
@akhoury
akhoury / gc2r.js
Last active August 29, 2015 14:13
// won't work, im dumb, I just realized that it's a cross-domain frame, initially I thought the frame-content is being written by the js script
var gc2r = (function() {
var hostPageStyle = ''
+ '@media screen and (max-width: 350px) {'
+ ' div.goog-bubble-content.gc-reset {'
+ ' width: auto !important;'
+ ' }'
+ ' div.goog-bubble-content.gc-reset, '
var convert = require('./bbcode-to-markdown');
var testString = '[As always, if anyone, especially ENFPs, has any suggestions for changes or improvements, feel free to comment.]' +
'[SIZE="5"]ENFP: A Jungian Cognitive Function Analysis[/SIZE]' +
'[SIZE="3"]by simulatedworld[/SIZE]' +
'[URL="www.personalitynation.com"]www.personalitynation.com[/URL]' +
'[B]ENFP[/B], or [I]Extroverted iNtuitive Feeling Perceiver[/I], is a label borrowed from MBTI nomenclature and now applied to the Jungian Cognitive Function set [B]{Ne, Fi, Te, Si}[/B].' +
'[B]Dominant: Extroverted iNtuition (Ne)[/B]' +
'[I]"More than anything I need to feel like I\'m working toward some kind of meaningful change or improvement in people\'s lives. I have a lot of big ideas for making things better, and I get really excited about new ideas that point toward some kind of new direction or idea I hadn\'t thought of before. I usually try to have a lot of people I like around, both because I like having them to bounce my ideas