Skip to content

Instantly share code, notes, and snippets.

View lightyrs's full-sized avatar
🌒
ლ(▀̿̿Ĺ̯̿̿▀̿ლ)

Harris Novick lightyrs

🌒
ლ(▀̿̿Ĺ̯̿̿▀̿ლ)
View GitHub Profile
@lightyrs
lightyrs / fql.rb
Created July 7, 2011 02:33
A Minimalist Facebook FQL Client in Ruby
require "rubygems"
require "open-uri"
require "rack/utils"
require "json"
class Fql
class << self
attr_accessor :base_url
end
@lightyrs
lightyrs / gist:1074343
Created July 10, 2011 06:59 — forked from jjb/gist:996510
How to set the certificate file for Net::HTTP library-wide

In my previous post I described how to securely acquire the Mozilla list of root certificates and convert them to a form usable by curl and various libraries which don't ship with them.

Next, I want to point Net:HTTP at this file library-wide, so that it is used by all invocations of methods accessing https resources (in particular, Kernel#open, which in ruby 1.8.7 does not have a ca_file option and is therefore unusable with https). I hunted around the ruby standard library for a couple hours and came up with this:

require 'openssl'
require 'open-uri'
require 'net/https'

module Net
@lightyrs
lightyrs / gist:1108708
Created July 27, 2011 04:52
lion rails 3 setup
# 2011-07-25
#
# Mac OS X 10.7
# Xcode 4.1
# Install Lion.
# Xcode
# Download Xcode from Mac App Store.
@lightyrs
lightyrs / applehud.css
Created July 30, 2011 05:50
OS X HUD Panel in Pure CSS3
<!-- http://bobjr.ru/hud/simulator.html -->
<div id="window">
<div id="title">
<div id="close"></div>
Applied Styles
</div>
<div id="content">
<div class="row odd"></div>
@lightyrs
lightyrs / lion_buttons.css
Created July 31, 2011 18:54
OS X Lion Buttons in Pure CSS3
/*
<a href="#" class="ok buttons">OK</a>
<a href="#" class="cancel buttons">Cancel</a>
<a href="#" class="inactive buttons">Inactive</a>
<a href="#" class="small buttons">Small</a>
require 'action_controller/test_process'
# Paperclip attachments in factories, made easy based on technicalpickles
Factory.class_eval do
def attach(name, path, content_type = nil)
if content_type
add_attribute name, ActionController::TestUploadedFile.new("#{RAILS_ROOT}/#{path}", content_type)
else
add_attribute name, ActionController::TestUploadedFile.new("#{RAILS_ROOT}/#{path}")
end
@lightyrs
lightyrs / canvas_color_fade.js
Created October 15, 2011 09:19
Transition canvas img from grayscale to color
(function() {
var supportsCanvas = !!document.createElement('canvas').getContext;
supportsCanvas && (window.onload = greyImages);
function greyImages() {
var ctx = document.getElementsByTagName('canvas')[0].getContext('2d'),
img = document.getElementById('cvs-src'),
imageData, px, length, i = 0,
red, green, blue, grey;
@lightyrs
lightyrs / apple_browser_detect.js
Created October 16, 2011 19:05
How Apple does browser detection
SC._detectBrowser = function(userAgent, language) {
var version, webkitVersion, browser = {};
userAgent = (userAgent || navigator.userAgent).toLowerCase();
language = language || navigator.language || navigator.browserLanguage;
version = browser.version = (userAgent.match(/.*(?:rv|chrome|webkit|opera|ie)[\/: ](.+?)([ \);]|$)/) || [])[1];
webkitVersion = (userAgent.match(/webkit\/(.+?) /) || [])[1];
browser.windows = browser.isWindows = !! /windows/.test(userAgent);
browser.mac = browser.isMac = !! /macintosh/.test(userAgent) || (/mac os x/.test(userAgent) && !/like mac os x/.test(userAgent));
browser.lion = browser.isLion = !! (/mac os x 10_7/.test(userAgent) && !/like mac os x 10_7/.test(userAgent));
browser.iPhone = browser.isiPhone = !! /iphone/.test(userAgent);
@lightyrs
lightyrs / list_rails_models.rb
Created December 8, 2011 21:36
Rails List All Models
ActiveRecord::Base.connection.tables.map do |model|
model.capitalize.singularize.camelize
end
# returns ["Activity", "Article", "User", "Video", "Vote"]
@lightyrs
lightyrs / wanstrath.txt
Created December 30, 2011 22:52 — forked from defunkt/gist:6443
Chris Wanstrath Open Source Talk
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.