It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Untested, but it should work :) | |
class Something < ActiveRecord::Base | |
# Simpler approach available with this small Rails patch: | |
# http://rails.lighthouseapp.com/projects/8994/tickets/1773-allow-returning-nil-from-a-named_scope-lambda | |
# | |
# named_scope :with_town_like, lambda { |term| | |
# { :conditions => ['town LIKE ?', term] } unless term.blank? | |
# } | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# minimal rails3 app | |
require 'action_controller' | |
Router = ActionDispatch::Routing::RouteSet.new | |
Router.draw do | |
root :to => 'site#index' | |
end | |
class SiteController < ActionController::Metal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
# Simple password generation in Ruby. | |
# | |
# Generate reasonably secure random passwords of any chosen length, | |
# designed to be somewhat easy for humans to read and remember. | |
# Each password has a capitalized letter and a digit. | |
# | |
# Example: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Priority Queues | |
═══════════════ | |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | |
INSERT DEL-MIN MIN DEC-KEY DELETE MERGE | |
binary log n log n 1 log n log n n | |
binomial 1 log n 1 log n log n log n | |
Fibonacci 1 log n† 1 1† log n† log n | |
Pairing 1† log n† 1† 1† log n† 1† | |
Brodal-Okasaki 1 log n 1 1 log n 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Router } from "express"; | |
import jwt from "jsonwebtoken"; | |
import jwkToPem from "jwk-to-pem"; | |
import * as Axios from 'axios'; | |
interface PublicKeys { | |
keys: PublicKey[]; | |
} | |
interface PublicKey { | |
alg: string; |