Skip to content

Instantly share code, notes, and snippets.

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

Gaurav cggaurav

🏠
Working from home
View GitHub Profile
@cggaurav
cggaurav / server.js
Created October 18, 2013 15:00
WebService
var connect = require('connect');
connect.createServer(
connect.static(__dirname)
).listen(8080);
@cggaurav
cggaurav / jsonp.html
Created October 21, 2013 20:08
JSONP
<script>
(function() {
var api = "y.com?callback=";
$.getJSON(api, jsonData)
.done(function(data) {
Do whatever you want
});
})();
</script>
@cggaurav
cggaurav / iframe.html
Created October 21, 2013 20:11
iFrame PostMessage
<iframe src="http://y.com" id="iframe"></iframe>
<script>
var sendToWindow = document.getElementById("iframe").contentWindow
function() {
window.postMessage(somedata, "http://y.com")
}
</script>
@cggaurav
cggaurav / voice_list.txt
Created October 22, 2013 13:14
Voice List
Agnes en_US # Isn't it nice to have a computer that will talk to you?
Albert en_US # I have a frog in my throat. No, I mean a real frog!
Alex en_US # Most people recognize me by my voice.
Bad News en_US # The light you see at the end of the tunnel is the headlamp of a fast approaching train.
Bahh en_US # Do not pull the wool over my eyes.
Bells en_US # Time flies when you are having fun.
Boing en_US # Spring has sprung, fall has fell, winter's here and it's colder than usual.
Bruce en_US # I sure like being inside this fancy computer
Bubbles en_US # Pull the plug! I'm drowning!
Cellos en_US # Doo da doo da dum dee dee doodly doo dum dum dum doo da doo da doo da doo da doo da doo da doo
/*
* Based on https://gist.github.com/583836 from http://stackoverflow.com/questions/3709391/node-js-base64-encode-a-downloaded-image-for-use-in-data-uri.
* Neither that gist nor this one work for me in 0.2.x or 0.3.x.
*/
var request = require('request'),
BufferList = require('bufferlist').BufferList,
sys = require('sys'),
bl = new BufferList(),
url = 'http://nodejs.org/logo.png'
;
@cggaurav
cggaurav / gist:7582088
Last active December 28, 2015 23:49
Memes
{
"10 Guy":"http://i.imgur.com/LaENqOV.jpg",
"3rd World Success Kid":"http://i.imgur.com/WA5duA1.jpg",
"90's Problems":"http://i.imgur.com/tL47qtp.jpg",
"Aaand It's Gone":"http://i.imgur.com/yf12saq.jpg",
"Actual Advice Mallard":"http://i.imgur.com/WymFmVy.jpg",
"Advice Dog":"http://i.imgur.com/Qk0VO6D.jpg",
"Advice God":"http://i.imgur.com/xH2fSFg.jpg",
"Almost Politically Correct Redneck":"http://i.imgur.com/YqLgINf.jpg",
"Am I The Only One":"http://i.imgur.com/gS9YL5U.jpg",
@cggaurav
cggaurav / gist:7844068
Created December 7, 2013 15:39
Change Tab Title to show CWD. ZSH
function settitle {
title_lab=${PWD##*/}
echo -ne "\e]2;$title_lab\a"
}
function cd() {
builtin cd "$@" && settitle;
}
@cggaurav
cggaurav / gist:7989909
Created December 16, 2013 16:30
Redis Connection Pool
'use strict';
var uri = require('../util/url');
var pool = require('generic-pool');
var driver = require('redis');
var flag = require('node-env-flag');
module.exports = function(url) {
var connection_settings = uri(url || process.env.REDIS_URL);
return pool.Pool({
@cggaurav
cggaurav / gist:7989927
Created December 16, 2013 16:31
MongoDB Connection Pool
'use strict';
var uri = require('../util/url');
var pool = require('generic-pool');
var driver = require('mongodb');
var flag = require('node-env-flag');
module.exports = function(url) {
var connection_settings = uri(url || process.env.MONGODB_URL);
return pool.Pool({
@cggaurav
cggaurav / gist:8350907
Created January 10, 2014 12:10
Embed Inject Script
// WHAT?
//
// Script to embed Gendly anywhere
//
// USAGE:
//
// <script src="//js.gendly.com" async="true" defer="true"></script>
//
(function(window, document) {