Skip to content

Instantly share code, notes, and snippets.

View dworznik's full-sized avatar

Patryk Dwórznik dworznik

  • Seoul, South Korea
  • 00:52 (UTC +09:00)
View GitHub Profile
class String
@@coder = HTMLEntities.new
def repair!
self.force_encoding('UTF-8')
self.replace(@@coder.decode(self))
end
end
#!/bin/sh
HOST="s.rootnode.net"
GEMS_PATH="www/bzium.net/htdocs/gems"
if [ "$1" != "" ] && [ `echo $1 | awk '{ print substr($0, length($0)-2, 3)}'` == "gem" ]; then
scp $1 $USER@$HOST:$GEMS_PATH || exit 1
ssh $USER@$HOST 'source .bash_profile; cd $GEMS_PATH; gem generate_index'
else
echo "Missing gem file"
:javascript
var mp_protocol = (('https:' == document.location.protocol) ? 'https://' : 'http://');
document.write(unescape('%3Cscript src="' + mp_protocol + 'api.mixpanel.com/site_media/js/api/mixpanel.js" type="text/javascript"%3E%3C/script%3E'));
:javascript
try { var mpmetrics = new MixpanelLib('<TOKEN>'); } catch(err) { null_fn = function () {}; var mpmetrics = { track: null_fn, track_funnel: null_fn, register: null_fn, register_once: null_fn, register_funnel: null_fn }; }
@dworznik
dworznik / euler001.clj
Created February 7, 2011 00:42
Find the sum of all the multiples of 3 or 5 below 1000
(reduce + (filter #(or (= 0 (rem % 3)) (= 0 (rem % 5))) (range 1 1000)))
@dworznik
dworznik / each.js
Created July 14, 2011 20:51
Array.each()
Array.prototype.each = function(fun) {
if(typeof(fun) != "function") return;
for(var i = 0; i < this.length; i++) {
fun(this[i]);
}
return this;
}
@dworznik
dworznik / apns_sender.rb
Created November 12, 2011 13:25
Apple Push Notification Service Sender
#!/usr/bin/env ruby -wKU
# USAGE
#
# apns_cert = './apns-dev.pem'
# device_token = 'XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX'
#
# APNSender.open(apns_cert, :sandbox) { |s| s.send(device_token, "Alert text") }
#
# sender = APNSender.open(apns_cert, :sandbox)
@dworznik
dworznik / embed.py
Created June 11, 2013 21:12
Embeds lyrics in ID3 tag
import mutagen.mp3
import mutagen.id3
import sys
def write_id3(file, lyrics):
tag = mutagen.mp3.MP3(file)
atom = u"USLT::'eng'"
if lyrics is None:
if atom in tag: del tag[atom]
else:
@dworznik
dworznik / ClassLoadContext.java
Created April 1, 2014 15:47
The following class serves as a global decision point for acquiring the best classloader to use at any given time in the application.
package com.vladium.utils;
// ----------------------------------------------------------------------------
/**
* Information context for {@link IClassLoadStrategy#getClassLoader(ClassLoadContext)}.
*
* @author (C) <a href="http://www.javaworld.com/columns/jw-qna-index.shtml">Vlad Roubtsov</a>, 2003
*/

Keybase proof

I hereby claim:

  • I am dworznik on github.
  • I am dworznik (https://keybase.io/dworznik) on keybase.
  • I have a public key whose fingerprint is 3FC8 969D 3B69 E1DE 47A7 9FD6 91E0 E6EF F796 5496

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am dworznik on github.
* I am dworznik (https://keybase.io/dworznik) on keybase.
* I have a public key whose fingerprint is 51C1 BA1A 66D2 E1F8 2D80 9B3F EAD1 8F87 CBA6 43A8
To claim this, I am signing this object: