Skip to content

Instantly share code, notes, and snippets.

Weather_Agent = Class.create({
initialize: function(woeid) {
this.woeid = woeid;
},
get: function(on_complete, on_error) {
var resource = 'http://weather.yahooapis.com/forecastrss?u=c&w=' + this.woeid;
new Ajax.Request(resource, {
module Facebooker
module ControllerExtensions
module ClassMethods
def facebooker_service_for_api
include ControllerExtensions::InstanceMethods
end
end
module InstanceMethods
def facebooker_errors
@dylanmei
dylanmei / SeoAssist.rb
Created January 27, 2011 01:57
rack _escaped_fragment_ handling
# Make redirects for SEO needs
class SeoAssist
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
@dylanmei
dylanmei / gist:1218387
Created September 15, 2011 02:34
Dynamic Resource magic
class Program
{
static void Main()
{
var view = new View();
System.Console.WriteLine(view.Resources.A.B.Value);
System.Console.WriteLine(view.Resources.A.B.Blah);
System.Console.ReadLine();
}
}
@dylanmei
dylanmei / gist:1680166
Created January 26, 2012 01:04
Famous people twitter search
require 'twitter'
@term = ARGV.first
puts "Famous people twitter search"
puts "You're looking for #{@term}..."
exit unless @term && @term.size > 0
Twitter.configure do |config|
config.consumer_key = 'key'
config.consumer_secret = 'secret'
@dylanmei
dylanmei / gist:1684240
Created January 26, 2012 18:33
Microsoft JSON date retardify & unretardify
class Time
def to_json(*)
"\/Date(#{self.strftime("%s000%z")})\/"
end
def self.from_json(jsonDate)
/Date\((?<msecs>\d+)(?<offset>-?\d+)\)/ =~ jsonDate
return nil if msecs.nil?
Time.at(msecs.to_i / 1000)
end
@dylanmei
dylanmei / gist:1689845
Created January 27, 2012 17:11
Chrome disable security for development
open -a Google\ Chrome --args --disable-web-security -–allow-file-access-from-files
@dylanmei
dylanmei / Getty Images CONTRIBUTING template.md
Created September 19, 2012 17:30
Getty Images CONTRIBUTING template

We love pull requests. Here's a quick guide:

  1. Fork the repo.
  2. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate:
  3. Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, we need a test!
  4. Make the test pass.
  5. Push to your fork and submit a pull request.
@dylanmei
dylanmei / beanshell scrape
Created March 25, 2013 14:54
Reading a page with java/beanshell
import java.io;
url = new URL("http://www.yahoo.com");
stream = new InputStreamReader(url.openStream());
reader = new BufferedReader(stream);
buffer = new StringBuilder();
while ((line = reader.readLine()) != null) {
buffer.append(line + '\n');
}
@dylanmei
dylanmei / gist:5271001
Created March 29, 2013 13:53
overwrite author/commiter on commit history
#!/bin/bash
git filter-branch --env-filter '
if [ "$GIT_AUTHOR_NAME" = "old author" ];
then
GIT_AUTHOR_NAME="new author";
GIT_AUTHOR_EMAIL="<youmail@somehost.ext>";
fi
if [ "$GIT_COMMITTER_NAME" = "old committer" ];
then