Skip to content

Instantly share code, notes, and snippets.

View sukima's full-sized avatar

Devin Weaver sukima

View GitHub Profile
@sukima
sukima / ImageLoadingOp.h
Created November 4, 2009 20:05 — forked from quique123/ImageLoadingOp.h
Thread programming review
//
// ImageLoadingOp.h
// PersonList
//
// Created by Marcio Valenzuela on 10/20/09.
// Copyright 2009 Personal. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@sukima
sukima / gist:603026
Created September 29, 2010 16:09 — forked from safarista/gist:602992
class Job < ActiveRecord::Base
belongs_to :catergory
# UPLOAD a file for the logo
def upload
uploaded_io = params[:job][:logo]
File.open(Rails.root.join('public', 'images', uploaded_io.original_filename), 'w') do |file|
file.write(uploaded_io.read)
end
end
(function($){
$.fn.extend({
formatInput: function(custom_settings) {
this.data("settings", $.extend({
regex:".*",
format_number: true,
max_length: false,
errback: null
}, custom_settings);
return this.each(function() {
$.each(arrayFromPHP, function (i, elem) {
console.log(elem.User);
console.log(elem.EmailAddress);
$("<option/>").clone()
.val(elem.Emailaddresses)
.text(elem.User)
.appendTo("#emailaddresses");
});
@sukima
sukima / coffeescript_converter.rb
Created June 13, 2012 17:13 — forked from phaer/coffeescript_converter.rb
A trivial CoffeeScript.org -> Javascript plugin for OLDER OctoPress. Put this file in 'plugins/' and write a YAML header to your .coffee files (i.e. "---\nlayout:nil\n---\n")
module Jekyll
require 'coffee-script'
class CoffeeScriptConverter < Converter
safe true
priority :normal
def matches(ext)
ext =~ /coffee/i
end
@sukima
sukima / gist:3933058
Created October 22, 2012 18:07 — forked from heath/gist:3932795
An attempt to avoid a long list of if statements
//all of this is within a pretty long method for handling key events
var groupChoices = {
65 : 'a', 66 : 'b', 67 : 'c',
68 : 'd', 69 : 'e', 70 : 'f',
71 : 'g', 72 : 'h', 73 : 'i',
74 : 'j', 75 : 'k', 96 : '0',
97 : '1', 98 : '2', 99 : '3',
100 : '4', 101 : '5', 102 : '6',
103 : '7', 104 : '8', 105 : '9'
// * document is the JavaScript document object
// * bind adds an event listener to the document object
// * pageinit is the event that document object should listen for
// * the anonymous function is the callback that getsw executed when the
// document recieves the pageinit event.
$(document).bind("pageinit", function(){
// Now the pageinit event was triggered
// again lets attach an event listener to the document element #listitem2
// This time the event to listen for is the swipeleft event
// The convinience function swipeleft is the same a s bind("swipeleft",...)
@sukima
sukima / Router.js
Last active December 10, 2015 05:38 — forked from yorickvP/gist:2725801
A simple router class in JavaScript using callbacks (not events)
/**
* # Simple Router
* A JavaScript router class.
*
* #### Examples
* var appRouter, func,
* Router = require("Router");
*
* appRouter = new Router();
* appRouter.get("/", indexMethod);
@sukima
sukima / README.md
Last active December 12, 2015 00:28 — forked from neoGeneva/gist:1309070

Super Simple Event Dispatcher

Use this to add events to your objects without needing any libaries.

Simple function can be imported or copy pasted. In your object constructor assign your event functions to the return value of the createCustomEvent().

Simple example:

class ReadlineLoop
constructor: ->
@rl = readline.createInterface
input: process.stdin
output: process.stdout
@rl.on("line" , @onLine)
.on("close", @onClose)
onLine: => # ...
onClose: => # ...