Skip to content

Instantly share code, notes, and snippets.

View igorparrabastias's full-sized avatar

Igor Parra Bastias igorparrabastias

View GitHub Profile
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@sergio-fry
sergio-fry / gist:3917217
Created October 19, 2012 09:49
Jquery Deferred Parallel Example
stuff1 = function(deferred) {
setTimeout(function() {
console.log("Stuff #1 is done!");
deferred.resolve();
}, 1000);
};
stuff2 = function(deferred) {
setTimeout(function() {
console.log("Stuff #2 is done!");
@sergio-fry
sergio-fry / gist:3918032
Created October 19, 2012 12:36
Jquery Deferred Series Example
stuff1 = function(deferred) {
setTimeout(function() {
console.log("Stuff #1 is done!");
deferred.resolve();
}, 1000);
};
stuff2 = function(deferred) {
setTimeout(function() {
console.log("Stuff #2 is done!");
@FGRibreau
FGRibreau / 0_readme.md
Created November 2, 2013 22:56
Mock NodeJS net.Socket with ReadWriteStream
var dummySocket = new ReadWriteNetStream();

// Debug
dummySocket.on('data', function(data){
console.log('write received', data);
});

dummySocket.write('hey !');
@paulallies
paulallies / gist:0052fab554b14bbfa3ef
Last active November 12, 2023 23:00
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin <branch-name>
@lucdew
lucdew / json_postgres.js
Last active November 16, 2022 17:49
Example of json document storage in postgresql and querying (with knex.js)
var connectionString = 'postgres://localhost:5432/postgres';
var Promise=require('bluebird');
var knex = require('knex')({
client: 'pg',
connection: {
user: 'postgres',
database: 'postgres',
port: 5432,
@bendrucker
bendrucker / test.js
Created October 1, 2014 09:52
Truncate data during tests with knex
'use strict';
var Promise = require('bluebird');
var knex = require('../../src/db').knex;
var tables = [
'organizations',
'campaigns',
'donors',
'pledges',
@hassansin
hassansin / eloquent-cheatsheet.php
Last active May 23, 2024 07:51
Laravel 5 Eloquent CheatSheet #laravel #eloquent
Model::
/*Select*/
select('col1','col2')
->select(array('col1','col2'))
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating'))
->addSelect('col3','col4')
->distinct() // distinct select
/*From*/
@jcollado
jcollado / email.js
Last active April 3, 2024 15:21
Send email with nodemailer and AWS SES (API or STMP)
var nodemailer = require('nodemailer');
var sesTransport = require('nodemailer-ses-transport');
var smtpPassword = require('aws-smtp-credentials');
var mailOptions = {
from: 'from@example.com',
to: 'to@example.com',
text: 'This is some text',
html: '<b>This is some HTML</b>',
};
@paulkearney
paulkearney / cleanup-codecommit-repos.sh
Created September 25, 2015 18:20
Migrating from GitHub to AWS CodeCommit
while read r; do
echo $r
aws codecommit delete-repository --repository-name $r --region us-east-1
done < ~/dev/utility-scripts/aws/codecommit/repos.txt