Skip to content

Instantly share code, notes, and snippets.

View Overbryd's full-sized avatar

Lukas Rieder Overbryd

View GitHub Profile
@Overbryd
Overbryd / remove_colorspace_from_png.rb
Created May 28, 2009 12:42
Fix PNG colorspace issues (vs. CSS colorspace) using pngcrush
#!/usr/bin/env ruby
# this script is up to remove PNG colorspace information in order to display png's correctly along with css colors
# it requires pngcrush to be installed
# $ sudo port install pngcrush
Dir[File.join(%w(public images ** *.png))].each do |pngfile|
newfile = File.join(File.dirname(pngfile), 'new_' + File.basename(pngfile))
`pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB #{pngfile} #{newfile}`
# compression ftw
<Location />
<ifmodule mod_deflate.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# compress content with type html, text, and css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
@Overbryd
Overbryd / document.rb
Created February 19, 2010 17:56
Implement Friendly Permalinks the easy way. Why you should think twice before even starting to implement something like this.
class Document < ActiveRecord::Base
after_save :update_permalink
def to_param
permalink.blank? ? id.to_s : permalink
end
private
def update_permalink
@Overbryd
Overbryd / API.getJSON.js
Created November 5, 2010 20:50
abort()ing previous xhr requests to avoid callback race conditions
var API = {
getJSON: function(path, params, success){
var that = this;
if (_.isFunction(params)){
success = params;
params = null;
}
if(this.runningRequest)
this.runningRequest.abort();
@Overbryd
Overbryd / Che Guevara Fy
Created June 1, 2011 22:29
Code Challenge #1
Btw, I have recently started a small code battle upon an easy task.
The goal is to improve your self estimation skill and to code something minimalistic in the shortest time possible.
If you want to join the battle, just do the following:
1) Check the briefing: "Create a webservice that is generating the 'Che Guevara Effect' on an uploaded picture"
I have already done my job and implemented an working version of this here: http://che-guevara-fy.heroku.com/
2) You can accept the challenge by giving an upfront estimate on how much time you think is needed to implement and deploy the briefing.
@Overbryd
Overbryd / gitignore2tmproj.rb
Created June 16, 2011 14:03
This ruby script can mix your Textmate project file into a new one with file ignores from a .gitignore file
#!/usr/bin/env ruby
require 'rubygems'
require 'plist'
require 'fileutils'
plist = ARGV[0] || Dir.pwd.split('/').last
new_plist = "#{plist}.new.tmproj"
gitignore = ARGV[1] || '.gitignore'
if File.exist?(plist) && File.exist?(gitignore)
@Overbryd
Overbryd / key value store.md
Created June 16, 2011 17:08
Code Challenge #2

Code Challenge #2

A new challenge is on. This time @rtacconi had the idea:

"Idea:

Create a simple persistent key/value storage capable of SET, GET and DELETE actions.
It is forbidden to use Redis, MongoDB, or other ready made key/value solutions,
only storage to file, databases, serialization... are allowed
@Overbryd
Overbryd / keyvalue_cli.rb
Created June 17, 2011 18:15
Super easy key value store for Code Challenge #2 (https://gist.github.com/1029706)
#!/usr/bin/env ruby
require 'rubygems'
require 'gli'
require 'yajl/json_gem'
require 'uuid'
include GLI
ENDTAG = "\x5f\x5fEND\x5f\x5f"
pre do
@Overbryd
Overbryd / hacking-club-mate-imatate.md
Created June 22, 2011 13:46
Hacking Club Mate "imatate"

Hacking Club Mate "imatate"

Read about the end result here

Join me when I start brewing my first batch of Club Mate. Inspired by a podcast from chaos radio express on the topic "Hackerbrausen" (Hacker's soda, listen here) I want to try this by myself.

So far I have bought all the necessary ingrediends and tools to get started. And with the help from Jan (@janl) I can even carbonate the end result :)

When? Where?

@Overbryd
Overbryd / the-result-hacking-club-mate-imatate.md
Created June 30, 2011 17:13
The Result: Hacking Club Mate "imatate"

Hacking Club Mate "imatate"

See the original post here: Hacking Club Mate "imatate"

It was great fun!

Brewing was easy. Many people joined, and they did enjoy my special surprise: "Mate jelly shots". So after having a debate over how much gram is a cup for sugar, I just went by visual judgment. Out came two batches, I made a bigger one for Imatate and a small one for Maca Mate. Cooling was definitely an issue, it took ages to heat the huge pot and it took ages to cool it down. So we decided to put everything in the refridgerator and wait for the night to pass.