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
queue = [] | |
['hello', 'x', 'world'].each do |word| | |
queue << word and puts "Added to queue" unless word.length < 2 | |
end | |
puts queue.inspect | |
# Output: | |
# Added to queue | |
# Added to queue | |
# ["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
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
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
public static string EscapeXml( this string s ) | |
{ | |
string xml = s; | |
if ( !string.IsNullOrEmpty( xml ) ) | |
{ | |
// replace literal values with entities | |
xml = xml.Replace( "&", "&" ); | |
xml = xml.Replace( "<", "<" ); | |
xml = xml.Replace( ">", ">" ); | |
xml = xml.Replace( "\"", """ ); |
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 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
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
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl http://npmjs.org/install.sh | sh |
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
// most of render() | |
this.el.html(this.template()) | |
this.$('input[name=id]').val(this.endpoint.get('id')) | |
this.$('input[name=group]').val(this.endpoint.get('group')) | |
this.$('input[name=name]').val(this.endpoint.get('name')) | |
this.$('input[name=route]').val(this.endpoint.get('route')) | |
this.$('textarea[name=sample_xml]').val(this.endpoint.get('sample_xml')) |
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
(defun find-functional-test (test-file) | |
(find-file (replace-regexp-in-string "_test" "" test-file | |
(replace-regexp-in-string "test\\/functional" | |
"app\/controllers\/" | |
test-file)))) |
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
(defun test () | |
(let ((a 1) | |
(b (+ a 2))) | |
(message b))) | |
(test) | |
Debugger entered--Lisp error: (void-variable a) | |
(+ a 2) |
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
{ | |
"mingle.local": { | |
"_enabled": true, | |
"_rules": { | |
"#card-index": { | |
"font-size": "5em", | |
"color": "#0076BA" | |
}, | |
"#show_enumeratedpropertydefinition_479_drop_link": { | |
"font-weight": "bold", |
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
// 1: how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |
OlderNewer