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
- $f = new form($this->parser, '/',$user) do | |
%p | |
= $f->input('name') | |
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' | |
gem 'dm-core' | |
require 'dm-core' | |
DataMapper.setup(:default, "mysql://root:password@localhost/db_testing") | |
DataMapper.setup(:external, "sqlite3:///#{Dir.pwd}/db2.db") | |
DataMapper::Logger.new(STDOUT, :debug) | |
DataObjects::Sqlite3.logger = DataObjects::Logger.new(STDOUT, :debug) | |
class User |
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
#!ruby1.9 | |
counts = [] | |
reference = [] | |
file = File.new(__FILE__) | |
line_count = 1 | |
while line = file.gets | |
reference[line_count] = line | |
line_count += 1 | |
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
require 'rubygems' | |
require 'mechanize' | |
a = WWW::Mechanize.new { |agent| | |
agent.user_agent_alias = 'Mac Safari' | |
} | |
a.get('http://en.wikipedia.org/wiki/Extrajudicial_killings_and_forced_disappearances_in_the_Philippines') do |page| | |
puts page.body | |
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
class Object | |
def new_method | |
puts "hi from a new method" | |
end | |
end | |
class One | |
end | |
a = One.new |
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 matrix_multiplier(a,b): | |
result = [] | |
print('len: ', len(a[0]), ' and ', len(b[0])) | |
for i in range(0, len(a[0])): | |
print("i is: ", i) | |
result.append([]) | |
for j in range(0, len(b[0])): | |
print('j is: ', j) | |
row_sum = 0 | |
for k in range(0, len(b[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
EmailAddress = begin | |
alpha = "a-zA-Z" | |
digit = "0-9" | |
atext = "[#{alpha}#{digit}\!\#\$\%\&\'\*+\/\=\?\^\_\`\{\|\}\~\-]" | |
dot_atom_text = "#{atext}+([.]#{atext}*)*" | |
dot_atom = "#{dot_atom_text}" | |
qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]' | |
text = "[\\x01-\\x09\\x11\\x12\\x14-\\x7f]" | |
quoted_pair = "(\\x5c#{text})" | |
qcontent = "(?:#{qtext}|#{quoted_pair})" |
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 <string> | |
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
#define input "prev-state" | |
#define output "CylinderVMD" | |
#define N 1100 |
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
# thanks to @judofyr for explaining this to me like thus: | |
# when ruby sees "bar =" (even thought it's not eval'd) it creates a local variable and assigns it to nil. | |
# so the first "bar" is a method call, while the second is a local variable. it should work if you replace | |
# it with "self.bar". | |
class Foo | |
attr_accessor :bar, :id | |
def initialize id | |
@id = id |
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
function decrSpeed(a, b, c, d) { | |
if (!c || c == '' || c>100) { | |
c = 0; | |
} | |
if ((!d && c>=a) || (d && c<=a)) { | |
return c; | |
} | |
var r = Math.floor(a-((a-c)/b)); | |
return (((!d && r>=c && r<Math.floor(a)) || (d && r<=c && r>Math.floor(a))) ? r : c); | |
} |