This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# if cron is not available | |
$ vim runme.sh | |
#!/bin/bash | |
while true; do | |
echo "Do useful stuff here" | |
sleep 86400 | |
done | |
$ nohup ./runme.sh & |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import urllib | |
import urllib2 | |
try: | |
import json | |
except ImportError: | |
try: | |
import simplejson as json | |
except ImportError: | |
raise ImportError("Need a json decoder") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an implementation of using python-oembed with api.embed.ly | |
# python-oembed http://code.google.com/p/python-oembed/ | |
import oembed | |
# Embed.ly Multi Provider API Endpoint | |
OEMBED_ENDPOINT = 'http://api.embed.ly/oembed/api/v1' | |
# URL Schemes Supported | |
URL_SCHEMES = ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: import oembed | |
In [2]: consumer = oembed.OEmbedConsumer() | |
In [3]: endpoint = oembed.OEmbedEndpoint('http://www.flickr.com/services/oembed', ['http://*.flickr.com/*']) | |
In [4]: consumer.addEndpoint(endpoint) | |
In [5]: response = consumer.embed('http://www.flickr.com/photos/wizardbt/2584979382/') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# strip &submit=Search in url | |
<%= submit_tag "Search", :name => nil %> | |
# keep the search keyword in input field | |
<%= text_field_tag :search, params[:search] %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 查看硬件信息 | |
sudo dmidecode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql master-slave (Replication)配置笔记 | |
感触最深的是:细节决定成败,尤其在Linux下配置服务。 | |
Master: | |
系统 fedora8 | |
数据库 | |
+------------+ | |
| version() | | |
+------------+ | |
| 5.0.45-log | | |
+------------+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MySQL配置文件my.cnf 例子最详细翻译,可以保存做笔记用。 | |
#BEGIN CONFIG INFO | |
#DESCR: 4GB RAM, 只使用InnoDB, ACID, 少量的连接, 队列负载大 | |
#TYPE: SYSTEM | |
#END CONFIG INFO | |
# | |
# 此mysql配置文件例子针对4G内存,并在两个日ip 2w ,pv 20w 测试过的。 | |
# 主要使用INNODB | |
#处理复杂队列并且连接数量较少的mysql服务器 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pool = ThreadPool(100) | |
#requests = makeRequests(some_callable, list_of_args, callback) | |
requests = makeRequests(get_data, get_urls, store_data) | |
[pool.putRequest(req) for req in requests] | |
while True: | |
try: | |
time.sleep(0.5) | |
main.poll() | |
except NoResultsPending: | |
print "**** No pending results." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf8 -*- | |
import logging | |
import logging.handlers | |
rootLogger = logging.getLogger('') | |
rootLogger.setLevel(logging.ERROR) | |
handler = logging.handlers.SMTPHandler( | |
mailhost='smtp.example.com', | |
fromaddr='[email protected]', | |
toaddrs='[email protected]', |