Skip to content

Instantly share code, notes, and snippets.

@pix0r
pix0r / UnityView.mm
Last active December 21, 2015 18:48
UnityView.mm that uses rotation notification
#include "UnityView.h"
#include "iPhone_View.h"
#include "iPhone_OrientationSupport.h"
#include "Unity/UnityInterface.h"
#include "Unity/GlesHelper.h"
#include "Unity/DisplayManager.h"
extern void UnitySendTouchesBegin(NSSet* touches, UIEvent* event);
extern void UnitySendTouchesEnded(NSSet* touches, UIEvent* event);
@pix0r
pix0r / cj.sh
Created August 21, 2013 20:38
in-place cleanjson
#!/bin/sh
if [ "$1" = "" ]; then
echo "Usage: $0 <file.json> [file2.json...]"
exit -1
fi
CLEANJSON=`which cleanjson`
if [ "$CLEANJSON" = "" ]; then
echo "Please install cleanjson and ensure it's on your PATH"
@pix0r
pix0r / scrape-sitemap.sh
Last active December 24, 2022 00:21
Use wget to scrape all URLs from a sitemap.xml Usage: scrape-sitemap.sh http://domain.com/sitemap.xml
#!/bin/sh
SITEMAP=$1
if [ "$SITEMAP" = "" ]; then
echo "Usage: $0 http://domain.com/sitemap.xml"
exit 1
fi
XML=`wget -O - --quiet $SITEMAP`
@pix0r
pix0r / heroku_postgis_broken.sh
Created March 8, 2013 05:56
Heroku PostGIS databases don't seem to be working
#!/bin/sh
set -e
APP=$1
APP_ARG=""
if [ "$APP" != "" ]; then
APP_ARG=" -a $APP"
fi
@pix0r
pix0r / demo.html
Created July 15, 2012 03:01
Open largest image on current page using jQuery $('img')
<a href="javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g&gt;f.fn.jquery||h(f)){c=a.createElement(&quot;script&quot;);c.type=&quot;text/javascript&quot;;c.src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/&quot;+g+&quot;/jquery.min.js&quot;;c.onload=c.onreadystatechange=function(){if(!b&amp;&amp;(!(d=this.readyState)||d==&quot;loaded&quot;||d==&quot;complete&quot;)){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,&quot;1.3.2&quot;,function($,L){var max_area = 0, src = &quot;&quot;; $('img').each(function(idx, img) { var a = $(img).height() * $(img).width(); if (a &gt; max_area) { src = img.src; max_area = a; } } ); if (src) document.location = src;});">Show Largest Image</a> (click link or drag to your bookmarks bar)
@pix0r
pix0r / update_baseurl.php
Created April 23, 2012 00:28
Script to update Magento base URL
<?php
$opt_arr = array(
'u' => 'user',
'p' => 'pass',
'h' => 'host',
'd' => 'dbname',
't' => 'table_prefix',
'b' => 'base_url',
's' => 'secure_url',
@pix0r
pix0r / pre-commit
Created March 29, 2012 15:36 — forked from spulec/pre-commit
Yipit Pre-commit Hook
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
CHECKS = [
@pix0r
pix0r / fabfile.py
Created March 8, 2012 18:49
Sample Fabric environment setup
from fabric.api import env, run
from fabric.contrib.project import rsync_project
try:
from fabfile_local import *
except ImportError, e:
environments = {
"dev": {
"hosts": ["localhost"],
},
@pix0r
pix0r / Delete Playlists.scpt
Created February 19, 2012 20:47
Delete *.m3u and *.pls under current Finder directory
-- Path of script:
-- tell application "Finder" to get POSIX path of ((container of (path to me)) as text)
-- Foreground Finder window:
tell application "Finder" to get POSIX path of ((the target of the front window) as text)
set currDir to quoted form of result
set cmdBase to "find " & currDir & " \\( -name \\*.m3u -or -name \\*.pls \\)"
set cmdList to cmdBase & " -exec basename {} \\;"
set cmdCount to cmdBase & " | wc -l"
@pix0r
pix0r / localized_nibs_config.py
Created August 24, 2011 18:13
Automates the process of updating localized NIB files
#!/usr/bin/env python
locales = ["en", "fr", "it", "de", "es"]
dev_locale = "en"
base_dir = "ProjectSourceDirectory"
nibs = [
"MainWindow.xib",
"Error/ErrorViewController.xib",
"Home/HomeViewController.xib",
"Home/SettingsViewController.xib",