Skip to content

Instantly share code, notes, and snippets.

View ketanghumatkar's full-sized avatar

Ketan Ghumatkar ketanghumatkar

View GitHub Profile
@umar-webonise
umar-webonise / add_client.rb
Last active September 3, 2015 14:10
Added Client in treeni Data Management
client = Client.new(name: 'Treeni')
client.save!
files = Dir["app/models/*.rb"]
models = files.map { |file| file.split('/').last.sub(/\.rb/, '').camelize.constantize }.select { |i| i != Client }
models.each { |model| model.update_all(client_id: client._id) }
@nnarhinen
nnarhinen / README.md
Last active June 25, 2019 09:33
Rails-like console with express.js, bookshelf.js and node-repl-promised

Install node-repl-promised: npm install -g repl-promised

Use the repl to list all users

$ node-promised
> var app = require('./app');
undefined
> var Bookshelf = app.get('bookshelf');
undefined
@yashprit
yashprit / jQuery_app_structure.js
Created May 30, 2014 06:31
This is one of way to Structure jQuery Application
(function(ctx, $, undefined){
$(document).ready(function(){
bindEvent();
})
function bindEvent () {
//private scope for application
}
@shardulmohite
shardulmohite / gist:f2956009a53d573f1e14
Last active August 29, 2015 13:56
DNS look up , example of Non-Blocking function of JS .
var SiteArray = ['google.com','webonise.com','facebook.com','techcrunch.com','indiatimes.com'];
var dns = require('dns');
for(var i = 0 ; i < SiteArray.length ; i++){
dns.lookup(SiteArray[i],function(err,ip){
if (err) return handleError(err);
console.log( " %s resolved to %s ", SiteArray[i],ip );
});
}
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2 postgresql-server-dev-9.2 postgresql-contrib-9.2
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
service postgresql stop
/usr/lib/postgresql/9.2/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.2/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.2/main/ -O "-c config_file=/etc/postgresql/9.2/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"
base64 original_img.png | base64 --decode > ~/dest/decoded_image.png
@scicco
scicco / geo_world_map_migration
Last active May 17, 2018 10:26
Rails migration for GeoWorldMap db into postgresql db
class CreatePlaces < ActiveRecord::Migration
# Rails migration for GeoWorldMap db into postgresql db
#(inspired by http://blog.inspired.no/populate-your-database-with-free-world-cities-countries-regions-in-2-minutes-using-a-rails-migration-273/ post)
#extract files from GeoWorldMap.zip archive from here
# http://www.geobytes.com/GeoWorldMap.zip
#
#and place them into #{Rails.root}/db/migrate/
##the archive has 'cities.txt' file, rename it 'Cities.txt'
#mv cities.txt Cities.txt
@ketanghumatkar
ketanghumatkar / terminator.md
Last active December 25, 2015 13:49
Terminator is a cross-platform GPL terminal emulator with features Automatic logging, Find, Horizontal scroll, Multiple Tabs, etc.

Installation and Shortcuts

Installation

Step1 : Add Terminator Repository

sudo add-apt-repository ppa:gnome-terminator
@brobertsaz
brobertsaz / serversetup.md
Last active July 6, 2020 08:56
Ubuntu 12.04 Ruby, Rails, Nginx, Unicorn

Ubuntu 12.04, Ruby, Rails, Nginx, Unicorn and git-deploy

In the seemlingly endless search for the actual correct and easy way to deploy a Rails app, we have tried several ways. We tried out using Apache2 and running a cluster of Thin servers. With the built in threading of Puma we decided to use it with Nginx.

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress (you can also use the domain name if you have the DNS setup already)
    • accept the RSA key
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"