Skip to content

Instantly share code, notes, and snippets.

Avatar
📈
observability matters

Yoshi Yamaguchi ymotongpoo

📈
observability matters
View GitHub Profile
View paren.ml
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 Dec 19, 2010
test implementation of binary tree
View binarytree.ml
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 Feb 1, 2011
download script for specific file in mod_uploader
View clean_dir.sh
#!/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 Feb 7, 2011
download flv file from some video site
View flv_downloader.py
# -*- 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
View megaporn.py
# -*- 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
char* operation practice
View setup.py
# -*- 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 Aug 1, 2011
crawl and extract youtube links in 2ch summary blogs
View GPL-LICENSE.txt
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 Aug 25, 2011
extract python package name and download counts from PyPI
View pybestpkg.py
# -*- 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 Aug 29, 2011
concat multiple pdf files
View concat_pdf.py
# -*- 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 Sep 29, 2011
download file on basic authed site
View pyspa_irc_download.py
#! /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"