Skip to content

Instantly share code, notes, and snippets.

View fkei's full-sized avatar
😀

fkei fkei

😀
View GitHub Profile
@fkei
fkei / gist:6362774
Created August 28, 2013 06:37
リクエストを別のHTTPサーバーに問い合わせるプログラム
/**
* web server: express
*
* リクエストを別のHTTPサーバーに問い合わせるプログラム
* - リクエストヘッダー等はコピーしていないです。
*/
var fs = require('fs');
var path = require('path');
var zlib = require('zlib');
@fkei
fkei / gist:6362679
Created August 28, 2013 06:19
MDN: bindを切り出したソース
// -----------------------------------------------------------------
// MDN: bind
// @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
// -----------------------------------------------------------------
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
@fkei
fkei / gist:6361924
Created August 28, 2013 03:43
blog.fkei.me : Canvas.toDataURL() -> img.src -> CORS(´・ω・`)ショボーン
var b64 = canvas.toDataURL()
var $img = new Image();
$img.crossOrigin = 'Anonymous';
$img.src = b64;
// もとに戻すとき null を入れるといいよ。
$img.crossOrigin = null;
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head>
<style>
body {
margin : 0;
padding : 0;
background-color: #eee;
font-size: 25px;
>>> a, b = 1, 2
>>> print a, b
1 2
>>> b, a = a, b
>>> print a, b
2 1
>>> list1, list2 = [1,2,3,4,5], [6,7,8,9,10]
>>> for (e1, e2) in zip(list1, list2): print e1, e2
...
1 6
2 7
3 8
4 9
5 10
@fkei
fkei / if in
Created March 6, 2013 14:23
Not has_key
>>> items = [1,2,3,4,5]
>>> if 3 in items: print "hit!!"
...
hit!!
@fkei
fkei / DefaultKeyBinding.dict
Created September 14, 2012 04:04
xcode keybindings for emacs emulation
{
/* Keybindings for emacs emulation. Compiled by Jacob Rus.
*
* To use: copy this file to ~/Library/KeyBindings/
* after that any Cocoa applications you launch will inherit these bindings
*
* This is a pretty good set, especially considering that many emacs bindings
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and
* perhaps a few more, are already built into the system.
*
@fkei
fkei / backup.py
Created August 23, 2012 06:27 — forked from rore/backup.py
A script to automate freezing XFS and locking MongoDB and snapshotting EBS volumes
#!/usr/bin/env python
from __future__ import with_statement
import contextlib
import logging
import os
import sys
import urllib2
from boto.ec2.connection import EC2Connection
@fkei
fkei / eventlet_gs_uploader.py
Created July 27, 2012 15:34 — forked from batok/eventlet_gs_uploader.py
A python script to do asynchronous upload to google storage using boto and eventlet libraries
# this program uploads to google storage using boto and eventlet all the jpg files of a selected folder
import eventlet
bcon = eventlet.import_patched("boto.gs.connection")
import glob
FOLDER = "/Users/myself/Documents/" # replace this with your chosen folder
BUCKET_NAME = "whateveryourbucketname" # replace this with your bucket name
def upload(myfile):
c = bcon.GSConnection()