Skip to content

Instantly share code, notes, and snippets.

View hokaccha's full-sized avatar

Kazuhito Hokamura hokaccha

View GitHub Profile
@hokaccha
hokaccha / Rakefile
Created August 2, 2012 05:48 — forked from jeffreyiacono/Rakefile
rake task for precompiling assets using sprockets within a sinatra app + view helpers
require 'rubygems'
require 'bundler'
Bundler.require
require './application'
namespace :assets do
desc 'compile assets'
task :compile => [:compile_js, :compile_css] do
end
@hokaccha
hokaccha / core.js
Created July 25, 2012 14:58
define namespace
// namespace
window.MyApp = {};
// define namespace
MyApp.define = function(name, fn) {
var parent = MyApp;
var parts = name.split('.');
parts.forEach(function(part, i) {
var isLast = parts.length === i + 1;
// expressで/public以下だけbasic認証外したい場合
var basicAuth = express.basicAuth(user, password);
app.use(function(req, res, next) {
if (/^\/public\//.test(req.path)) {
next();
}
else {
basicAuth(req, res, next);
}
});
@hokaccha
hokaccha / caveatPatchor.js
Created April 12, 2012 02:18 — forked from protocool/caveatPatchor.js
Sample Propane caveatPatchor.js file
/**
Sample Propane caveatPatchor.js file based on tmm1's avatar hack.
You'll need at least version 1.1.1 to experiment with this:
http://propaneapp.com/appcast/Propane.1.1.1.zip
Once I'm sure exposing this hack-injection point doesn't cause problems
I'll do an official auto-updating version.
As of version 1.1.1, Propane will load and execute the contents of
var origSet = Backbone.Model.prototype.set;
Backbone.Model.prototype.set = function(key, value, options) {
var attrs, attr, val;
if (_.isObject(key) || key == null) {
attrs = key;
options = value;
} else {
attrs = {};
attrs[key] = value;
}
@hokaccha
hokaccha / Cakefile
Created February 28, 2012 12:47
Cakefile
#
# modules
#
fs = require 'fs'
{exec} = require 'child_process'
#
# options
#
@hokaccha
hokaccha / _nodebrew
Created February 23, 2012 23:32
zsh complete for nodebrew
#compdef nodebrew
_sub_commands install uninstall use list ls ls-remote ls-all clean selfupdate
@hokaccha
hokaccha / indent_toggle.vim
Created February 16, 2012 09:37
indent_toggle.vim
" タブの設定を切り替えのトグル
function! TabToggle()
fun! l:Set1()
setlocal softtabstop=2
setlocal shiftwidth=2
setlocal expandtab
endfun
fun! l:Set2()
setlocal softtabstop=4
setlocal shiftwidth=4
@hokaccha
hokaccha / watcher
Created January 18, 2012 09:26
File watch and exec command cli tool
#!/usr/bin/env node
/*
* File watch and exec command cli tool.
*
* Example
*
* $ watcher *.less -- lessc style.less style.css
*
*/