Skip to content

Instantly share code, notes, and snippets.

View vishr's full-sized avatar
🎯
Focusing

Vishal Rana vishr

🎯
Focusing
View GitHub Profile
@lexer
lexer / Client.js
Created May 8, 2011 19:08
Node pubsub server based on socket.io and redis
var client = new Pubsub({
port: 8000
});
client.connect();
client.on("connect", function() {
client.subscribe("trololo", function(data){
console.log('Received a message from the server: ' + data);
});
@tsabat
tsabat / supervisor.conf
Created December 28, 2011 15:09
Sample supervisor config file
; Sample supervisor config file.
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default
@mxriverlynn
mxriverlynn / 1.js
Created February 6, 2012 15:21
async template loading
Backbone.View.extend({
template: 'my-view-template',
render: function(){
var that = this;
$.get("/templates/" + this.template + ".html", function(template){
var html = $(template).tmpl();
that.$el.html(html);
});
return this;
@nicolasfont
nicolasfont / targznode
Created March 15, 2012 00:52
tar.gz with node.js
var fstream = require("fstream"),
tar = require("tar"),
zlib = require("zlib");
fstream.Reader("src").pipe(tar.Pack()).pipe(zlib.createGzip()).pipe(fstream.Writer("output.tar.gz"));
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@aheckmann
aheckmann / emit.js
Created June 7, 2012 15:25
mongoose update,new,remove events
var mongoose = require('mongoose');
mongoose.connect('localhost', 'testing_emitUpdate');
var Schema = mongoose.Schema;
var schema = new Schema({
name: String
});
// plumbing
schema.pre('save', function (next) {
@tly1980
tly1980 / fabfile.py
Created November 27, 2012 01:56
Small demo to show how to use fabric & cuisine to do some DevOps
from fabric.api import env, local, sudo, cd
from fabric.contrib.files import append
from cuisine import user_ensure, group_ensure, group_user_ensure, file_local_read
from cuisine import select_package, package_update, package_ensure, dir_exists, run
from fabric.context_managers import prefix, settings
def vagrant():
# change from the default user to 'vagrant'
env.user = 'vagrant'
@cobyism
cobyism / gh-pages-deploy.md
Last active July 18, 2024 05:22
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@TheNicholasNick
TheNicholasNick / 01 Install Arch Linux Guest on VirtualBox.md
Last active November 26, 2017 14:24
Simple to the point no fluff install Arch Linux Guest on VirtualBox