Skip to content

Instantly share code, notes, and snippets.

View usergenic's full-sized avatar
💭
Manifesting dreams! 🦄

Brendan Baldwin usergenic

💭
Manifesting dreams! 🦄
View GitHub Profile
We couldn’t find that file to show.
<html>
<head>
<script>
(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o<i;o++)e(a[o],b,f?d.call(a[o],o,e(a[o],b)):d,j);return a}return i?
e(a[0],b):w}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function na(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function oa(a){var b,d=[],f=[],e=arguments,j,i,o,k,n,r;i=c.data(this,"events");if(!(a.liveFired===this||!i||!i.live||a.button&&a.type==="click")){a.liveFired=this;var u=i.live.slice(0);for(k=0;k<u.length;k++){i=u[k];i.origType.replace(O,"")===a.type?f.push(i.selector):u.splice(k--,1)}j=c(a.target).closest(f,a.currentTarge
@usergenic
usergenic / to_proc.rb
Created October 27, 2010 21:52
Ruby Proc Coercion for Fun and Profit
# Given this is the definition of Symbol#to_proc as was added
# in ActiveSupport (and in the Ruby Extensions project before
# that) and later added to core Ruby 1.9 in C...
class Symbol
def to_proc
proc { |obj| obj.send(self) }
end
end
@usergenic
usergenic / Subclassing String
Created November 5, 2010 00:23
Good to do? Bad to do?
class String
end
class JSONString < String
def parse
JSON.parse(self)
end
end
module Enumerable
class Proxy
instance_methods.each do |method|
next if method.to_s =~ /\A__(id|send)__\Z/
undef_method(method)
end
def initialize(target, method=:map)
@target, @method = target, method
end
private
class Module
# just like include except it makes sure to find all
# the modules that have already included self and
# update those features with the given module.
def include_hard(include_me)
include include_me
ObjectSpace.each_object(Module) do |some_module|
next unless some_module.included_modules.include?(self)
next if some_module.included_modules.include?(include_me)
some_module.class_eval { include include_me }
module Name
def client
ApiClient.new
end
# this puts the instance method 'client' on Name.
# otherwise you should have said def self.client
extend self
#!/usr/bin/ruby
require 'rubygems'
require 'data_objects' # current master @ ed1ceefc
require 'dm-core' # current master @ 73860575
require 'dm-migrations' # current master @ ab608e81
class Order
include ::DataMapper::Resource
class Render::Scope
include ErbHelpers
def initialize(context)
@context=context
end
def binding
(proc { }).binding
@usergenic
usergenic / form.html
Created April 27, 2011 21:57
docstore callback reacharound
<form action="//ds.mydomain.com/"
enctype="multipart/form-data"
method="post">
<input name="callback"
type="hidden"
value="http://someapp.mydomain.com/upload_result" />
<input name="my_file_param"
type="file" />