Skip to content

Instantly share code, notes, and snippets.

@aphlysia
aphlysia / pyone
Last active October 9, 2015 23:28
pyone: python one liner
#!/usr/bin/env python
help = '''
python one liner
Usage: pyone [OPTIONS] code [OPTIONS] [--] [file1, file2, ...]
-e code
-E code
-l
-Mmodule[,module,...]
-n
@aphlysia
aphlysia / .screenrc
Last active September 24, 2016 07:44
.screenrc
escape ^Tt
term xterm
termcap xterm hs@
terminfo xterm hs@
defscrollback 100000
startup_message off
vbell off
bind h focus left
bind j focus down
bind k focus up
@aphlysia
aphlysia / gist:4345785
Created December 20, 2012 15:03
Count items in a iterable.
reduce(lambda x, y: x + y, map(lambda x: Counter(**{x: 1}), 'aba'))
import os.path
class Path:
def __init__(self, path = os.path.curdir):
assert isinstance(path, str) or isinstance(path, self.__class__)
if isinstance(path, str):
self.path = path
else:
self.path = path.path
@aphlysia
aphlysia / 0_reuse_code.js
Created September 26, 2013 10:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@aphlysia
aphlysia / python_libraries.md
Last active December 26, 2015 09:29
python libraries
@aphlysia
aphlysia / hive_memo.md
Last active December 26, 2015 23:09
hive note

hive の正規表現

'abc' rlike 'b'

true になる。これは java.util.regex.Matcher.find() を使っているから (rlike の実体は UDFRegExp。詳しくは FunctionRegistry.javaUDFRegExp.java を参照)。もし matches() だと全体が一致しないとマッチしない。

http://docs.oracle.com/javase/jp/7/api/java/util/regex/Matcher.html

@aphlysia
aphlysia / matplotlib_recipes.md
Created October 31, 2013 02:26
matplotlib recipes

histogram

import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
ax.hist(np.random.randn(10000), 20, label = 'series 1', alpha=0.3, color='r')
ax.hist(np.random.randn(10000), 20, label = 'series 2', alpha=0.3, color='b')
legend = ax.legend(loc = 'upper left')
plt.savefig('a.png')
@aphlysia
aphlysia / minitest_recipes.md
Last active December 27, 2015 13:39
minitest recipes

e.g. hoge.rb にある関数 abs() と、クラス A のメソッド f() をテストしたいとき。

hoge.rb

# coding: utf-8

def abs(x)
  return -x if x < 0
@aphlysia
aphlysia / techs.md
Last active July 6, 2016 03:05
technologies