Skip to content

Instantly share code, notes, and snippets.

View nickyp's full-sized avatar
🛁
Editing my status

Nicky Peeters nickyp

🛁
Editing my status
  • Amsterdam, Netherlands
View GitHub Profile
// CSS built for http://kpax.wolf359.be/kpax/dynamic/reddit/reddit-home
body {
margin: 5px 5px 5px 10px;
padding: 0;
background: url('bg.gif') 0 0 repeat-x;
font:1.1em/1.4em Georgia, Times, serif;
color: #464646;
background-color: transparent;
}
# Package Maintainer: Increment phusion_release to match latest release available
%define phusion_release 2009.10
Summary: Ruby Enterprise Edition (Release %{phusion_release})
Name: ruby-enterprise
Vendor: Phusion.nl
Packager: Adam Vollrath <adam@endpoint.com>
Version: 1.8.7
Release: 2%{dist}
License: GPL
require 'nokogiri'
# \
# \
# \\
# \\
# >\/7
# _.-(6' \
# (=___._/` \
renderContentOn: html
html heading: 'Reddit.st'.
html heading level: 3; with: 'In 10 elegant Smalltalk classes'.
self renderActionsOn: html.
self renderHighestRankingLinksOn: html.
self renderLatestLinksOn: html
renderActionsOn: html
html paragraph: [
html anchor callback: [ ]; with: 'Refresh'.
// Save state of UITableView scroll position:
save CGPoint contentOffset = self.view.contentOffset;
[myWebView stringByEvaluatingJavaScriptFromString:@"window.scrollTo(0,0);"];
require 'rubygems'
require 'active_support'
class Base
class_inheritable_accessor :name
self.name = "Base"
end
# destructures the parameter values according to the order of the sorted keys
# Usage:
# hash = { :macbook => 1, :iphone => 2, :ipad => 3 }
# ipad, iphone, macbook = destructuring_bind(hash)
def destructuring_bind(hash)
hash.sort_by {|k, v| k.to_s }.map {|e| e[1] }.flatten
end
@nickyp
nickyp / local_variables_set.rb
Created October 25, 2010 16:17
experiment trying to destructuring-bind a hash into local variables
# see
# http://markmail.org/message/zeessthwisaozywf#query:Ruby%20local_variable_set+page:1+mid:zeessthwisaozywf+state:results
require 'rubygems'
require 'extensions/binding'
foo = "bar"
puts "foo: " + Kernel.binding["foo"]
puts ""
@nickyp
nickyp / org.redis.redis-server.plist
Created November 9, 2010 16:34
Mac OS X LaunchDaemon plist for Redis
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.redis.redis-server</string>
<key>ProgramArguments</key>
<array>
<string>/opt/redis/redis-server</string>
@nickyp
nickyp / gist:826228
Created February 14, 2011 17:41
rescue_record_invalid
def rescue_record_invalid(e)
logger.info(e)
message = e.record.errors.map {|error|
"#{t('activerecord.attributes.' + error[0])} #{error[1]}"
}.join("\n")
respond_to do |format|
format.xml {
render :status => :unprocessable_entity,