Skip to content

Instantly share code, notes, and snippets.

View takahi-i's full-sized avatar

Takahiko Ito takahi-i

View GitHub Profile
@darktable
darktable / MiniJSON.cs
Created November 30, 2011 23:08
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2013 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining
@Gen2ly
Gen2ly / md2wp
Created July 9, 2012 23:34
Convert Markdown to Wordpress blogging format
#!/bin/bash
# Convert Markdown to Wordpress blogging format
# Required program(s)
req_progs=(ascii2uni pandoc)
for p in ${req_progs[@]}; do
hash "$p" 2>&- || \
{ echo >&2 " Required program \"$p\" not installed."; exit 1; }
done
@tk0miya
tk0miya / conf.py
Created December 19, 2012 14:11
sphinxcontrib_markdown
sys.path += ["."]
extensions += ["markdown"]
markdown_title = 'hello world'
source_suffix = '.md'
@dfkaye
dfkaye / mocking-private-functions.md
Last active March 13, 2019 15:40
mocking - not testing - private functions in JavaScript, using new Function() - followup to https://gist.github.com/dfkaye/5971486

Mocking - not testing - private functions in JavaScript

Instead of trying to extract a private function, we can rely on mocking/spying. This gist shows how to use the "new Function()" constructor to replace an internal call so that we can mock, spy or stub.

Another response to @philwalton - 
http://philipwalton.com/articles/how-to-unit-test-private-functions-in-javascript/

This is a followup to https://gist.github.com/dfkaye/5971486 - a suggestion for 
*annotating* functions to be extracted and tested separately (publicly).
@clintongormley
clintongormley / load_test_data.sh
Last active January 5, 2024 07:32
Run these commands in your shell to setup the test data for Chapter 5
curl -XPUT 'http://localhost:9200/us/user/1?pretty=1' -d '
{
"email" : "john@smith.com",
"name" : "John Smith",
"username" : "@john"
}
'
curl -XPUT 'http://localhost:9200/gb/user/2?pretty=1' -d '
{
@floer32
floer32 / python_bind_function_as_method.py
Created February 11, 2015 01:42
Bind Python function as method
# based on: http://stackoverflow.com/questions/1015307/python-bind-an-unbound-method#comment8431145_1015405
def bind(instance, func, as_name):
""" Turn a function to a bound method on an instance
.. doctest::
>>> class Foo(object):
... def __init__(self, x, y):
... self.x = x
... self.y = y
@yamarten
yamarten / Atom.asc
Last active August 29, 2015 14:17
Atom のススメ

Atom のススメ

エディタの方。個人的結論としては「かなり良いけど乗り換えるならもう少し(1.0くらいまで)待ってからでもいいんじゃないか」という感じになると思う。

公式ドキュメントが整備された記念にgistの試し書きも兼ねて書きなぐり。ちなみにこれ自体もAtom で Gist It とか Asciidoc Preview とか使って書いてる。
比較対象は Sublime TextBrackets は特化型っぽいし Light Table はまだ実用的に感じない(Eve 含め少し気になってはいる)。宗教系はもう必要時以外は触れたくない。

気に入ってるところ

  • 拡張性

@karronoli
karronoli / redpan_ja.bat
Last active December 6, 2015 09:56
RedPen interface for proofreading paragraph.
@echo off
chcp 65001 >NUL
set JAVA_OPTS=-XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Dfile.encoding=UTF-8
cmd /c %USERPROFILE%\Downloads\redpen-cli-1.2\bin\redpen.bat ^
-c %USERPROFILE%\Downloads\redpen-cli-1.2\conf\redpen-conf-ja.xml %* 2>&1 ^
| findstr /V /R "^$" | findstr /V /C:"[INFO ]"
if ERRORLEVEL 1 (
exit /b 0
) else (
exit /b 1
@so-c
so-c / redpen-conf-mirror-house.xml
Last active July 22, 2016 14:16
RedPenのブログ下書き用設定ファイル。
<redpen-conf lang="ja">
<validators>
<!--Rules on sentence length-->
<validator name="SentenceLength">
<property name="max_len" value="100"/>
</validator>
<validator name="CommaNumber" />
<!--Rules on expressions-->
<validator name="ParagraphNumber"/>