Skip to content

Instantly share code, notes, and snippets.

View rupakg's full-sized avatar
😎
drinking from the firehose...

Rupak Ganguly rupakg

😎
drinking from the firehose...
View GitHub Profile
@rupakg
rupakg / Dev Gems
Created October 30, 2010 03:02
gemfile with dev stack
source 'http://rubygems.org'
gem 'rails', '3.0.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'mysql2'
gem "sqlite3-ruby"
@rupakg
rupakg / generate_passkey.rb
Last active September 24, 2015 03:28
SHA1
require 'hmac-sha1'
require 'digest/sha1'
require 'base64'
token="-Sat, 14 Nov 2009 09:47:53 GMT-GET-/video.xml-"
private_key="whatever"
salt=Digest::SHA1.hexdigest(token)[0..19]
passkey=Base64.encode64(HMAC::SHA1.digest(private_key, salt)).strip
Coffeescript:
masterTableView = new TableView
id:'masterView'
data:tableData
layout:'vertical'
style: Titanium.UI.iPhone.TableViewStyle.GROUPED
editable:true <=========
complies to JS:
domDocument = Titanium.XML.parseString(this.responseText)
domNodeList = domDocument.getElementsByTagName("Contents")
objectsList = [];
for (var i = 0; i < domNodeList.length; i++)
{
keyName = item.getElementsByTagName('Key').item(0).textContent;
size = objects[i].getElementsByTagName('Size').item(0).textContent;
objectsList[i] = {
key: keyName,
@import compass/css3
$color-light: #fff
$color-grey: #ddd
$color-dark: #000
//--------------------------------------------------------------------------------
// I started out like this, getting all
// carried away with how awesome Sass
@rupakg
rupakg / .gitignore_global
Created June 27, 2011 18:36
Global gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@rupakg
rupakg / Gemfile
Created November 12, 2011 08:14 — forked from therealadam/Gemfile
An example of how to authorize your app with Punchtab's OAuth2 API
source :rubygems
gem 'sinatra', '1.0'
gem 'oauth2'
gem 'json'
group :development do
gem 'shotgun'
end
@rupakg
rupakg / GetEpochTime.cs
Created September 19, 2012 19:15
Get Epoch Time in C# on .NET similar to time().now in Ruby/PHP
string GetEpochTime()
{
var utcDate = DateTime.Now.ToUniversalTime();
long baseTicks = 621355968000000000;
long tickResolution = 10000000;
long epoch = (utcDate.Ticks - baseTicks) / tickResolution;
long epochTicks = (epoch * tickResolution) + baseTicks;
var date = new DateTime(epochTicks, DateTimeKind.Utc);
return epoch.ToString();
}
@rupakg
rupakg / ruby_1_9_Notes.txt
Created November 8, 2012 14:08
Ruby 1.9 Notes
Ruby 1.9 Notes by Peter Cooper (http://rubyinside.com/19.txt)
INTRO
- Welcome to the Ruby 1.9 Walkthrough
- A walkthrough or a review, if you will, of how Ruby 1.9.2/3 compares to Ruby 1.8.7
- I've gone through and tried 100s of things on Ruby 1.8.6, 1.8.7, and 1.9.2 to see what has changed
- Matz quote
- Many of the videos and blog posts about 'what's new in Ruby 1.9' are out of date because some decisions were reversed
or because they were written when 1.8.6 was out, but then stuff got backported to 1.8.7
enumerators, for example!
@rupakg
rupakg / Ruby_1_9_Walkthru_Notes.txt
Created November 8, 2012 14:18
Ruby 1.9 Walkthru Notes
Ruby 1.9 Walkthru Notes
(http://dev-logger.blogspot.co.uk/2011/11/ruby-19-walkthrough-by-peter-cooper.html)
Strings
- Parse lines in a String object with #each_line or #lines, instead of #each
- String#ord returns the UTF-8 index
- "x".ord is the new way of doing ?x
- ?a == "a" (and no more "97")
- "A".ord == 65, "ABC".ord == 65