Skip to content

Instantly share code, notes, and snippets.

View jasdeepsingh's full-sized avatar
🏠
Working from home

jasdeep singh jasdeepsingh

🏠
Working from home
View GitHub Profile
@jasdeepsingh
jasdeepsingh / angular-routing.js
Last active August 29, 2015 14:04
angular-routing
// in router
angular.module('app-name', [], function($routeProvider, $locationProvider, UserService) {
$routeProvider.
when('/user/:userName', {
templateUrl: 'userShowPage',
controller: UserController,
resolve: {
//resolve functions here...
loadedUser: UserController.resolve.loadUser

Keybase proof

I hereby claim:

  • I am jasdeepsingh on github.
  • I am jasdeep (https://keybase.io/jasdeep) on keybase.
  • I have a public key whose fingerprint is 6550 3A83 EAC2 9730 5A82 095C CC82 3B63 DB9B 2E7F

To claim this, I am signing this object:

@jasdeepsingh
jasdeepsingh / longest_palindrome.rb
Last active August 29, 2015 13:58
longest_palindrome.rb
# Ruby problem exercise from: http://www.rubeque.com/problems/a-man-comma--a-plan-comma--a-canal--panama-excl-
# We've covered the above problem at Brainstation Toronto: Backend Programming - First Cohort. (http://brainstation.it)
# The following solution is O(N^2)
# I've deliberately kept is as such (O(N^2)) so as to make sure
# It's easier to explain to the students.
def palindrome?(str)
str == str.reverse
@jasdeepsingh
jasdeepsingh / histogram.js
Created March 27, 2014 02:39
histogram.js
var string = "my string where i'll count the occurrences";
var arr = string.split("");
obj = {};
arr.forEach(function(elem) { obj[elem] = 0 });
arr.forEach(function(elem) { obj[elem]++ });
@jasdeepsingh
jasdeepsingh / work_report.rb
Created December 13, 2013 18:24
work_report bug
previous_work_report.visits.active.select('schedule_visits.id, schedule_visits.uuid').select_all.each do |v|
Schedule::SimpleVisit.verify_and_clone_with_schedule(self, v['id'].to_i, v['uuid'].to_i)
end
@jasdeepsingh
jasdeepsingh / spec_style.rb
Last active December 25, 2015 19:19
spec_style
describe Class do
# let blocks are always single line blocks.
let(:variable) { value }
# context blocks always have a string description.
context "when something" do
before(:each) do
# before blocks are always multilined
@jasdeepsingh
jasdeepsingh / Gemfile
Last active December 19, 2015 08:19
add-puma-gem
source 'https://rubygems.org'
gem 'rails', '3.2.11'
gem 'puma'
# .. other beautiful glowing gems you might have in your project.
@jasdeepsingh
jasdeepsingh / installing-redis1.sh
Created May 22, 2013 15:40
Installing Redis on Mac OS X
$ cd ~/Downloads/redis-2.4.14
$ make test
$ make
@jasdeepsingh
jasdeepsingh / memoize.sh
Created May 9, 2013 22:28
memoization inside hashes
>> tri = Hash.new { |hash,n| hash[n] = (n*(n+1))/2 }
{}
>> tri[1] = 1 # Setup the base case
1
>> tri[4]
10
>> tri[433]
93961
@jasdeepsingh
jasdeepsingh / automate.rb
Created May 9, 2013 21:39
Scripting for Benefit
#!/usr/bin/ruby
require 'rubygems'
require 'net/http'
require 'uri'
require 'nokogiri'
require 'mail'
url = ###/tracktest.php
refnum = # my application reference number.