Skip to content

Instantly share code, notes, and snippets.

View kkc's full-sized avatar
🌴
On vacation

Kakashi Liu kkc

🌴
On vacation
View GitHub Profile
@kkc
kkc / graphite.md
Last active December 27, 2015 17:49 — forked from caged/graphite.md

install graphite (http://graphite.wikidot.com) on AWS ubuntu 12.04. Fix py2cairo installation problem on virtualenv environment. Please fork and fix if you find an error.

Install Cairo

sudo apt-get install libcairo2-dev

Instally py2cairo

#git clone git://git.cairographics.org/git/py2cairo
@kkc
kkc / gist:7460292
Last active December 28, 2015 06:49
Ubuntu更新時區
dpkg-reconfigure tzdata # 將時區設回台灣
ntpdate time.stdtime.gov.tw
@kkc
kkc / gist:7513640
Last active September 27, 2019 11:36
scrapy formrequest
"""
iyp spider
a crawler for iyp.com.tw
"""
from scrapy.selector import Selector
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.http.request import Request
from scrapy.http import FormRequest
from prototype.items import PrototypeItem
@kkc
kkc / gist:7523583
Created November 18, 2013 06:37
polipo setting
### Basic configuration
### *******************
# Uncomment one of these if you want to allow remote clients to
# connect:
# proxyAddress = "::0" # both IPv4 and IPv6
# proxyAddress = "0.0.0.0" # IPv4 only
proxyAddress = "127.0.0.1"
@kkc
kkc / gist:7583766
Created November 21, 2013 15:35
test
# -*- coding:utf-8 -*-
import json
import csv
csv_data = []
for line in open('items.trans.jl'):
try:
data = json.loads(line)
except:
@kkc
kkc / gist:7819336
Created December 6, 2013 06:13
SgmlLinkExtractor
In [10]: fetch('http://www.last.fm/music/AC%252FDC/+images')
In [11]: lx = SgmlLinkExtractor(restrict_xpaths=('//a[@class="nextlink"]'))
In [12]: lx.extract_links(response)
Out[12]: [<Link url='http://www.last.fm/music/AC%2FDC/+images?page=2' text=u'Next' >]
@kkc
kkc / gist:7868249
Last active December 30, 2015 18:29
sort dict of list
people = [
{age:'17', name: 'John'},
{age:'24', name: 'kakashi'},
]
sorted(people, key=lambda person: person['age'])
from operator import itemgetter
sorted(people, key=itemgetter('age'))
@kkc
kkc / gist:7869167
Created December 9, 2013 08:39
pytz
from datetime import datetime
import pytz
now = datetime.utcnow()
datetime.datetime(2013, 11, 17, 14, 13, 51, 641900)
now = now.replace(tzinfo=pytz.utc)
datetime.datetime(2013, 11, 17, 14, 13, 51, 641900, tzinfo=<UTC>)
@kkc
kkc / setup.py
Created December 23, 2013 11:41 — forked from edwardgeorge/setup.py
import os
import shutil
import subprocess
import sys
import tarfile
import urllib2
LIBXML2_PREFIX = "libxml2"
LIBXSLT_PREFIX = "libxslt"
LIBXML2_FTPURL = "ftp://xmlsoft.org/libxml2/"
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://raw.github.com/gist/2776679/04ca3bbb9f085b192f6aca945120fe12d59f15f9/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"