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 / 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 / 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

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 / 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
@jasdeepsingh
jasdeepsingh / notifier_proxy.rb
Created September 21, 2014 22:29
notifier_proxy.rb
class Notifier
def notify(user)
if user.student?
send_sms(user.number)
elsif user.parent?
send_email(user.email)
end
end
@jasdeepsingh
jasdeepsingh / recent.md
Last active August 29, 2015 14:15
Recent Files Tracker

Let's build a Recent File Tracker

  • Implement a Class, name it RecentFiles

  • You can start implementing your class from 2nd line onwards.

  • You can run the test code, which will test your code using the following command: rspec file_name.rb

  • You can replace the file_name.rb with your actual file which you are working with.

  • If you get any errors such as rspec not found etc, please do: sudo gem install rspec

  • The class should be able to handle the following scenarios:

    • Output a list of most recent accessed files.
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@jasdeepsingh
jasdeepsingh / recent_files_spec.rb
Last active August 29, 2015 14:24
recent_files_spec.rb
#====== Implement your solution below:
# class RecentFiles
# end
#====== Solution implementation ends
require 'rspec'
@jasdeepsingh
jasdeepsingh / yml_to_markdown.md
Created August 16, 2015 21:06
yml_to_markdown
@jasdeepsingh
jasdeepsingh / gist:1274617
Created October 10, 2011 04:11
Installing/Building ImageMagick and Rmagick Gem on Mac OS X Lion
cd ~/src
git clone git://github.com/masterkain/ImageMagick-sl.git
cd ImageMagick-sl
sh install_im.sh
sudo gem install rmagick