Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
@danmackinlay
danmackinlay / supervisord.sh
Created August 27, 2009 07:07
an init.d script for supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@defunkt
defunkt / resque.py
Created November 3, 2009 19:49
Resque client in Python
from redis import Redis
import simplejson
class Resque(object):
"""Dirt simple Resque client in Python. Can be used to create jobs."""
redis_server = 'localhost:6379'
def __init__(self):
host, port = self.redis_server.split(':')
self.redis = Redis(host=host, port=int(port))
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# Feel free to rename the models, but don't rename db_table values or field names.
#
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'
# into your database.
from django.db import models
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {
@toastdriven
toastdriven / rebuild_environment.sh
Last active December 3, 2019 19:12
Rebuild Environment
brew install git
brew update
brew install readline
brew link readline
brew install python
brew install postgres
brew install tmux
brew install pip
brew install nginx
brew install libevent
import httplib, urlparse, socket
def http_get_headers_and_truncated_body(
url, max_redirects=5, body_length=2048, timeout=5,
allowed_content_types = ('text/html',), num_redirects_followed=0,
redirect_chain = None
):
redirect_chain = redirect_chain or []
# Returns {'ok':True,'headers':{},'redirected':False,'url':'','body': '',
# 'max_redirects_reached': False, 'num_redirects_followed': 0,
require 'formula'
<<-COMMENTS
This is the Homebrew formula for Python.
Versions
--------
This formula is currently tracking version 2.6.x.
# 2010-10-02 14h00
# Update created field in user_prefs table
def migrate(db):
with db.select('user_id, created', from_='users'):
all_users = db.fetchall()
for user in all_users:
with db.update('user_prefs') as obj:
obj.created = user['created']
db.where('user_id = %s', user['user_id'])
@rslinckx
rslinckx / csrf.py
Created October 14, 2010 21:15
CsrfProtector for Flask applications
import logging
log = logging.getLogger(__name__)
from datetime import timedelta
from flask.helpers import _endpoint_from_view_func
from flask import request, g, abort
import os
import hmac
irb(main):001:0> a = Object.new
=> #<Object:0x7ff7a6ff6388>
irb(main):002:0> a.object_id #获取对象ID
=> 70350817702340
irb(main):003:0> a.class #获取对象类型
=> Object
irb(main):004:0> Integer.superclass #获取父类
=> Numeric
irb(main):006:0> Numeric.superclass #...
=> Object