Skip to content

Instantly share code, notes, and snippets.

@ktkaushik
ktkaushik / feed.js
Created February 20, 2014 12:23
admin feed.js
posts.adminFeed = function(req, res, next) {
var perPage = 10
, page = req.params.page > 0 ? req.params.page : 0;
console.log("looking for admin feed ************************");
var query = req.query.from;
Post
.find(req.query)
@ktkaushik
ktkaushik / error.js
Created April 3, 2014 22:13
socket parse error nodejs
events.js:72
throw er; // Unhandled 'error' event
^
Error: Parse Error
at Socket.socketOnData (http.js:1583:20)
at TCP.onread (net.js:525:27)
4 Apr 03:41:51 - [nodemon] app crashed - waiting for file changes before starting...
@ktkaushik
ktkaushik / bash_profile.sh
Created January 15, 2015 10:18
bash profile file
source ~/.bash_settings/.paths
#export PATH="/usr/local/Cellar/postgresql/9.2.3/bin/:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
source ~/.bash_settings/.bash_pretty
source ~/.bash_settings/.aliases
# {{{
# Node Completion - Auto-generated, do not touch.
@ktkaushik
ktkaushik / spineModel.js
Created April 1, 2015 08:15
A simple Model
/*
var model = new BackboneModel({
key : value
})
model.add("key", "value")
model.listen("key", function(){
})
*/
@ktkaushik
ktkaushik / index.html
Created September 5, 2015 06:43
zvxmwE
<svg xmlns="SVG namespace" width="600" height="250">
<g stroke-width="16" fill="none">
<path d="M173 102a51 51 0 1 1-13-30m20 37h-53" stroke="#4a87ee"/>
<circle cx="227" cy="128" r="32" stroke="#d83038"/>
<circle cx="313" cy="128" r="32" stroke="#f4c022"/>
<path d="M401 160a31 31 0 1 1 0-61m-4 0a24 29 0 1 1 0 61m26-67v79m-1-12a20 20 0 1 1-52 17" stroke="#4a87ee"/>
<path stroke="#4ab95a" d="M449 51v115"/>
<path d="M529 118a30 30 0 1 0-2 24m5-32l-62 28" stroke="#d83038"/>
</g>
@ktkaushik
ktkaushik / client_spec.rb
Created March 27, 2012 17:05
Specs for testing MongoDB's Embedded and Referenced association with Mongoid.
require 'spec_helper'
describe Client do
context "With valid client info" do
context "Associations" do
it "should embed many projects" do
association = Client.relations['projects']
association.klass.should == Project
association.relation.should == Mongoid::Relations::Embedded::Many
end
@ktkaushik
ktkaushik / gist:2223776
Created March 28, 2012 04:59 — forked from rtdp/gist:742461
Importing Gmail Contacts list to Rails Application.
class ImportedContactsController << ApplicationController
require 'net/http'
require 'net/https'
require 'uri'
#THIS METHOD TO SEND USER TO THE GOOGLE AUTHENTICATION PAGE.
def authenticate
# initiate authentication w/ gmail
# create url with url-encoded params to initiate connection with contacts api
# next - The URL of the page that Google should redirect the user to after authentication.
# scope - Indicates that the application is requesting a token to access contacts feeds.
@ktkaushik
ktkaushik / mongoid.yml
Created April 9, 2012 04:53
Mongoid YAML file.
development:
host: localhost
database: quadmint_development
test:
host: localhost
database: quadmint_test
# set these environment variables on your prod server
production:
@ktkaushik
ktkaushik / puma_web_server_on_crud_operations.txt
Created April 10, 2012 04:44
Puma Web Server after regular CRUD operation on scaffold generator for Product Model.
Puma 1.1.1 starting...
* Min threads: 0, max threads: 16
* Listening on tcp://0.0.0.0:9292
Use Ctrl-C to stop
127.0.0.1 - - [10/Apr/2012 10:14:46] "GET /index.html HTTP/1.1" 304 - 2.5345
127.0.0.1 - - [10/Apr/2012 10:14:51] "GET /rails.png HTTP/1.1" 304 - 4.0353
127.0.0.1 - - [10/Apr/2012 10:14:51] "GET /favicon.ico HTTP/1.1" 304 - 0.0005
127.0.0.1 - - [10/Apr/2012 10:14:53] "GET /products HTTP/1.1" 304 - 0.8145
127.0.0.1 - - [10/Apr/2012 10:14:53] "GET /scaffolds.css?body=1 HTTP/1.1" 304 - 0.0055
127.0.0.1 - - [10/Apr/2012 10:14:53] "GET /products.css?body=1 HTTP/1.1" 304 - 0.0126
@ktkaushik
ktkaushik / custom_logger.rb
Created April 22, 2012 04:56
Custom Logger in rails 3.2.x. Store logs in different logs based on environment as well, All in one file.
# If you wish to store everything in one logger file then do this.
class CustomLogger
LOGGERFILE = File.join("#{Rails.root}/log/category_clicks_#{Rails.env}_errors.log")
def self.log( message, severity = :info )
@category_click_logger ||= ActiveSupport::BufferedLogger.new( LOGGERFILE )
@model_log.send severity, "[#{Time.now.to_s(:db)}] [#{severity.to_s.capitalize}] #{message}\n"
end
end