Skip to content

Instantly share code, notes, and snippets.

View beatak's full-sized avatar
🍄
Mushroom

Takashi M beatak

🍄
Mushroom
  • San Francisco, CA
View GitHub Profile
@dnephin
dnephin / compose-hooks.sh
Last active October 21, 2022 20:44
Execute a hook in './hooks/<service>/<action>' when that event is received
#!/bin/bash
set -e
function handle_event() {
local entry="$1"
local action=$(echo $entry | jq -r '.action')
local service=$(echo $entry | jq -r '.service')
local hook="./hooks/$service/$action"
if [ -x "$hook" ]; then
"$hook" "$entry"
var wrap_spawn = function (arg_spawn, cb_on_close) {
var child = spawn.apply(null, arg_spawn);
var stdout = [];
var stderr = [];
child.stdout.on('data', function (data) {
stdout.push(data.toString());
});
child.stderr.on('data', function (data) {
stderr.push(data.toString());
});
#!/bin/sh
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
@whitingx
whitingx / meta-tags.md
Created October 5, 2012 16:41 — forked from kevinSuttle/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
@FGRibreau
FGRibreau / table.filter.lua
Created September 26, 2012 19:59
Lua table.filter (JavaScript Array::filter equivalent)
-- table.filter({"a", "b", "c", "d"}, function(o, k, i) return o >= "c" end) --> {"c","d"}
--
-- @FGRibreau - Francois-Guillaume Ribreau
-- @Redsmin - A full-feature client for Redis http://redsmin.com
table.filter = function(t, filterIter)
local out = {}
for k, v in pairs(t) do
if filterIter(v, k, t) then out[k] = v end
end
@shikajiro
shikajiro / gist:3041123
Created July 3, 2012 17:15
Google SpreadsheetをJSONを返すダミーサーバーとして利用する方法
###
GoogleShpreadsheetのシートに記述されたデータをDBのテーブルに見立て取得し、
JSONに変換するスクリプト。
このソースはTitanium Mobileを想定しているが、コンバートの処理は流用できる。
テストに使用しているShpreadsheetは以下
https://docs.google.com/spreadsheet/ccc?key=0AuCUD7G5hGZrdGlBbHBDVElfUXdsbWRkRThVcmdCalE
条件:1行目をカラム名にすること
LEFT JOINなどの処理は別途本気出して実装する必要あり。
@eka
eka / logger.py
Created February 16, 2012 18:50
phenny module - log channels conversations using a TimedRotatingFileHandler
#!/usr/bin/env python
"""
logger.py - Esteban Feldman
based on logger.py - Phenny Room Logging Module
Author: Peter Higgins (dante@dojotoolkit.org)
About: http://higginsforpresident.net
License: AFL | New BSD
"""
from datetime import datetime
import logging
@Striker21
Striker21 / gist:1352993
Created November 9, 2011 20:57 — forked from padolsey/gist:500145
quickEach
// $.quickEach() replicates the functionality of $.each() but allows 'this'
// to be used as a jQuery object without the need to wrap it using '$(this)'.
// The performance boost comes from internally recycling a single jQuery
// object instead of wrapping each iteration in a brand new one.
// Development -----------------------------------
(function($)
{
$.fn.quickEach = function(f)
{
@beatak
beatak / gist:1157884
Created August 19, 2011 20:12
Force break line with using &shy;
var shyizeElements = function ($elms, limit) {
$elms.each(
function (n, elm) {
var $elm = $(elm),
str = shyize($elm.text(), limit);
str = str.replace('<', '&lt;', 'g').replace('>', '&gt;', 'g');
$elm.html(str);
}
);
};
@polotek
polotek / pipeaccept.js
Created May 18, 2011 01:16 — forked from heapwolf/pipeaccept.js
accepting input from a pipe, nodejs
var data;
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
data += chunk;
});
process.stdin.on('end', function() {