Skip to content

Instantly share code, notes, and snippets.

@ericelliott
ericelliott / essential-javascript-links.md
Last active November 8, 2024 17:29
Essential JavaScript Links
@nikcorg
nikcorg / berlin-jsconf-2014.md
Last active August 4, 2023 12:45
Slide decks of JSConf 2014
@alicial
alicial / mock-service-example.js
Last active June 10, 2019 14:26
AngularJS: Setting up a mocked service to use in controller unit tests.
// 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 October 3, 2011 17:17
Christianity described in Ruby code
#!/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 February 24, 2010 19:39
JavaScript: integer suffixes (1st, 2nd, 3rd...)
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"