Skip to content

Instantly share code, notes, and snippets.

View ashgti's full-sized avatar

John Harrison ashgti

View GitHub Profile
- $f = new form($this->parser, '/',$user) do
%p
= $f->input('name')
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
#!ruby1.9
counts = []
reference = []
file = File.new(__FILE__)
line_count = 1
while line = file.gets
reference[line_count] = line
line_count += 1
end
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
class Object
def new_method
puts "hi from a new method"
end
end
class One
end
a = One.new
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])):
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})"
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
#define input "prev-state"
#define output "CylinderVMD"
#define N 1100
# 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
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);
}