Skip to content

Instantly share code, notes, and snippets.

View cymen's full-sized avatar

Cymen Vig cymen

  • Vig Consulting, LLC
  • Remote
View GitHub Profile
@cymen
cymen / gist:1282505
Created October 12, 2011 20:51 — forked from saikat/gist:1084146
Stripe sample checkout form
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Sample Form</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script>
<script type="text/javascript" src="https://js.stripe.com/v1/"></script>
<script type="text/javascript">
def first(string, length)
string[0..length-1]
end
def rest(string, index)
if string[index] == " "
index += 1
end
return string[index..-1]
end
presenterData: function () {
var attributes = _.clone(this.model.attributes);
var that = this;
attributes.display_name = function() {
// logic here to return name as combination of fields
}
return attributes;
}
...
Name: {{display_name}}
...
@cymen
cymen / 0-readme.md
Created April 15, 2012 04:48
ruby-1.9.3-p125 cumulative performance patch.

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

class Example
def convert(arg1, arg2, arg3)
# do something
return arg3
end
end
require './example'
describe Example do
it "can mock convert and return the 3rd argument" do
example = Example.new
example.stub(:convert)
example.should_receive(:convert).with(any_args()).and_return { |*args| args[2] }
result = example.convert('a', 'b', 'c')
result.should eq('c')
class Person
attr_accessor :name, :phone
def initialize hash
@name = hash['name']
@phone = hash['phone']
end
end
class Base
def self.hash_attr_accessor(*accessors)
accessors.each do |m|
define_method(m) do
@attributes[m]
end
define_method("#{m}=") do |value|
@attributes = {} if @attributes.nil?
class Person < Base
hash_attr_accessor :name, :phone
end