Skip to content

Instantly share code, notes, and snippets.

View 0xBADDCAFE's full-sized avatar

shun 0xBADDCAFE

View GitHub Profile
@0xBADDCAFE
0xBADDCAFE / #todo_286.py
Last active December 19, 2015 06:19
computer_science room #Lingr
'''
[_] 0286 s_of_p 6 hours ago chap2を読んで試して考えよ: dictのkeyにlistを用いると何が起こるのか? (by bgnori)
'''
Python 3.3.2 (default, Jul 2 2013, 19:41:05)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a_dict={'a':1, 'b':2, 'c':3}
>>> a_dict
{'a': 1, 'b': 2, 'c': 3}
@0xBADDCAFE
0xBADDCAFE / #todo_288.py
Last active December 19, 2015 06:29
in computer_science room(#Lingr).
def fizzbuzz_t(n):
'''
Return "fizzbuzz" value by tuple.
Examples:none.
'''
a_tuple = ()
for i in range(1, n+1):
if i % (3 * 5) == 0:
a_tuple += ('fizzbuzz',)
elif i % 3 == 0:
@0xBADDCAFE
0xBADDCAFE / #todo_293.py
Created July 2, 2013 18:32
in computer_science room(#Lingr).
def prob001():
'''
Return answer of project euler problem 001 value.
Examples:
>>> prob001()
233168
'''
ans = 0
n=1000
for i in range(1, n):
Downloading/unpacking distribute==0.6.28 (from -r freeze.txt (line 1))
Getting page https://pypi.python.org/simple/distribute/
URLs to search for versions for distribute==0.6.28 (from -r freeze.txt (line 1)):
* https://pypi.python.org/simple/distribute/0.6.28
* https://pypi.python.org/simple/distribute/
Getting page https://pypi.python.org/simple/distribute/0.6.28
Could not fetch URL https://pypi.python.org/simple/distribute/0.6.28: HTTP Error 404: Not Found (distribute/0.6.28)
Will skip URL https://pypi.python.org/simple/distribute/0.6.28 when looking for download links for distribute==0.6.28 (from -r freeze.txt (line 1))
Analyzing links from page https://pypi.python.org/simple/distribute/
@0xBADDCAFE
0xBADDCAFE / failed
Created July 4, 2013 16:52
cahp2.q0005
....F
======================================================================
FAIL: test_no_sideeffect (__main__.NumberingTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "./tests/chap2/q0005.py", line 30, in test_no_sideeffect
self.assertEqual(xs, ys)
AssertionError: Lists differ: [(0, 0), (1, 1), (2, 2), (3, 3... != [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
First differing element 0:
@0xBADDCAFE
0xBADDCAFE / openlinksintext.js
Last active December 21, 2015 00:59
書き捨て。リンクが大量に詰まったtxtファイルをブラウザで開き、一括で開くためのbookmarklet。 http://ted.mielczarek.org/code/mozilla/bookmarklet.html 辺りで変換して使える。 Fxでタブ固定前提で書いているので、chromeでやると新規窓がバンバン開いてウボァ
javascript:(function(){
URLtext=document.getElementsByTagName("pre").item(0).firstChild.nodeValue;
URLs=URLtext.split("\n");
len=URLs.length;
for(i=0;i<len;i++){
if(URLs[i].indexOf("http")==0){
if(i>0&&i%2510==0){
if(!confirm("Open next 10 URLs?\nstatus: "+i+"/"+len)){
return;
}
Messages maintainer: Bram Moolenaar <Bram@vim.org>
E15: Invalid expression: g:airline_left_sep
line 37:
E121: Undefined variable: g:airline_right_sep
E15: Invalid expression: a:active ? g:airline_right_sep : g:airline_right_alt_sep
line 41:
E121: Undefined variable: g:airline_right_sep
E15: Invalid expression: a:active ? g:airline_right_sep : g:airline_right_alt_sep
Error detected while processing function airline#update_statusline:
「あるプログラミング言語を一通り触る」という目標を達成するのに必要な課題の集合はなにか?
"Hellow World"
まずはこれ
標準出力、実行環境
"fizzbuzz"
if文, mod
@0xBADDCAFE
0xBADDCAFE / imgscript
Created January 3, 2014 21:24
curl でリファラ必要の画像サイトリストから一括で抜き出したい
curl でファイルを予測して引っ張ってくる。
file -bi で mimetype image かを頑張ってチェックする。
ミスなら拡張子など変えてリトライ。
curl はバックグラウンドでモリモリ呼び出して並列にダウンロードする。
全部の curl が終わったことを確認する仕組みがほしい。