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
#include <unistd.h> | |
float o=0.075,h=1.5,T,r,O,l,I;int _,L=80,s=3200;main(){for(;s%L|| | |
(h-=o,T= -2),s;4 -(r=O*O)<(l=I*I)|++ _==L&&write(1,(--s%L?_<L?--_ | |
%6:6:7)+"World! \n",1)&&(O=I=l=_=r=0,T+=o /2))O=I*2*O+h,I=l+T-r;} |
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
class String | |
def squish! | |
strip! | |
gsub!(/\s+/, ' ') | |
self | |
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
- flash.each do |key, msg| | |
%div{ :id => key }= msg |
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
it "registers a new temperature reading via the API" do | |
page.driver.post('/temperature/new', { :params => { :degrees => "30" } }) | |
page.driver.status_code.should eql 200 | |
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
# This is the current solution. It merely validates the string's inclusion in | |
# the given list, and saves it as a string. | |
ActiveRecord::Schema.define(:version => 20110101000000) do | |
create_table "foos", :force => true do |t| | |
t.string "bar" | |
end | |
end | |
class Foo < ActiveRecord::Base |
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 sort some_array # This "wraps" recursive_sort. | |
recursive_sort some_array, [] | |
end | |
def recursive_sort unsorted_array, sorted_array | |
# Check to see if there is anything to sort | |
if unsorted_array.empty? | |
return sorted_array | |
else | |
# Start with the first member of unsorted array, |
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 Anagram | |
class Wordlist | |
def load_words | |
@words = Hash.new{[]} | |
File.open("/usr/share/dict/words", "r") do |file| | |
while line = file.gets | |
word = line.chomp | |
@words[word.split('').sort!.join('')] += [word] | |
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
$ sudo aptitude install apache2 dnsmasq | |
$ sudo vim /etc/dnsmasq.conf | |
# ... | |
address=/dev/127.0.0.1 | |
listen-address=127.0.0.1 | |
$ sudo vim /etc/dhcp3/dhclient.conf | |
# uncomment line 20: |
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 | |
extend self | |
def bar | |
"hello world" | |
end | |
end | |
Foo.bar | |
#=> "hello world" |
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
if [[ -n "$PS1" ]]; then | |
HISTCONTROL=ignoredups:ignorespace | |
HISTSIZE=1000 | |
HISTFILESIZE=2000 | |
shopt -s histappend | |
shopt -s checkwinsize | |
# make less more friendly for non-text input files, see lesspipe(1) | |
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" |