Skip to content

Instantly share code, notes, and snippets.

View plindberg's full-sized avatar

Peter Lindberg plindberg

View GitHub Profile
@plindberg
plindberg / snippet.js
Created July 22, 2009 15:12
Boilerplate for jQuery-powered bookmarklet
(function(){
var run=function(){
// code here...
};
if(typeof jQuery=='undefined'){
var s=document.createElement('script');
s.src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js';
s.loaded=false;
s.onload=function(){
s.loaded=true;
@plindberg
plindberg / gist:172008
Created August 21, 2009 13:43
This can’t be right?
/\bid(é|é)\b/.match('idéer')
# => #<MatchData "id&eacute;" 1:"&eacute;">
/\bid(é|&eacute;)\b/.match('idéer')
# => nil
@plindberg
plindberg / checkkit.rb
Created August 26, 2009 09:11
Koden som fiskade fram vinnare i glasstävlingen på Jaiku
require 'rubygems'
require 'ruby-debug'
require 'hpricot'
require 'open-uri'
require 'icecream_checker'
checker = IcecreamChecker.new [2, 5, 6, 11, 15, 21, 22, 23, 30, 39]
checker.disqualify('snoleoparden')
checker.disqualify('fleecelabs')
checker.disqualify('alla')
require 'rubygems'
require 'open-uri'
require 'nokogiri'
URL = 'http://simplesignup.se/private_event/2905/2dbaa69f97'
while true
body = Nokogiri::HTML(open(URL).read)
if body.css('select').size > 0
@plindberg
plindberg / rip-julkalendern-2010.sh
Created December 1, 2010 19:37
Rippa och bränn årets julkalender i Sveriges Radio (på Mac)
#!/bin/bash
BASE_URL=http://sverigesradio.se
ASX_URL=$(curl -Ls ${BASE_URL}'/sida/default.aspx?programid=3023' \
| sed -e '/button-wrapper.*href=".*type=broadcast/!d' \
-e 's/^.*a href="//; s/".*$//' \
| ruby -rcgi -n -e 'puts CGI::unescapeHTML($_)')
M4A_URL=$(curl -s ${BASE_URL}${ASX_URL} \
@plindberg
plindberg / rip-musil.sh
Created December 5, 2010 21:18
Tankar ned samtliga avsnitt av följetongen Mannen utan egenskaper
ASX_URLS=$(curl -Ls "http://sverigesradio.se/sida/default.aspx?programid=1111" \
| sed -e '/href=".*asx".*title="Mann/!d' -e 's/^.*a href="//; s/".*$//' \
| sort | uniq)
for ASX_URL in ${ASX_URLS}; do
M4A_URL=$(curl -s http://sverigesradio.se${ASX_URL} \
| sed -e '/<ref/!d' -e 's/^.*href="//; s/".*$//')
curl -LO ${M4A_URL}
done
@plindberg
plindberg / gist:990919
Created May 25, 2011 12:58
Installing Ruby 1.9.2 via RVM, RubyGems, and Passenger on Debian 5.x (for Rails 3.1 deployment)

Install needed packages

apt-get update
apt-get install build-essential bison openssl libreadline5 libreadline5-dev \
  curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 \
  libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev

Install RVM

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="urn:ObjektService" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="urn:ObjektService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<env:Body>
<AddProjektObjekt>
<ObjektToAdd>
<supplier>22</supplier>
<broker>1</broker>
<maklarsystemObjektId>property:6ec6375a</maklarsystemObjektId>
<urlBeskrivning>http://veidekkebostad.se/snokristallen/hus-7</urlBeskrivning>
<omrade>Hägersten, Västertorp</omrade>
%ol.season-list
%li.listed-season
= link_to '#', class: 'arrow-link' do
= image_tag 'downarrow.png', class: 'arrow', alt: nil
Säsong 2
%ol.episode-list-for-season
%li.listed-episode-current= link_to 'Avsnitt 2', '#'
%li.listed-episode= link_to 'Avsnitt 1', '#'
%li.listed-season
= link_to '#', class: 'arrow-link' do
@plindberg
plindberg / jaikuslurp.md
Created January 4, 2012 21:03
Archive your Jaiku on jaikuarchive.com!

As you may have heard, Jaiku is going away on January 15th. Perhaps you want to save your posts on Jaiku Archive. Here’s an easy way to do it, if you have a Mac or Unix machine.

Note that currently, you need Xcode on your Mac to be able to run this. Sorry for not realizing this up front. While it is free from the App Store, it would take you a while to download and install. However, I can’t guarantee that I’ll be able to rewrite the script to not require Xcode anytime soon.

If you have a Mac, hop into Terminal and enter the following, substituting “plindberg” for your Jaiku username.

If you’re on a Unix machine, you probably know what to do. But you’ll need Ruby 1.8.7 or later, and RubyGems.

bash &lt; &lt;(curl -s fleecelabs.se/jaikuslurp/) -s plindberg