Skip to content

Instantly share code, notes, and snippets.

View filipsalomonsson's full-sized avatar

Filip Salomonsson filipsalomonsson

View GitHub Profile

Keybase proof

I hereby claim:

  • I am filipsalomonsson on github.
  • I am filip (https://keybase.io/filip) on keybase.
  • I have a public key whose fingerprint is F44E 239D D008 CFA3 DE90 BF3B 6ED8 AD87 FDD5 D3B3

To claim this, I am signing this object:

Simple file/stream encryption using OpenSSL

Create and store a 512-byte random encryption key named secret:

$ mkkey secret

Encrypt the contents of file with the secret key and write it to file.enc:

$ encrypt secret < file > file.enc
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool YES;
sudo defaults delete /Library/Preferences/com.apple.windowserver DisplayResolutionDisabled;
// by the way, you need to logout and log back in for this to take effect. Or at least that's what
// Quartz Debug says. Who knows, maybe it's lying?
// P.S. Go to [Apple menu --> System Preferences --> Displays --> Display --> Scaled] after logging
// back in, and you'll see a bunch of "HiDPI" resolutions in the list to choose from.
@filipsalomonsson
filipsalomonsson / json.py
Created May 20, 2011 12:57
Simple JSON pretty-printer
#!/usr/bin/env python
# Copyright 2011 Filip Salomonsson <filip.salomonsson@gmail.com>
# MIT Licensed
# Simple JSON pretty-printer
# Save as ~/bin/json and pipe stuff to it.
import json
import sys
@filipsalomonsson
filipsalomonsson / buildlibxml.diff
Created May 9, 2011 20:20 — forked from ento/buildlibxml.diff
Installing lxml on a Mac OS X 10.6 that has no PPC support (read: Xcode 4)
diff --git a/buildlibxml.py b/buildlibxml.py
index bfcf3e4..7bf36e5 100644
--- a/buildlibxml.py
+++ b/buildlibxml.py
@@ -284,8 +284,11 @@ def build_libxml2xslt(download_dir, build_dir,
})
else:
env.update({
- 'CFLAGS' : "-arch ppc -arch i386 -arch x86_64 -O2",
- 'LDFLAGS' : "-arch ppc -arch i386 -arch x86_64",
@filipsalomonsson
filipsalomonsson / jquery.inverse.js
Created April 13, 2011 15:51
Untested plugin for getting the inverse of the last selection in jQuery
(function($) {
$.fn.inverse = function() {
var prevSelector = this.prevObject.selector,
suffix = this.selector.slice(prevSelector.length);
if (suffix.charAt(0) === " ") {
// Last action was a find
return this.prevObject.find(":not(" + suffix.slice(1) + ")");
} else {
return this.prevObject.not(this);
}
@filipsalomonsson
filipsalomonsson / .bashrc
Created July 14, 2010 21:30
If you ever forget to give grep some filenames and end up waiting while it waits for input, stuff this into your .bashrc.
# Call grep, with stdin closed if it is a terminal.
#
# Avoids the "eternal wait" problem when you've forgotten
# to specify a filename.
function grep { (tty -s && exec <&-; exec $(which grep) "$@"); }
#!/usr/bin/env python
# -*- coding: utf8 -*-
"""Stemmers for Swedish and English
Implements the Swedish stemming algorithm used in snowball:
<http://snowball.tartarus.org/algorithms/swedish/stemmer.html>
Implements the English (Porter2) stemming algorithm used in snowball:
<http://snowball.tartarus.org/algorithms/english/stemmer.html>
"""
@filipsalomonsson
filipsalomonsson / gist:131350
Created June 17, 2009 16:54
When someone links directly to a jpg on flickr, use this as a bookmarklet to get to the photo page
javascript:void(function(){n=parseInt((location.href.split("/").pop().split("_")[0]),10);s="";while(n>0){s="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"[n%2558]+s;n=Math.floor(n/58)};window.location="http://flic.kr/p/"+s;}())