Skip to content

Instantly share code, notes, and snippets.

View MatthewCallis's full-sized avatar
🍖
Hungry Goriya

Matthew Callis MatthewCallis

🍖
Hungry Goriya
View GitHub Profile
@oupo
oupo / myutil.lua
Created June 15, 2010 10:50
myutil.lua
function reg(i) return memory.getregister("r"..i) end
read8 = memory.readbyte
read32 = memory.readdword
read16 = memory.readword
function read16_noalign(addr)
return bit.bor(read8(addr), bit.lshift(read8(addr+1), 8))
end
function read32_noalign(addr)
return bit.bor(read16_noalign(addr), bit.lshift(read16_noalign(addr+2), 16))
end
// The `quickEach` method will pass a non-unique jQuery instance
// to the callback meaning that there will be no need to instantiate
// a fresh jQuery instance on each iteration. Most of the slow-down
// inherent in jQuery's native iterator method (`each`) is the constant
// need to have access to jQuery's methods, and so most developers
// see constructing multiple instances as no issue... E.g.
// $(...).each(function(){ $(this)... $(this)... $(this)... });
// A better approach would be `quickEach`.
jQuery.fn.quickEach = (function(){
@nebiros
nebiros / Mysql.php
Created October 3, 2010 04:10
Mysql ala OOP, wrapper for some mysql_* functions
<?php
/**
* Mysql wrapper, to handle some mysql_* functions in a OOP way.
*
*/
class App_Db_Mysql {
const DEFAULT_ROW_COUNT = 10;
const DEFAULT_PAGE = 1;
@gifnksm
gifnksm / nicovideo_getFlv.js
Created November 10, 2010 03:42
ニコニコ動画でgetFlvを呼び出す関数
(function() {
if (!('nicovideo_getFlv' in window)) {
const Getter = function(videoID) {
this._videoID = videoID;
this._callbacks = [];
};
Getter.prototype = {
_videoID: null,
_lock: false,
@dira
dira / omniauth.rb
Created December 1, 2010 01:56
OmniAuth strategy for a custom provider
# config/initializers/omniauth.rb
module OmniAuth
module Strategies
# tell OmniAuth to load our strategy
autoload :Pixelation, 'lib/pixelation_strategy'
end
end
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, "app_name", "secret"
@Kilian
Kilian / annoying.js
Created January 6, 2011 15:04
How to be an asshole
/**
* Annoying.js - How to be an asshole to your users
*
* DO NOT EVER, EVER USE THIS.
*
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com)
* Visit https://gist.github.com/767982 for more information and changelogs.
* Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog
* Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors
*
@tobynet
tobynet / supermario_progress_bar_formatter.rb
Created January 25, 2011 18:59
SuperMarioSoundFormatter,it's one of supporting tools for EDD(Enjoyment Driven Development)
# -*- encoding: utf-8 -*-
# $ cat spec/spec.opts
# --require ~/lib/supermario_progress_bar_formatter.rb
# --format Spec::Runner::Formatter::SuperMarioProgressBarFormatter
require 'spec/runner/formatter/base_text_formatter'
require 'spec/runner/formatter/no_op_method_missing'
module Spec::Runner::Formatter
Javascript Obfuscation, Minification and why it doesn't really matter.
I'm working on placing some geocaches[http://www.geocaching.com] and they must be 0.1 miles away from other geocaches. Being a programmer I thought, well, let's just write a bookmarklet to augment the geocaching website with a radius around the caches displayed on the map. So I googled for chunk of code that would do this because I'm lazy. The first tool was http://www.freemaptools.com/radius-around-point.htm and its UI was clunky but the output looked good enough to me. So I dig into the source... and *gasp* what is this?
10111010001000010111010000111101010101101101110100010101010100100001...
http://www.freemaptools.com/script/radius-around-point.js
At that point, I could've just looked for the next site but I have a few tricks up my sleeve since I've had to dig into ridiculous javascript for serveral of my jobs... The first trick is just use chrome developer tools, it'll probably get you 90% of the way there... and look, it does!
@revolunet
revolunet / lzw_encoder.js
Created February 25, 2011 14:55
LZW javascript compress/decompress
// LZW-compress a string
function lzw_encode(s) {
var dict = {};
var data = (s + "").split("");
var out = [];
var currChar;
var phrase = data[0];
var code = 256;
for (var i=1; i<data.length; i++) {
currChar=data[i];
@gotascii
gotascii / simple_deployer.rb
Created March 22, 2011 14:46
cc.rb auto-deployer
# This plugin will deploy your app using capistrano.
# If the build fails the app won't de be deployed and if it passes it will try to deploy to a list of stages you can supply.
#
# Configuration
# In your project's cruise_config.rb file:
#
# Pass an array of stages you want to deploy to
# project.cap_deployer.stages = ['integration', 'staging']
#
# source ~/.rvm/scripts/rvm before deployment?