Skip to content

Instantly share code, notes, and snippets.

View tyrchen's full-sized avatar

Tyr Chen tyrchen

View GitHub Profile
@tyrchen
tyrchen / redis_session_backend.py
Created December 5, 2011 09:14 — forked from mikeyk/redis_session_backend.py
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(

Django-celery + Redis notes

Installation and Setup

  1. Install redis on OSX (10.7) Lion I used:

     $ brew install redis
    
  2. In the project and virtualenv I wanted to use django-celery in I installed the following.

# UpYun storage for django, written by Tyr Chen @ tukeq.com
# to run this gist you need to get upyun python sdk first.
# upyun storage
class UpYunStorage(Storage):
def __init__(self, bucket=settings.UPYUN_BUCKET):
self.upyun = UpYun(bucket, settings.UPYUN_USERNAME, settings.UPYUN_PASSWORD)
self.upyun.setApiDomain(settings.UPYUN_API_DOMAIN)
self.binding_domain = settings.UPYUN_BINDING_DOMAIN
@tyrchen
tyrchen / README.md
Created November 7, 2012 00:33 — forked from dariocravero/README.md
Save files in Meteor

Create a Meteor app and put the client_/server_ files in a client/server directories. Also, create a public dir to save the uploaded files.

// Set up a collection to contain player information. On the server,
// it is backed by a MongoDB collection named "players".
Players = new Meteor.Collection("players");
if (Meteor.isClient) {
Template.leaderboard.players = function () {
return Players.find({}, {sort: {score: -1, name: 1}});
};
Template.leaderboard.selected_name = function () {
var player = Players.findOne(Session.get("selected_player"));
return player && player.name;
#!/bin/bash
#
# MongoDB Backup Script
# VER. 0.1
# Note, this is a lobotomized port of AutoMySQLBackup
# (http://sourceforge.net/projects/automysqlbackup/) for use with
# MongoDB.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

Untitled Slide

Welcome to Glide.

Glide is the easiest way to create useful slide for all of your Gists.

  • input key <- to go backward.
  • input key -> to go forward.

Publishing

ssh ubuntu@n.n.n.n "bash -s -x" -- <ixgbevf-upgrade.sh
#!/bin/bash
usage ()
{
cat <<UsageHERE
boot2docker-fwd -- Helper function to quickly manage port forwards between the boot2docker-vm and the host
Usage: boot2docker-fwd [ -n RULE_NAME ] [ -h HOST_PORT ] [ -p {tcp|udp} ] [ -i HOST_IP ] GUEST_PORT
or boot2docker-fwd -d RULE_NAME
or boot2docker-fwd -l
or boot2docker-fwd -A