Skip to content

Instantly share code, notes, and snippets.

View jjaffeux's full-sized avatar

Joffrey JAFFEUX jjaffeux

View GitHub Profile
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
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(
@csanz
csanz / movingredistolinode.md
Created August 29, 2011 07:40
Moving your redis instance to linode

Move your redis instance to Linode!

create linode server instance

local:

<shell>$ssh root@(IP ADDRESS)

remote:

@mranney
mranney / emoji_sad.txt
Created January 30, 2012 23:05
Why we can't process Emoji anymore
From: Chris DeSalvo <[email protected]>
Subject: Why we can't process Emoji anymore
Date: Thu, 12 Jan 2012 18:49:20 -0800
Message-Id: <[email protected]>
--Apple-Mail=_6DEAA046-886A-4A03-8508-6FD077D18F8B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
@brentkirby
brentkirby / stack.sh
Created January 31, 2012 22:18
Linode nginx, php, mysql stackscript
#!/bin/bash
#
# Ruby 1.9.2 with options for database, and nginx install. Adds option to install RVM system-wide.
# Outputs to /root/stackscript.log
#
# <UDF name="deploy_user" Label="Name of deployment user." />
# <UDF name="deploy_password" Label="Password for deployment user." />
# <UDF name="deploy_sshkey" Label="Deployment user public ssh key." />
# <UDF name="ssh_port" Label="SSH Port" />
# <UDF name="new_hostname" Label="Server's hostname." />
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@chsh
chsh / appapp_delegate.rb
Created May 10, 2012 08:41
RubyMotion Localization sample.
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
alert = UIAlertView.new
alert.message = t('start')
alert.show
true
end
def t(key)
NSBundle.mainBundle.localizedStringForKey(key, value:nil, table:nil)
@godfat
godfat / app_delegate.rb
Created June 15, 2012 18:58
RubyMotion
class AppDelegate
attr_accessor :window
def application(application, didFinishLaunchingWithOptions:launchOptions)
self.window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
window.rootViewController = Controller.alloc.init
window.rootViewController.wantsFullScreenLayout = true
window.makeKeyAndVisible
true
end
end
@catwell
catwell / active.md
Last active December 21, 2023 09:47
Speakerdecks
@sxross
sxross / save_cancel_toolbar.rb
Created August 12, 2012 17:15
UIToolbar Subclass to Include Save and Done Buttons
class SaveCancelToolbar < UIToolbar
attr_writer :delegate
def initWithFrame frame, andTitle: title
super
items = []
spacer = UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemFlexibleSpace, target:nil, action:nil)
@cancel_button = UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemCancel, target:self, action:'on_cancel:')
class MyViewController < UIViewController
include ViewTags
#by convention, these views will have tags that correspond to the order you specify them in
# :date_label:1, :name_label:2
has_view :date_label, :name_label
def loadView
views = NSBundle.mainBundle.loadNibNamed "myview", owner:self, options:nil
self.view = views[0]