Skip to content

Instantly share code, notes, and snippets.

View funkatron's full-sized avatar

Ed Finkler funkatron

View GitHub Profile
@funkatron
funkatron / jslint
Created April 10, 2011 22:40
a build definition for Sublime Text 2 that will pass the file through the node-jslint addon. I had to modify the output of the jslint script to include the filename.
#!/usr/bin/env node
// jslint wrapper for nodejs
// Adapted from rhino.js. Copyright 2002 Douglas Crockford
// Shebang removal regex uses insecure "."
// JSLINT is provided by fulljslint.js modified to export the global
/*global JSLINT */
(function (file) {
var e, i, input, len, success, pad,
path = __filename.split("/").slice(0, -2).join("/"),
@funkatron
funkatron / awesome.coffee
Created April 15, 2011 13:52
awesome coffeescript
foo = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus nisl dolor, pulvinar id, pharetra a, egestas nec, ante. Duis scelerisque eleifend metus. Sed non odio id odio varius rutrum. Pellentesque congue commodo lacus. In semper pede lacinia felis. Morbi mollis molestie lorem. Morbi suscipit libero. Quisque ut erat sit amet elit aliquam nonummy. Donec tortor. Aliquam gravida ullamcorper pede. Praesent eros. Sed fringilla ligula sed odio pharetra imperdiet. Integer aliquet quam vitae nibh. Nam pretium, neque non congue vulputate, odio odio vehicula augue, sit amet gravida pede massa ac lectus. Curabitur a libero vitae dui sagittis aliquet. Ut suscipit. Curabitur accumsan sem a urna. Ut elit pede, vulputate sed, feugiat quis, congue sed, lacus.'
console.log foo
@funkatron
funkatron / http_digest_example.php
Created April 30, 2011 20:08
An example of how to manually construct an HTTP Digest authentication header.
<?php
$url = 'http://domain.foo';
$uri = '/assets';
$username = 'testyser';
$password = 'somepassword';
$method = 'GET';
$ht = new HttpRequest($url.$uri, HttpRequest::METH_GET);
$ht->send();
@funkatron
funkatron / vbox3to4.md
Created May 5, 2011 01:58
Moving a webOS VM from one OS X box to another

On my LAN, I have:

  • Machine A: An OS X machine running VirtualBox 3.2
  • Machine B: An OS X machine running VirtualBox 4

Here's what I did:

  1. first, create the image on machine A by running the Palm Emulator application.
  2. open VirtualBox 3.2 on machine A to make sure it set up correctly. Run it and watch it boot. If it works fine, shut it down.
  3. On Machine B, close all VBox VMs that are currently running, and close the VirtualBox application if it is running.
@funkatron
funkatron / twitter_sources_collector.php
Created May 10, 2011 00:41
a PHP script to capture twitter source data from the streaming API into MySQL
#!/dh/cgi-system/php5.cgi -q
<?php
$TWITTER_USERNAME = 'foo';
$TWITTER_PASSWORD = 'bar';
$PDO_CONN_URL = 'mysql:host=hostname;dbname=db_name', 'username', 'password';
set_time_limit(0);
function getLinkFromHref($str) {
return htmlspecialchars(preg_replace('/(<a href=")([^"]+)"(.*)/i', '$2', $str), ENT_QUOTES, 'UTF-8');
@funkatron
funkatron / twitter-oauth-pin.html
Created May 19, 2011 01:06
A simple example of PIN-based oauth flow with Twitter and jsOAuth
<!DOCTYPE html>
<html>
<head>
<!--
A simple example of PIN-based oauth flow with Twitter and jsOAuth.
This is mostly based on/copied from <http://log.coffeesounds.com/oauth-and-pin-based-authorization-in-javascri>.
Get jsOAuth at <https://github.com/bytespider/jsOAuth/downloads>
@funkatron
funkatron / app.xml
Created May 19, 2011 14:24
This is a proof of concept to demonstrate listening for a callback request from Twitter's oAuth system with a local socket server in AIR
<?xml version="1.0" encoding="utf-8" ?>
<application xmlns="http://ns.adobe.com/air/application/2.0">
<id>com.funkatron.jsOAuthListenerTest</id>
<filename>jsOAuthListenerTest</filename>
<name>jsOAuth AIR Listener Test</name>
<version>0.1</version>
<initialWindow>
<content>index_socket.html</content>
<visible>true</visible>
<width>700</width>
@funkatron
funkatron / localization_interpolate.js
Created May 29, 2011 19:23
Example of variable interpolation for localized strings in Enyo
enyo.macroize($L('Stopped following {$screen_name}'), {'screen_name':self.user.username})
@funkatron
funkatron / capture_batch.scpt
Created September 1, 2011 12:56
Paparazzi! batch from CLI
-- Usage:
-- $ osascript capture_batch.scpt URL URL URL ...
--
on run argv
-- set argv here so we can run this from the script editor with some data
-- comment it out if you're actually running on the CLI
set argv to {"http://funkatron.com", "http://google.com"}
tell application "Paparazzi!"
add argv to batch window 1
tell batch window 1 to start capturing
@funkatron
funkatron / strip_bad_chars.php
Created September 23, 2011 15:48
PHP function to remove *most* low ascii, keeping newlines, CRs, etc
/**
* sometimes you want to remove nefarious stuff like control chars and vertical tabs, but
* you still want to retain newlines and tabs.
* chars preserved are 0 (null), 9 (horiz tab), 10 (newline), 12 (new page), 13 (carriage return)
*/
function strip_bad_chars($input) {
$lower = array(
chr(1),
chr(2),
chr(3),