Skip to content

Instantly share code, notes, and snippets.

View lwe's full-sized avatar
💭
I may be slow to respond.

Lukas Westermann lwe

💭
I may be slow to respond.
View GitHub Profile
@lwe
lwe / reset.css
Created July 1, 2009 09:15
Slightly edited YUI reset.css, i.e. basically changed border-collapse
/* Copyright (c) 2008, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 3.0.0pr2 */
html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:separate;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong
,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-b
ottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}
@lwe
lwe / faker_ch.rb
Created August 11, 2009 11:26
Swiss-ify random data generated by faker
# make faker a bit more swiss-friendly :)
module Faker
class Company
# Add swiss suffixes like AG, GmbH etc.
def self.suffix
%w(AG GmbH und\ Söhne und\ Partner &\ Co. Gruppe LLC Inc.).rand
end
end
@lwe
lwe / gravatar_helper.rb
Created September 16, 2009 13:07
Some simple helpers to construct gravatar urls and <img/>-tags.
module Gravatar
def self.options; @options ||= {}; end
module GravatarHelper
def gravatar_url(mail, options = {})
options = Gravatar.options.merge(options).stringify_keys!
options.assert_valid_keys('size', 'rating', 'default')
"#{build_gravatar_host(mail)}/avatar/#{Digest::MD5.hexdigest(mail.to_s.strip.downcase)}.jpg#{build_gravatar_url_options(options)}"
end
@lwe
lwe / example_usage.markdown
Created September 18, 2009 10:05
iPhoto-like preview batches (Video in action: http://www.vimeo.com/6639381)

in action: http://www.vimeo.com/6639381

javascript:

var pp = "/images/test/images_";
var images_p1 = [ pp + '1.jpg', pp + '2.jpg', pp + '3.jpg', pp + '4.jpg', pp + '5.jpg' ];
var images_p2 = [ pp + '6.jpg', pp + '7.jpg', pp + '8.jpg', pp + '9.jpg', pp + '10.jpg' ];

$('.preview').slideview(function(e) { return e.id == "p1" ? images_p1 : images_p2; }, { size: 75 });
@lwe
lwe / README.txt
Created November 5, 2009 07:43 — forked from rmm5t/README.md
Added german translations
You can represent time statements in most western languages where
a prefix and/or suffix is used.
The default case is to use suffix only (as in English), which you
do by providing the `suffixAgo` and `suffixFromNow` settings in
the strings hash (earlier versions of timeago used the deprecated
`ago` and `fromNow` options). If present, they are used.
2 minutes [suffixAgo]
2 minutes [suffixFromNow]
@lwe
lwe / savon_nokogiri_response_hack.rb
Created December 16, 2009 16:18
Handle SOAP multi-ref entries a bit more gracefully...
# Basically replaces just all `<arg href="#xyz"/>`-entries with the "real" value.
module NokogiriResponse
def xml_body
@xml_body ||= NokogiriResponse.create_doc_and_process_multirefs(@response.body)
end
def to_hash_from_xml_body
@hash_body ||= Crack::XML.parse(xml_body.to_s).find_regexp([/.+:Envelope/, /.+:Body/, /.+/]).map_soap_response
end

Meine Vorstellung ist, dass ihr grundsätzlich eine API-Methode zur Verfügung stellt um die Spieler + ihre Stats abzuholen, vom iPhone aus rufen wir danach z.B. folgende URL auf:

GET http://www.scb.ch/api/players.json?token=${SHARED_TOKEN}

Dadurch bekommen wir ein JSON Resultat wie bei resp_spieler.js, wichtig ist, dass der Content-Type application/json ist. Das oben erwähnt ${SHARED_TOKEN} ist ein kleiner Hash, denn wir jedes Mal mitsenden, somit können wir grundsätzlich sicherstellen, dass nur unsere iPhone App darauf zugriff hat (und ihr müsst überprüfen ob das Token übereinstimmt). Gut, zugegeben, wenn man will findet man das Token relativ schnell heraus, aber joa, besser als nichts. Ausser, man könnte die Daten via HTTPS abrufen...

Anyway, denke für die Kader-Liste + Spieler-Statistiken sollte dies erst einmal reichen. Wichtig ist einfach, dass ihr einen kleines Script erstellt, welches diese Daten in diesem Format ausgibt...

@lwe
lwe / rails_wrapper.sh
Created July 6, 2010 12:58
Simple rails wrapper, which transparently handles Rails 2.x vs. Rails 3 projects.
## rails wrapper
function rails() {
if [ -x `pwd`/script/rails ]; then
echo "[run] ./script/rails"
`pwd`/script/rails $*
elif [ -f `pwd`/Gemfile ]; then
echo "[run] bundle exec rails"
bundle exec rails $*
else
_rails_bin=$(\which rails | tail -1)
@lwe
lwe / brew-more.rb
Created July 14, 2010 08:53
Try to scrape formula information from @formula.homepage.
# Small utility which uses the homepage and nokogori to get a description from the formula's homepage.
#
# As written in the homebrew wiki:
# > Homebrew doesn’t have a description field because the homepage is always up to date,
# > and Homebrew is not. Thus it’s less maintenance for us. To satisfy the description
# > we’re going to invent a new packaging microformat and persuade everyone to publish
# > it on their homepage.
#
# Too bad no packaging microformat has yet been invented, but brew-more just first looks for a
# `<meta name="description">` tag, then for an `a#project_summary_link` tag (which is used in
@lwe
lwe / brew-rebase.sh
Created July 28, 2010 07:15
Replacement for `brew update` which uses rebase.
#!/bin/sh
# DISCLAIMER:
#
# brew update now has a --rebase switch, thus this script is certainly obsolet.
#
# USAGE: brew-rebase [--verbose|-v] [remote] [branch]
#
# Fetches upstream and rebases HOMEBREW_REPOSITORY ($_git_repo)