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
# To get the clue, enter the correct seed. | |
# If you don't know it, we know where you live! | |
import random | |
secret = # guess me | |
random.seed(secret) | |
words = "longing rusted furnace daybreak seventeen benign nine homecoming cash one freight car bubble flush calculator smash with book blow invincible".split(' ') | |
code = random.sample(words, 3) | |
print('Clue: ' + ' '.join(code)) |
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
#!/bin/bash | |
# call with ./splitwords.bash thisisawesome | |
find_substrings() { | |
local remainder=$1 | |
matched=$2 | |
# echo "in find_substrings '${remainder}' (${matched[@]})" | |
if [[ -z $remainder ]]; then | |
echo "Found: ${matched[@]}" | |
exit 0 |
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
### MY CUSTOMIZATIONS | |
# Set hostname, etc | |
export DESIREDHOSTNAME=caelian | |
sudo scutil --set HostName $DESIREDHOSTNAME | |
sudo scutil --set LocalHostName $DESIREDHOSTNAME | |
sudo scutil --set ComputerName $DESIREDHOSTNAME | |
# Use homebrew, click bottom right button in dialog when prompted | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
brew install git |
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
defmodule Foo do | |
# Use case matching | |
def fact1(n) do | |
case n do | |
1 -> 1 | |
_ -> n * fact1(n-1) | |
end | |
end |
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
package main | |
import ( | |
"crypto/md5" | |
"fmt" | |
"io" | |
"io/ioutil" | |
"log" | |
"os" | |
"path/filepath" |
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
def counts_of_files_by_extension(dir) | |
Dir["#{dir}/**/*"].reduce(Hash.new(0)) do |extension_counts, filepath| | |
extension_counts[File.extname(filepath)] += 1 | |
extension_counts | |
end | |
end | |
directory = ARGV.shift || Dir.pwd | |
counts = counts_of_files_by_extension(directory) |
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
module Foo | |
def included(base) | |
base.extend ClassMethods | |
# We need to call these AR methods ON the class | |
base.class_eval do | |
after_commit :foo | |
end | |
end | |
module ClassMethods |
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
Windows Registry Editor Version 5.00 | |
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings] | |
"Colour6"="0,0,0" | |
"Colour7"="85,87,83" | |
"Colour8"="204,0,0" | |
"Colour9"="239,41,41" | |
"Colour10"="78,154,6" | |
"Colour11"="138,226,52" | |
"Colour12"="196,160,0" |
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
require 'webrick' | |
require 'tempfile' | |
# Start gvim in foreground mode | |
$EDITOR = "gvim -f " | |
s = WEBrick::HTTPServer.new(:Port => 9292) | |
%w(INT TERM).each { |signal| trap(signal) { s.shutdown } } | |
s.mount_proc("/") do |req,res| | |
t = Tempfile.open('textaid') { |f| f.write(req.body); f } |
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
values = [nil, '', [], {}, true, false, 0, 3.51, '0', '42', '0xb', '1.2', '1e2', | |
'nil', 'true', 'false' ,'foo', [3,4], {5=>6}] | |
converters = %w(String to_s Integer to_i Float to_f Array to_a) | |
table_format = "%9s" * converters.size + "\n" | |
printf( "%9s ", '') | |
legend = converters | |
printf(table_format, *legend) | |
values.each do |v| |
NewerOlder