Skip to content

Instantly share code, notes, and snippets.

@runeb
runeb / .gems
Created January 12, 2010 12:30
# Heroku .gems file
oauth
nokogiri
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",
#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;
-(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);
#!/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
#!/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]