Skip to content

Instantly share code, notes, and snippets.

@didip
didip / information-schema-analytics.sql
Created December 30, 2010 21:59
Find out size of tables and other meta information from MySQL
SELECT concat( table_schema, '.', table_name ) table_name,
concat( round( data_length / ( 1024 *1024 ) , 2 ) , 'M' ) data_length,
concat( round( index_length / ( 1024 *1024 ) , 2 ) , 'M' ) index_length,
concat( round( round( data_length + index_length ) / ( 1024 *1024 ) , 2 ) , 'M' ) total_size,
table_rows,
engine
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'coolshit_dev'
ORDER BY data_length DESC;
@didip
didip / delicious-scraper.py
Created December 17, 2010 23:53
Scrape delicious links using Python
# Requirements:
# - python-lxml
# - pyquery
#
# As implemented in http://mybucket.co
# html_util.py
from pyquery import PyQuery as pq
def extract_delicious_data_from_html(html):
results = []
settings = {'debug': True}
handlers = [(r"/", MainHandler)]
tornado.web.Application.__init__(self, handlers, **settings)
==> Build Environment
CC: /usr/bin/cc => /usr/bin/gcc-4.2
CXX: /usr/bin/c++ => /usr/bin/c++-4.2
LD: /usr/bin/cc => /usr/bin/gcc-4.2
CFLAGS: -O3 -w -pipe
CXXFLAGS: -O3 -w -pipe
CPPFLAGS: -I/usr/local/Cellar/readline/6.1/include
LDFLAGS: -L/usr/local/Cellar/readline/6.1/lib
MAKEFLAGS: -j4
PKG_CONFIG_PATH: /usr/local/Cellar/readline/6.1/lib/pkgconfig
c = pycurl.Curl()
c.setopt(pycurl.URL, "http://example.com/post")
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.POSTFIELDS,
urllib.urlencode({
'some_data': 'the data',
'some_more_data': 'more data',
})
)
c.perform()
# --------------------------------------------------
# app.py - nothing special here
# --------------------------------------------------
import tornado.httpserver
import tornado.ioloop
import tornado.web
class Application(tornado.web.Application):
def __init__(self):
pass
#!/bin/bash
# This is recipe for OS X only
# A wise man once said; When shit fails, use strace(Linux) or dtruss(OS X)
# Installing MySQL gem
export ARCHFLAGS="-arch i386 -arch x86_64" ; gem install --no-rdoc --no-ri mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
# Create symlink
# If that symlink does not work, use strace to figure out where MySQL gem is looking for it.
from paste.deploy import appconfig
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from your_app.config.middleware import make_app
port = 5000
config = appconfig("config:%s" % "/your/app/development.ini")
app = make_app(config.global_conf, **config.local_conf)
@didip
didip / gist:251919
Created December 8, 2009 19:41 — forked from samg/gist:251918
httperf --hog --server 10.1.10.118 --port 8080 --num-conn 10000 --ra 100 --num-calls=100 --timeout .01
#!/bin/bash
DUMPFILE=/tmp/dump.`date +%Y.%m.%d`.sql
echo Dumping > $DUMPFILE
mysqldump dump > $DUMPFILE
echo Finished dumping >> $DUMPFILE