Skip to content

Instantly share code, notes, and snippets.

View zhu327's full-sized avatar
🥰
Out sick

Timmy zhu327

🥰
Out sick
View GitHub Profile
@bdarnell
bdarnell / django_tornado_handler.py
Created October 29, 2010 18:59
django_tornado_handler.py
# NOTE: This code was extracted from a larger class and has not been
# tested in this form. Caveat emptor.
import django.conf
import django.contrib.auth
import django.core.handlers.wsgi
import django.db
import django.utils.importlib
import httplib
import json
import logging
@mxcl
mxcl / uninstall_homebrew.sh
Created August 26, 2011 11:25
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@saghul
saghul / glocal.py
Created November 26, 2012 22:43
greenlet locals for greenlet >= 0.4.0
from greenlet import getcurrent
__all__ = ['local']
def _get_local_dict():
current = getcurrent()
s = '_%s__local_dict__' % current.__class__.__name__
if not hasattr(current, s):
@stormwild
stormwild / sql_safe_updates
Last active February 6, 2024 23:52
How to disable MySQL Safe Mode
UPDATE table_name SET bDeleted=0 WHERE name='xyz';
“You are using safe update mode and you tried to update a table without a WHERE clause that uses a KEY column.”
SET SQL_SAFE_UPDATES=0;
UPDATE table_name SET bDeleted=0 WHERE name='xyz';
SET SQL_SAFE_UPDATES=1;
#http://www.xpertdeveloper.com/2011/10/mysql-safe-update/
@shiny
shiny / 短网址互转.py
Created July 28, 2013 05:21
以下代码是python3版本的
import math
import decimal
def convert_to_code(num):
"""
将数字转换为代码
"""
def get_num(num, out=''):
num = decimal.Decimal(num)
codes = "abcdefghjkmnpqrstuvwxyz23456789ABCDEFGHJKMNPQRSTUVWXYZ"

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@st4lk
st4lk / django_log_settings.py
Last active December 2, 2022 07:14
Django logging settings
# Logging settings for django projects, works with django 1.5+
# If DEBUG=True, all logs (including django logs) will be
# written to console and to debug_file.
# If DEBUG=False, logs with level INFO or higher will be
# saved to production_file.
# Logging usage:
# import logging
# logger = logging.getLogger(__name__)
# logger.info("Log this message")
/**
* Format a date like YYYY-MM-DD.
*
* @param {string} template
* @param {Date=} [date]
* @return {string}
* @license MIT
*/
function formatDate(template, date) {
var specs = 'YYYY:MM:DD:HH:mm:ss'.split(':');
@cloverstd
cloverstd / cache.py
Last active October 27, 2021 05:35
tornado cache
# coding: utf-8
try:
import cPickle as pickle
except ImportError:
import pickle
try:
import hashlib
sha1 = hashlib.sha1
@curtismcmullan
curtismcmullan / setup_selenium.sh
Last active May 2, 2023 22:56
Setup Selenium Server on Ubuntu 14.04
#!/bin/bash
# Following the guide found at this page
# http://programmingarehard.com/2014/03/17/behat-and-selenium-in-vagrant.html
echo "\r\nUpdating system ...\r\n"
sudo apt-get update
# Create folder to place selenium in