Skip to content

Instantly share code, notes, and snippets.

View EmmanuelOga's full-sized avatar
🕹️

Emmanuel Oga EmmanuelOga

🕹️
View GitHub Profile
@EmmanuelOga
EmmanuelOga / responsive-context-images.html
Created March 1, 2012 22:55 — forked from vasilisvg/responsive-context-images.html
Responsive context aware images without cookies or server logic
<!doctype html>
<meta charset="UTF-8">
<title>Client side context aware responsive images</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.image-container {
width: 50%;
position: relative;
}
.image-container img {
@EmmanuelOga
EmmanuelOga / LICENSE.txt
Created February 21, 2012 19:24 — forked from aemkei/LICENSE.txt
Binary Tetris - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@EmmanuelOga
EmmanuelOga / g.sh
Created January 31, 2012 17:35 — forked from anonymous/g.sh
#!/usr/bin/env ruby
cmd = %Q{curl https://gist.github.com/gists -s -L -o /dev/null -w "%{url_effective} " }
files = ARGV.empty? ? Dir["**/*"] : Dir[*ARGV].uniq
files.select { |f| File.file?(f) }.each_with_index do |path, i|
cmd << %Q{-F "file_ext[gistfile#{i}]=#{File.extname(path)[1..-1]}" }
cmd << %Q{-F "file_name[gistfile#{i}]=#{File.basename(path)}" }
cmd << %Q{-F "file_contents[gistfile#{i}]=<#{path}" }
var setTextMeasure = function (contentElement, targetMeasure, maxSize, minSize) {
if (!contentElement) contentElement = document.createElement('p');
if (!targetMeasure) targetMeasure = 66;
if (!maxSize) maxSize = 16;
if (!minSize) minSize = 9;
var sizer = contentElement.cloneNode();
sizer.style.cssText = 'margin: 0; padding: 0; color: transparent; background-color: transparent; position: absolute;';
run "rm public/index.html"
file "Isolate", <<-END
gem "rails", "3.0.0"
gem "haml", "3.0.18"
gem "sqlite3-ruby", "1.3.1"
env :development do
gem "thin", "1.2.7"
gem "haml-rails", "0.2"
@EmmanuelOga
EmmanuelOga / nokogiri.to_hash.rb
Created April 19, 2010 04:38 — forked from dimus/Hash.from_xml using Nokogiri
Convert a nokogiri tree to a Hash
module NokogiriUtils
extend self
# http://gist.github.com/370755
def hash_from_node(node)
{ node.root.name.to_sym => xml_node_to_hash(node.root) }
end
def xml_node_to_hash(node)
return to_value(node.content.to_s) unless node.element?
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
require 'rubygems'
require 'eventmachine'
require 'em-http' # gem install em-http-request
require 'yajl' # gem install yajl-ruby
module ChatClient
def post_init
@name = "anonymous_#{ChatClient.client_num+=1}"
@sid = ChatClient.channel.subscribe(method(:send_msg))
@buf = ''
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'nokogiri'
class Array
module RegexpIndexing
def [] a
a.is_a?(Regexp) ? select {|b| b.is_a?(String) && b[a]} : super
# More "proper" than a miniskirt (http://gist.github.com/273579).
class Minidress
@@factories = {}
class << self
def define(name, &block)
@@factories[name.to_s] = block
end
def build(name, attrs = {})
new(name.to_s.classify.constantize.new, &@@factories[name.to_s]).record