Skip to content

Instantly share code, notes, and snippets.

View ymotongpoo's full-sized avatar
📈
observability matters

Yoshi Yamaguchi ymotongpoo

📈
observability matters
View GitHub Profile
module A = struct
let map f l = List.rev (List.rev_map f l)
let enclose x = "(" ^ x ^ ")"
let cross lhs rhs =
let rec cross_aux accu = function
| [] -> accu
| x::xs -> cross_aux (List.fold_left (fun a y -> (x^y)::a) accu rhs) xs
in
cross_aux [] lhs
@ymotongpoo
ymotongpoo / binarytree.ml
Created December 19, 2010 12:31
test implementation of binary tree
type 'a tree = Lf | Bt of 'a * 'a tree * 'a tree
let rec size = function
| Lf -> 0
| Bt (_, l, r) -> 1 + (size l) + (size r)
let rec depth = function
| Lf -> 0
| Bt (_, l, r) -> 1 + max (depth l) (depth r)
@ymotongpoo
ymotongpoo / clean_dir.sh
Created February 1, 2011 17:03
download script for specific file in mod_uploader
#!/bin/bash
download_dir=./download
cd $download_dir
for file in `find . -name "*.zip"`; do
unzip $file
rm $file
touch $file
done
@ymotongpoo
ymotongpoo / flv_downloader.py
Created February 7, 2011 16:35
download flv file from some video site
# -*- coding: utf-8 -*-
import re
import urllib
from urlparse import urlunparse, urlparse
import gzip
import eventlet
from eventlet.green import urllib2
import cookielib
from pyquery import PyQuery as pq
# -*- coding: utf-8 -*-
# expressing my strong respect for mopemope
import re
import urllib
from urlparse import urlunparse, urlparse
import gzip
import eventlet
from eventlet.green import urllib2
import cookielib
@ymotongpoo
ymotongpoo / setup.py
Created May 12, 2011 22:14
char* operation practice
# -*- coding: utf-8 -*-
try:
from setuptools.setuptools import setup, Extension
except:
from distutils.core import setup, Extension
import sys
import os
from subprocess import Popen, PIPE
@ymotongpoo
ymotongpoo / GPL-LICENSE.txt
Created August 1, 2011 11:02
crawl and extract youtube links in 2ch summary blogs
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
@ymotongpoo
ymotongpoo / pybestpkg.py
Created August 25, 2011 16:44
extract python package name and download counts from PyPI
# -*- coding: utf-8 -*-
from lxml import etree
from StringIO import StringIO
from multiprocessing import Pool
import urllib2
base_url = r"http://pypi.python.org"
xhtml_ns = r'http://www.w3.org/1999/xhtml'
pypi_list = r"http://pypi.python.org/pypi?%3Aaction=index"
@ymotongpoo
ymotongpoo / concat_pdf.py
Created August 29, 2011 17:01
concat multiple pdf files
# -*- coding: utf-8 -*-
from pyPdf import PdfFileWriter, PdfFileReader
def main(output_file, input_files):
print "concat all files:"
output = PdfFileWriter()
total_pages = 0
@ymotongpoo
ymotongpoo / pyspa_irc_download.py
Created September 29, 2011 05:15
download file on basic authed site
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
from datetime import datetime, timedelta
# create Basic Authorized opener
username = "nishio"
password = "nishio"
realm = "secret bucho contents"