Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tanakahisateru's full-sized avatar

Hisateru Tanaka tanakahisateru

View GitHub Profile
@tanakahisateru
tanakahisateru / fizzbuzz.py
Created October 20, 2010 06:36
Fizz Buzz expression
map(lambda n:'fizzbuzz' if n%15==0 else 'fizz' if n%3==0 else 'buzz' if n%5==0 else str(n), range(1, 101))
javascript:(function() {
var count=0;
var id=setInterval(function() {
var evt=document.createEvent("MouseEvents");
evt.initMouseEvent("click",true,true,window,0,0,0,0,0,false,false,false,false,0,null);
document.getElementById("more").dispatchEvent(evt);
if(++count > 300) {
alert('end');
clearInterval(id);
}
@tanakahisateru
tanakahisateru / crlf2cr.py
Created March 7, 2011 08:58
Convert CRLF to LF in a folder recursively.
# Convert CRLF to LF in a folder recursively.
import sys, os
if len(sys.argv) < 2:
raise RuntimeError("No folder specified to convert.")
def iterfiles(basedir):
for (path, dirs, files) in os.walk(basedir):
for fn in files:
@tanakahisateru
tanakahisateru / おためし
Created April 15, 2011 17:58
twitterで見れるかためしてみられたので
<?php
/* ↓PHPのechoの変態な書き方 */
?>ねもい<?php
<?php ob_start(); ?>
echo 'ねもい';
<?php eval(ob_get_clean()); /* ここまでくるとさすがに無理しすぎ */
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAZCAYAAAAiwE4nAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABZ0RVh0Q3JlYXRpb24gVGltZQAwNC8yMC8xMf5OkcQAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzQGstOgAAAGqUlEQVRIiaWWa4yU1RnH/885721mZ3aW7bBcusvKShEaUVLAaKVKdYN1tZcUbRqjbWpsQtNYE0hoU6L9UlJjUpo2TWwx9VMT2xBjIlUjgmDptqxdLgEXRNd1l72xOzs793kv5z3n6YdZVmDRpPFJni/vufzy///POXmJmfFp5f/uDs/qaPo+Yv2wzvm3mVw0G5f0fm9N6vfOT3pzn7rwM4quB5z98YaEu8J7RrZZPdZS50auRcl4widzKUSY16pepcEwEi9k2ux92Rf6a/8P0LreR5mU94HwC+EJEAHa1+BQg0MDrWDHAa8NC3rvyAS3Z4GdnxsoXPGA8ATIk2BtwKEGQgMTMbQGdAyYCLgwFJx8+eUtO6qT3JVuE7/c870j5evtt3fkbmf0aPIr03/hUwuAZ2gxde1e1U0egVyaV8YhQysgjgGjgDBGeFTGfdkivxREtNGJ5bZfHdr6d8ehd2ymSc+SDkN01Q3fWaXU1qjMpamPa5sWADu2d64jm26ghARJwAQxOGpATQxo1VBXDfjE9B+XID2FW4UtIGyxlCzxlJDiKZsEbCkRGcCwgQqA4mCw7/DYsaS4Tn73kysgPAEwz9vJETfUzSnMz8YHVqXcjYGCbXsE6QFCAhKAFAQQEDMjFoAqMvLnav8FEC4ACod6yBMgj8DKgAMNDgyMYug5hVEMXJhVb7uz/E1lCLZLkA5B0CfNDMQMxMQIZ0x56Hj+NAD/KmDukfVfIFvcJlMCVkJAKEBoCRkDRjHiOTvrEY8efbzpUlxBN1kNmHQASQSBRmsGNDPiCPAn4t
@tanakahisateru
tanakahisateru / RequestContinuation.php
Created May 12, 2011 10:10
Request continuation for confirmation page
<?php
/**
* Request continuation
*
* This utility provides a very short lifetime (and navigation closed) session.
* Confirmation page shown after user input form should hold previously poted
* data and passes them to the next request. Those data would live in only two
* requests, so they should be in request scope.
* It's bad idea to use cookie or _SESSION to implement for confirmation page!
*
@tanakahisateru
tanakahisateru / gist:993071
Created May 26, 2011 12:51
Simple text templating
<?php
/**
* Simple text templating
*
* before: "hello,{{name}}"
* given: array('name'=>'world')
* after: "hello,world"
*/
function fill_text_template($template, $vars) {
$target = array();
@tanakahisateru
tanakahisateru / pinocoise.sh
Created June 1, 2011 13:20
Pinoco project initializer
#!/bin/sh
PINOCO_VER="0.5.2"
PINOCO_URL_BASE="https://github.com/downloads/tanakahisateru/pinoco"
PHPTAL_VER="1.2.2"
PHPTAL_URL_BASE="http://phptal.org/files"
if [ ! -d _download ]; then
mkdir _download
curl -o _download/empty-project.tgz -L ${PINOCO_URL_BASE}/empty-project.tgz
@tanakahisateru
tanakahisateru / gist:1010418
Created June 6, 2011 15:03
PHPTALのnamespace拡張とりあえずTALES無視
<?php
require_once 'PHPTAL.php';
// namespace def
class MYNS_Namespace extends PHPTAL_Namespace
{
public function __construct()
{
// namespace
parent::__construct('myns', 'http://xml.zope.org/namespaces/mytal');