Skip to content

Instantly share code, notes, and snippets.

View TahaBoulehmi's full-sized avatar
🎯
Focusing

Taha Boulehmi TahaBoulehmi

🎯
Focusing
View GitHub Profile
@dinana
dinana / useDeepPopulate.js
Last active June 13, 2019 08:33
Util Sails Service with PopulateDeep function
User.find(id).populate('preferences').exec(function (err, user) {
if(err) {
sails.log.error("ERR:", err);
}
sails.services['util'].populateDeep('user', user[0], 'preferences.nestedPreferences', function (err, newUser) {
if (err) {
sails.log.error("ERR:", err);
}
console.log(newUser);
});
@maephisto
maephisto / Javascript ISO country code to country name conversion
Last active November 3, 2023 21:05
ISO 3166-1 alpha-2 country code to country name conversion with a simple Javascript implementation, an array and a function.
var isoCountries = {
'AF' : 'Afghanistan',
'AX' : 'Aland Islands',
'AL' : 'Albania',
'DZ' : 'Algeria',
'AS' : 'American Samoa',
'AD' : 'Andorra',
'AO' : 'Angola',
'AI' : 'Anguilla',
'AQ' : 'Antarctica',
@branneman
branneman / better-nodejs-require-paths.md
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@danpaluska
danpaluska / uploader2.py
Created March 2, 2010 18:06
youtube uploading python script.
from gdata.youtube import YouTubeVideoEntry
from gdata.youtube.service import YouTubeService
import gdata
from gdata.service import BadAuthentication, CaptchaRequired
from optparse import OptionParser
import sys
import time
import os