Skip to content

Instantly share code, notes, and snippets.

View essential-javascript-links.md
@nikcorg
nikcorg / berlin-jsconf-2014.md
Last active Aug 2, 2020
Slide decks of JSConf 2014
View berlin-jsconf-2014.md
@alicial
alicial / mock-service-example.js
Last active Jun 10, 2019
AngularJS: Setting up a mocked service to use in controller unit tests.
View mock-service-example.js
// Mocked Service
angular.module('mock.users', []).
factory('UserService', function($q) {
var userService = {};
userService.get = function() {
return {
id: 8888,
name: "test user"
}
@techandfaith
techandfaith / christianity.rb
Created Oct 3, 2011
Christianity described in Ruby code
View christianity.rb
#!/usr/bin/env ruby
require 'singleton'
require 'date'
Infinity = 1.0 / 0
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# In the beginning, there was God.
class God
# He is the only God.
@redoPop
redoPop / suffix.js
Created Feb 24, 2010
JavaScript: integer suffixes (1st, 2nd, 3rd...)
View suffix.js
var suffix = function(n) {
var d = (n|0)%100;
return d > 3 && d < 21 ? 'th' : ['th', 'st', 'nd', 'rd'][d%10] || 'th';
};
// suffix(1) => "st"
// suffix(102) => "nd"
// suffix(113) => "th"