Compiled by Stephen Ball.
Like this? I write more programming blog posts at Rake Routes
- JavaScript Garden [guide]
- JavaScript Enlightenment [book]
- JavaScript Koans [codebase]
- Run JavaScript Koans on Cloud9 [blog post]
# drop this task in the environment(s) you want to confirm deployment for | |
before :deploy, "deploy:confirm" | |
namespace :deploy do | |
desc "Should we really deploy?" | |
task :confirm do | |
if Capistrano::CLI.ui.ask("Are you sure?") == "yes" | |
puts "You got it buddy. Imma deploy now." | |
else |
require 'minitest/spec' | |
require 'minitest/autorun' | |
class String | |
def one_time_override(method, &override) | |
self.instance_eval do | |
def to_s | |
self.instance_eval do | |
def to_s | |
'foo' |
Compiled by Stephen Ball.
Like this? I write more programming blog posts at Rake Routes
<?php | |
// page setup | |
require('/www/includes/ipdatabase/ipdb_page.php'); | |
$javascript = '<script type="text/javascript" src="/ipdatabase/js/index.js"></script>'; | |
$page = new IPDB_Page(); | |
$page->title('Main'); | |
$page->javascript($javascript); |
<?php | |
/** | |
* ezproxy_redirect | |
* | |
* EZProxy requires that the username and password be passed via GET. | |
* This is just about as insecure as possible. | |
* | |
* So, we trick ezproxy into security by opening a socket connection | |
* to the server; acting as a browser to initiate the connection; then | |
* writing out its response to the actual browser. |
original = [ | |
{ a: { foo: 1 } }, | |
{ b: { foo: 2 } }, | |
{ c: { foo: 3 } }, | |
{ d: { foo: 4 } }, | |
{ e: { foo: 5 } }, | |
{ f: { foo: 6 } }, | |
{ g: { foo: 7 } }, | |
] |
is_binary <<255::size(8)>> # => true | |
is_bitstring <<255::size(8)>> # => true | |
is_binary <<255::size(4)>> # => false | |
is_bitstring <<255::size(4)>> # => true | |
# So a binary is a bitstring but a bitstring isn't necessarily a binary. | |
# We can see that effect in pattern matching as well: | |
<<255::size(4)>> # => <<15::size(4)>> | |
<<x>> = <<255::size(4)>> # => MatchError! |
def ssl_config do | |
ssl_config(client_cert, client_cert_key) | |
end | |
def ssl_config(_client_cert=nil, _client_cert_key=nil) do | |
[] | |
end | |
def ssl_config(client_cert, client_cert_key) do | |
[ |
'use strict'; | |
// none of this is good | |
class Greet { | |
required(arg) { | |
throw new Error(`${arg} is required`); | |
} | |
requireArgs(given, required) { |
check_letter() { | |
echo "$1: `type $1 >/dev/null && type $1 | sed -e \"s/^$1: //\" | tr '\n' ' '`"; | |
} | |
letters() { | |
for letter in {a..z}; do | |
check_letter $letter | |
check_letter `echo $letter | tr a-z A-Z` | |
done | |
} |