Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby -wKU
# http://blog.grayproductions.net/articles/the_unicode_character_set_and_encodings
module UTF8Checksum
def is_utf8?
where_we_were = pos
begin
loop do
break if eof?
first_byte = "%08b" % read(1)[0]
#!/usr/bin/env ruby
# put in /etc/munin/plugins and restart munin-node
# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
# NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats
def output_config
puts <<-END
graph_category App
graph_title Passenger memory stats
graph_vlabel count
-(UIImage*)imageByScalingToSize:(CGSize)targetSize
{
UIImage* sourceImage = self;
CGFloat targetWidth = targetSize.width;
CGFloat targetHeight = targetSize.height;
CGImageRef imageRef = [sourceImage CGImage];
CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageRef);
#include <sys/types.h>
#include <ifaddrs.h>
#include <netinet/in.h>
#include <arpa/inet.h>
- (NSString *)getIPAddress
{
NSString *address = @"error";
struct ifaddrs *interfaces = NULL;
struct ifaddrs *temp_addr = NULL;
int success = 0;
require 'rubygems'
require 'oauth'
KEY = "replace with your key"
SECRET = "replace with your secret"
consumer = OAuth::Consumer.new(KEY, SECRET, {
:site=>"https://www.google.com",
:request_token_path=>"/accounts/OAuthGetRequestToken",
:authorize_path=>"/accounts/OAuthAuthorizeToken",
require 'rubygems'
require 'oauth'
KEY = "replace with your key"
SECRET = "replace with your secret"
consumer = OAuth::Consumer.new(KEY, SECRET, {
:site=>"https://www.google.com",
:request_token_path=>"/accounts/OAuthGetRequestToken",
:authorize_path=>"/accounts/OAuthAuthorizeToken",
@runeb
runeb / .gems
Created January 12, 2010 12:30
# Heroku .gems file
oauth
nokogiri
@runeb
runeb / mongoid.nb.yml
Created August 30, 2010 20:12
Norwegian translation for Mongoid
nb:
activemodel:
errors:
messages:
taken: er allerede i bruk
mongoid:
errors:
messages:
document_not_found:
@runeb
runeb / db.no.clean.css
Created September 1, 2010 14:29
Cleaning up db.no
/* Generell plagsomhet */
.skattesok2009 {display: none!important;}
#solBox {display: none!important;}
#header {display:none!important;}
div.ad {display: none!important;}
#ad-top {display: none!important;}
div#topp-ad {display: none!important;}
#tvguide .head {display: none!important; }
iframe {display: none!important;}
#footerwrapper {display: none!important;}
# An attempt at visualising classbox local rebinding as described in
# http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.3.4133&rep=rep1&type=pdf
#
# Suppose a classbox ClassBox1 defines a class C with two methods, m callin n, and
# classbox ClassBox2 imports C from ClassBox1 and replaces n. We say that…
class C;end
module ClassBox1
refine C do