Skip to content

Instantly share code, notes, and snippets.

var fs = require('fs'),
path = require('path'),
Promise = require('rsvp').Promise,
request = require('request'),
files = [
'https://www.google.com/images/srpr/logo11w.png',
'http://rack.1.mshcdn.com/media/ZgkyMDEzLzA5LzE2L2JjL0Jpbmdsb2dvb3JhLmFkYjJkLnBuZwpwCXRodW1iCTEyMDB4OTYwMD4/996d9598/35b/Bing-logo-orange-RGB.png',
'http://assets.fontsinuse.com/static/use-media-items/15/14246/full-2048x768/52c4c6bc/Yahoo_Logo.png'
@prabirshrestha
prabirshrestha / bus.js
Created March 10, 2014 14:23
sample bus wrapper
/*
* usage:
* var Bus = require('../utils/bus');
* var bus = new Bus({ url: 'amqp://guest:guest@localhost:5672' });
* bus.connect(); // or bus.connectWithRetry();
*
* bus.createQueueIfNotExists('queueName', function (err) {
* if (err) return console.log('error creating queue', err);
* console.log('queue created successfully');
* });
@prabirshrestha
prabirshrestha / gulp-tap-example.js
Created February 27, 2014 22:08
get bower main
var gulp = require('gulp'),
tap = require('gulp-tap');
gulp.src('bower_components/*')
.pipe(tap(function (file, t) {
var main = require(file.path + '/' + 'bower.json').main
console.log(file.path + '/' + main);
}));
@prabirshrestha
prabirshrestha / package.json
Created February 27, 2014 21:54
auto install bower after npm install
{
"name": "a",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "./node_modules/bower/bin/bower install"
},
"author": "",
</html>
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div id="app"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
@prabirshrestha
prabirshrestha / react-router-qs.html
Created February 21, 2014 03:40
react countries backbone router with fake ajax call
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div id="app"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
@prabirshrestha
prabirshrestha / react-backbone-router.html
Last active August 29, 2015 13:56
react countries search with backbone router
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div id="app"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
var Hapi = require('hapi'),
server = Hapi.createServer(parseInt(process.env.PORT || 3000), { files: { relativeTo: __dirname } }),
gulp = require('gulp'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
browserify = require('gulp-browserify');
gulp.task('scripts', function () {
gulp.src(['client/app.js'])
@prabirshrestha
prabirshrestha / ReactBindTo.js
Created January 15, 2014 05:14
simple two way bindings for reactjs using mixins
/** @jsx React.DOM */
// http://jsfiddle.net/prabir/x2VX7/5/
var ReactBindTo = {
bindTo: function (key, defaultValue) {
var self = this;
return {
value: this.state[key] || defaultValue,
requestChange: function (value) {
@prabirshrestha
prabirshrestha / isNode.js
Created January 15, 2014 00:05
isNode.js
(function (isNode) {
var public = {};
if (isNode) {
module.exports = public;
} else {
window.public = public;
}