Skip to content

Instantly share code, notes, and snippets.

View joenoon's full-sized avatar

Joe Noon joenoon

  • SF Bay Area - San Ramon
View GitHub Profile
#!/bin/bash
# Install VirtualBox Guest Additions
# (change ARCH and VERSION as needed)
# run it as root or with sudo
ARCH="x86"
VERSION="3.2.6"
FILE="VBoxGuestAdditions_${VERSION}.iso"
URL="http://download.virtualbox.org/virtualbox/${VERSION}/${FILE}"
cd /tmp
wget "$URL"
#!/usr/bin/env bash
set -e
ME=$0
SSH_USER=$1
HOST=$2
SSH_TO="$SSH_USER@$HOST"
PASSWORD="${PASSWORD:-chefchefchef}"
USE_SUDO="${USE_SUDO:-yes}"
@joenoon
joenoon / gist:1013595
Created June 8, 2011 01:21
quick hack to use vagrant's familiar chef-solo integration to provision a remote server instead of a vm
require 'rubygems'
require 'vagrant'
module Vagrant
class SSH
def rsync(opts={})
if Mario::Platform.windows?
raise Errors::SSHUnavailableWindows, :key_path => env.config.ssh.private_key_path,
:ssh_port => port(opts)
end
@joenoon
joenoon / sass_asset_data_url_helper.rb
Created September 11, 2011 08:52
asset-data-url sass helper
# `asset-data-url` sass helper
# quick fix for: https://github.com/rails/sass-rails/pull/46
unless Sass::Script::Functions.method_defined?(:asset_data_url)
module Sass
module Extra
module Helpers
def asset_data_url(path)
data = context_asset_data_uri(path.value)
Sass::Script::String.new(%Q{url(#{data})})
@joenoon
joenoon / gist:1247348
Created September 28, 2011 08:24
avoid deepening the javascript stack
// the biggest problem i've faced in "big" js apps (one-page RIAs, mobile and web)
// is the javascript stack. avoid diving deep as much as possible. basically
// a function that calls a function that calls a function within a loop is a
// really really bad idea. especially on mobile devices that typically don't have
// a stack limit as big as a normal browser.
var books = [
{ name: "A", chapters: [ { name: "X" }, { name: "Y" }, { name: "Z" } ] },
{ name: "B", chapters: [ { name: "X" }, { name: "Y" }, { name: "Z" } ] },
{ name: "C", chapters: [ { name: "X" }, { name: "Y" }, { name: "Z" } ] },
@joenoon
joenoon / gist:4156512
Last active October 14, 2020 20:21
RubyMotion - read entitlements from the provisioning_profile
# read entitlements from the provisioning_profile
# you can the set it like this:
# app.entitlements = app.read_provisioning_profile_entitlements
module Motion
module Project
class Config
def read_provisioning_profile_entitlements
text = File.read(provisioning_profile)
text.force_encoding('binary') if RUBY_VERSION >= '1.9.0'
text = text.scan(/<key>\s*Entitlements\s*<\/key>\s*<dict>(.*?)\s*<\/dict>/m)[0][0]
Original http://pkgs.fedoraproject.org/cgit/htmldoc.git/plain/htmldoc-1.8.27-libpng15.patch?h=f18
From upstream 1.8 branch svn r1668
The previous libpng-1.5 conversion patch here caused corrupt PNG output
on 64 bit. e.g. http://answerpot.com/showthread.php?3662601-PNG+Rendering+Problems
The upstream version (below) works well.
Index: htmldoc/image.cxx
@joenoon
joenoon / gist:5846816
Created June 23, 2013 22:44
YapModel, coming soon
class YapModel
def self.database
Dispatch.once { @database = YapDatabase.alloc.initWithPath(App.documents_path + "/yap.db") }
@database
end
def self.dbconnection
Thread.current["yap_dbconnection"] ||= WeakRef.new(new_dbconnection)
end
@joenoon
joenoon / update_plex_added_at.sql
Last active November 7, 2017 12:08
PLEX MEDIA SERVER: Update the added_at timestamp for each series to the most recently added episode's timestamp for that series.DO NOT RUN THIS UNLESS YOU KNOW WHAT IT DOES, AND BACKUP FIRST. IT WILL ALTER YOUR PLEX DATABASE. IT IS MOSTLY UNTESTED.
BEGIN;
DROP TABLE IF EXISTS tmp_series_episodes;
-- a temp table containing each episode with its cooresponding series
CREATE TEMP TABLE tmp_series_episodes AS
SELECT series.id series_id,
series.title series_name,
series.added_at series_added_at,
episode.id episode_id,
@joenoon
joenoon / gist:7950988
Created December 13, 2013 20:41
drop-in to see allocations and deallocations.
# [ UIViewController, UIView, etc. ]...
[ UIViewController ].each do |klass|
klass.class_eval do
def self.allocWithZone(zone)
super.tap do |x|
p " + alloc! #{x.inspect}"
end
end
alias_method 'old_dealloc', 'dealloc'