Skip to content

Instantly share code, notes, and snippets.

@rishabhmhjn
rishabhmhjn / create.gist.test.js
Created February 26, 2014 10:04
sublime gist
(function() {
console.log('testing gist create from sublime text');
}());
package me.unfollowers.droid.ui;
import me.unfollowers.droid.R;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
/**
* @author rishabhmhjn
@rishabhmhjn
rishabhmhjn / viewport_snippet.html
Created October 27, 2014 01:59
Viewport disable user pinch zoom on mobile devices to be put inside the <head> tag
<!-- Viewport mobile tag for sensible mobile support -->
<meta name="MobileOptimized" content="320" />
<meta http-equiv="cleartype" content="on" />
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
@rishabhmhjn
rishabhmhjn / TwttrMaxlengthDirective.js
Last active December 15, 2015 07:12
An extension to md-maxlength from Angular Material (https://material.angularjs.org/latest/api/directive/mdInput) to calculate a tweet's length using the twitter-text-js library. Demo http://plnkr.co/edit/UC0aHq?p=preview
(function() {
// angular.module('TwttrMaxlengthDirectiveDemo', ['ngMaterial'])
// .constant('twttr', twttr) // https://github.com/twitter/twitter-text/tree/master/js
// .directive('twttrMaxlength', TwttrMaxlengthDirective);
TwttrMaxlengthDirective.$inject = ['$animate', 'twttr'];
function TwttrMaxlengthDirective($animate, twttr) {
return {
@rishabhmhjn
rishabhmhjn / ssh.config
Created December 16, 2015 04:57
SSH remote login via app-nat to app-remote
Host app-nat
Hostname app-nat.example.com
User app-nat-user
IdentityFile ~/.ssh/app-nat-id_rsa
Host app-remote
ProxyCommand ssh -q app-nat nc app-remote.example.com 22
User app-remote-user
IdentityFile ~/.ssh/app-remote-id_rsa
@rishabhmhjn
rishabhmhjn / Array.myLast.js
Last active December 17, 2015 17:58
Encapsulating Array Object to add a custom method
var MyArray = function() { return this; } ;
MyArray.prototype = new Array();
MyArray.prototype.constructor = MyArray; // http://stackoverflow.com/a/10430875/842214
Object.defineProperty(MyArray.prototype, 'myLast', (function () {
return {
configurable : true,
enumerable : true,
get : function () {
return this[this.length - 1];
@rishabhmhjn
rishabhmhjn / JS.inheritance.js
Created May 31, 2013 06:57
Javascript inheritance
var Person = function () {
this.fname = 'douglas';
this.lname = 'crockford';
};
var Student = function() {
return this;
};
Student.prototype = new Person();
@rishabhmhjn
rishabhmhjn / node_install_with_nvm.sh
Last active December 18, 2015 04:39
Install nodejs using nvm
vi ~/.bashrc
# [add the following]
# -------------------------------------------------------------
. ~/.nvm/nvm.sh && nvm use default
# -------------------------------------------------------------
mkdir ~/src
cd !$
@rishabhmhjn
rishabhmhjn / redis-pool.js
Created June 11, 2013 04:20
Implementation of Redis connection pooling
var redisConfig = {
"host" : "localhost",
"port" : "6379",
"maxConnections" : 10,
"minConnections" : 5,
"debug" : true
}
var redis = require("redis");
var ItemModel = Backbone.Model.extend({
defaults : {
"item_id" : 0,
"item_content" : "this is a content"
}
});
var ItemColl = Backbone.Collection.extend({