Skip to content

Instantly share code, notes, and snippets.

@ktkaushik
ktkaushik / json_format
Created January 3, 2013 11:36
CurrentJson
{
call: {
stats: [
{
activity_time: "01/12 - 02/12",
outgoing: 0,
incoming: 0
},
{
activity_time: "03/12 - 10/12",
@ktkaushik
ktkaushik / data_for_time_zone.rb
Created January 8, 2013 13:54
add time in time zone
Activity.all.each do |activity|
begin
puts activity.id
if (tz=activity.get_value_from_info('timezone'))
if Time.find_zone(tz)
activity.activity_time_with_zone = DateTime.strptime(activity.activity_time.in_time_zone( tz ).strftime("%m/%d/%Y %H:%M:%S"), "%m/%d/%Y %H:%M:%S")
activity.save!
end
end
rescue Exception => e
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@ktkaushik
ktkaushik / migration_template.rb
Created January 23, 2013 06:22
migration_template source code
def migration_template(source, destination=nil, config={})
destination = File.expand_path(destination || source, self.destination_root)
migration_dir = File.dirname(destination)
@migration_number = self.class.next_migration_number(migration_dir)
@migration_file_name = File.basename(destination).sub(/\.rb$/, '')
@migration_class_name = @migration_file_name.camelize
destination = self.class.migration_exists?(migration_dir, @migration_file_name)
<script>
// Charles Lawrence - Feb 16, 2012. Free to use and modify. Please attribute back to @geuis if you find this useful
// Twitter Bootstrap Typeahead doesn't support remote data querying. This is an expected feature in the future. In the meantime, others have submitted patches to the core bootstrap component that allow it.
// The following will allow remote autocompletes *without* modifying any officially released core code.
// If others find ways to improve this, please share.
var autocomplete = $('#searchinput').typeahead()
.on('keyup', function(ev){
ev.stopPropagation();
@ktkaushik
ktkaushik / install.sh
Last active December 14, 2015 18:19
Installing postgresql on mac (mountain lion, if that matters)
# install Homebrew (figure it out yourself)
#use brew to install postgresql
brew install postgresql
# Next, try and run the executable for postgresql command
psql
@ktkaushik
ktkaushik / error.txt
Created March 15, 2013 13:09
Express error
TypeError: Cannot read property '0' of undefined
at new View (/Users/kaushik/dev/my_repos/retailer-catalog-backend/node_modules/express/lib/view.js:41:65)
at Function.app.render (/Users/kaushik/dev/my_repos/retailer-catalog-backend/node_modules/express/lib/application.js:486:12)
at ServerResponse.res.render (/Users/kaushik/dev/my_repos/retailer-catalog-backend/node_modules/express/lib/response.js:753:7)
at exports.new (/Users/kaushik/dev/my_repos/retailer-catalog-backend/routes/api/user.js:80:7)
at callbacks (/Users/kaushik/dev/my_repos/retailer-catalog-backend/node_modules/express/lib/router/index.js:161:37)
at param (/Users/kaushik/dev/my_repos/retailer-catalog-backend/node_modules/express/lib/router/index.js:135:11)
at pass (/Users/kaushik/dev/my_repos/retailer-catalog-backend/node_modules/express/lib/router/index.js:142:5)
at Router._dispatch (/Users/kaushik/dev/my_repos/retailer-catalog-backend/node_modules/express/lib/router/index.js:170:5)
at Object.router (/Users/ka
Running "uglify:build" (uglify) task
WARN: Dropping unused function argument message [build/diamond-search.js:13583,32]
WARN: Dropping unused function argument $depth [build/diamond-search.js:13691,39]
WARN: Side effects in initialization of unused variable Router [build/diamond-search.js:14343,4]
WARN: Dropping unused function argument slider [build/diamond-search.js:9694,36]
WARN: Non-strict equality against boolean: == false [build/diamond-search.js:9890,17]
WARN: Dropping unused function argument collection [build/diamond-search.js:10500,25]
WARN: Dropping unreachable code [build/diamond-search.js:10394,10]
WARN: Condition always true [build/diamond-search.js:11566,6]
WARN: Dropping unused function argument options [build/diamond-search.js:12114,21]
@ktkaushik
ktkaushik / server.js
Created June 19, 2013 06:16
Dynamic Server to run less and other engines on static html files
#!/usr/bin/env coffee
http = require 'http'
express = require '/usr/local/lib/node_modules/express'
# -----
argv = process.argv.slice(2)
argvLen = argv.length
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as: