Skip to content

Instantly share code, notes, and snippets.

@aminamid
aminamid / show_bigmsgs_by_pop.py
Created March 12, 2014 03:39
pythonでPOP SSLを使い大きい順に5個メッセージを表示又は削除する
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import time
import poplib
import email
def get_subject(msg):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
複数プロセスから複数スレッドを起動して、Ctrl-Cで停止する例
'''
import time
import threading
import multiprocessing
@aminamid
aminamid / app.py
Created March 14, 2014 10:52
Access RIAK REST API from angularJS $resource by Tornado.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import json
import tornado
from tornado import websocket, web, ioloop, gen, httpclient
ws_client = []
@aminamid
aminamid / gen_token.sh
Created April 8, 2014 11:18
1 line cassandra token generator
# tokengenerator (node#,num of node)
python -c 'print (lambda node,nodes: [ 2**127/nodes*x for x in xrange(nodes)][node-1])(1,5)'
@aminamid
aminamid / README.md
Created April 17, 2014 03:28
Chatserver by angularJS + geventwebsocket + flask

Location

./test.py ./static/index.html ./static/client.js

Usage

python ./test.py

@aminamid
aminamid / index.html
Created April 25, 2014 03:33
Sample of AngularJS and Flask-Restless
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.1/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.1/angular-resource.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.1/angular-cookies.min.js"></script>
<script language="javascript">
function pausecomp(ms) {
ms += new Date().getTime();
while (new Date() < ms){}
@aminamid
aminamid / Centos.md
Last active August 29, 2015 14:00
cheatsheets

netstatの代替

ss -onapet | cat
ss -onapet | grep `pgrep imdircacheserv`
ss -onapet4l | sort -k5

カプレーゼ

材料

  • モッツァレラ
  • プチトマト
  • バジル
  • オリーブオイル
  • 胡椒
@aminamid
aminamid / downloaddsv.py
Created May 9, 2014 08:41
Python snippet
class FileHandler(tornado.web.RequestHandler):
def get(self):
self.set_header('Content-Type', "text/csv")
self.set_header('Content-Disposition',
"attachment; filename=\"{}\"".format(filename))
self.set_header('Content-Length', os.path.getsize(filename))
with open(filename, 'rb') as fp:
self.write(fp.read())
import datetime
for obj in a:
datetime.datetime.fromtimestamp(float(id(obj))/pow(10,5)).strftime( '%Y-%m-%d %H:%M:%S' )