Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
# if cron is not available
$ vim runme.sh
#!/bin/bash
while true; do
echo "Do useful stuff here"
sleep 86400
done
$ nohup ./runme.sh &
#!/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 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 = (
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/')
@lxneng
lxneng / gist:337493
Created March 19, 2010 13:29
strip &submit=xxx in url
# strip &submit=Search in url
<%= submit_tag "Search", :name => nil %>
# keep the search keyword in input field
<%= text_field_tag :search, params[:search] %>
@lxneng
lxneng / gist:340926
Created March 23, 2010 07:42
查看硬件信息
# 查看硬件信息
sudo dmidecode
mysql master-slave (Replication)配置笔记
感触最深的是:细节决定成败,尤其在Linux下配置服务。
Master:
系统 fedora8
数据库
+------------+
| version() |
+------------+
| 5.0.45-log |
+------------+
MySQL配置文件my.cnf 例子最详细翻译,可以保存做笔记用。
#BEGIN CONFIG INFO
#DESCR: 4GB RAM, 只使用InnoDB, ACID, 少量的连接, 队列负载大
#TYPE: SYSTEM
#END CONFIG INFO
#
# 此mysql配置文件例子针对4G内存,并在两个日ip 2w ,pv 20w 测试过的。
# 主要使用INNODB
#处理复杂队列并且连接数量较少的mysql服务器
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."
# -*- 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]',