Skip to content

Instantly share code, notes, and snippets.

@aphlysia
aphlysia / pyone
Last active Oct 9, 2015
pyone: python one liner
View pyone
#!/usr/bin/env python
help = '''
python one liner
Usage: pyone [OPTIONS] code [OPTIONS] [--] [file1, file2, ...]
-e code
-E code
-l
-Mmodule[,module,...]
-n
View .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 Dec 20, 2012
Count items in a iterable.
View gist:4345785
reduce(lambda x, y: x + y, map(lambda x: Counter(**{x: 1}), 'aba'))
View Path.py
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 Sep 26, 2013
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View python_libraries.md
View hive_memo.md

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

View matplotlib_recipes.md

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')
View minitest_recipes.md

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 Jul 6, 2016
technologies
View techs.md