Skip to content

Instantly share code, notes, and snippets.

View tarmolehtpuu's full-sized avatar

Tarmo Lehtpuu tarmolehtpuu

View GitHub Profile
<?hh
function get_app_to_handle_uri(string $uri): {
switch ($uri->getProtocol()) {
case 'itunes':
return ITUNES_APP;
case 'irc':
return IRC_APP;
case 'https':
if ($uri->getAuthority()->endsWith('.onion')) {
class UserService
def self.register(params)
user = User.new
user.first_name = params[:first_name]
user.last_name = params[:last_name]
user.email = params[:email]
user.password = params[:password]
user.password_confirmation = params[:password_confirmation]
user.save
@tarmolehtpuu
tarmolehtpuu / gist:5081363
Created March 4, 2013 10:28
ID Card Crash
Process: id-updater [10658]
Path: /Library/EstonianIDCard/*/id-updater.app/Contents/MacOS/id-updater
Identifier: id-updater
Version: 3.6.0.574 (3.6.0.574)
Code Type: X86-64 (Native)
Parent Process: launchd [120]
User ID: 501
Date/Time: 2013-03-04 12:27:42.012 +0200
OS Version: Mac OS X 10.8.2 (12C60)
import Image
import random
TERRAIN_GRASS = 0
TERRAIN_SAND = 1
TERRAIN_WATER = 2
TERRAIN_DIRT = 3
COLORS = [
(0x52, 0x65, 0x35, 0x00),
@tarmolehtpuu
tarmolehtpuu / gist:1682346
Created January 26, 2012 11:28
OS X redirect 80 -> 8080
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>ee.perfectline.httpredirect</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
@tarmolehtpuu
tarmolehtpuu / gist:1095382
Created July 20, 2011 17:13
Quick hack to symlink ImageMagick binaries to /usr/bin (probably simplest way to fix it for Rubymine)
#!/usr/bin/env ruby
PATH_SRC = "/usr/local/bin"
PATH_DST = "/usr/bin"
%w[animate compare composite conjure convert display identify import mogrify montage stream].each do |file|
if File.exists?("#{PATH_DST}/#{file}")
puts "[EXIST]: #{file}"
else
@tarmolehtpuu
tarmolehtpuu / shm.rb
Created June 27, 2011 11:07
Linux and OS X Shared Memory Calculator
#!/usr/bin/env ruby
def halt
puts "----------------------------------"
puts " Usage "
puts "----------------------------------"
puts "./shm.rb <size> <units>"
puts "\tsize = integer > 0"
puts "\tunits = MB or GB"
exit
@tarmolehtpuu
tarmolehtpuu / ytget.rb
Created June 27, 2011 10:44
Youtube Downloader (Ruby)
#!/usr/bin/ruby -rubygems
require 'uri'
require 'curb'
if ARGV.size == 0
puts "Usage: ytget <video>"
exit 0
end
@tarmolehtpuu
tarmolehtpuu / gist:987290
Created May 23, 2011 18:58
patch SDL for UrT 4.0 to window mode full screen (OS X)
--- a/src/video/quartz/SDL_QuartzVideo.m Thu Feb 17 02:31:50 2011 -0800
+++ b/src/video/quartz/SDL_QuartzVideo.m Tue Feb 22 22:21:26 2011 +0200
@@ -761,7 +761,7 @@
[ qz_window setFrameTopLeftPoint:NSMakePoint((float) origin_x, (float) (this->info.current_h - origin_y))];
center_window = 0;
} else if ( center_window ) {
- [ qz_window center ];
+ [ qz_window setFrameTopLeftPoint:NSMakePoint((float) 0, (float) [[qz_window screen] frame].size.height)];
}
@tarmolehtpuu
tarmolehtpuu / pvsz.c
Created March 22, 2011 23:43
Plants Vs Zombies: Add 655k gold
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#define PVSZ_HOME "Library/Application Support/PopCap/PlantsVsZombiesMac/userdata"
char pvsz_home[999];
void add_moneyz(char *file)