Skip to content

Instantly share code, notes, and snippets.

View tschellenbach's full-sized avatar

Thierry Schellenbach tschellenbach

View GitHub Profile
[
{
"actor": "user:dnevozhai",
"verb": "add",
"object": "picture:1",
"foreign_id": "picture:1",
"image": "https://images.unsplash.com/photo-1483664852095-d6cc6870702d?auto=format&fit=crop&w=3450&q=80&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D",
"message": "I was driving home from Mammoth Lakes by 88 somewhere near Kirkwood when suddenly after another turn this view has appeared. Not thinking too much I crossed double solids :) and parked on the other side. I left the car and walked in the knee deep snow for like 10 meters further from the road to reach untouched powder and take some nice sunset photos. This was one of them.",
"tags": ["tree", "snow", "winter", "landscape"],
"location": "Kirkwood",
@tschellenbach
tschellenbach / getstream_example_if_statement.py
Created December 15, 2014 13:04
GetStream.io aggregated notification feed example with if statement
# Instantiate a new client
import stream
client = stream.connect('key', 'secret')
# Assume the notification is aggregated on
# {% if verb.infinitive == 'like' %}{{ object }}{% else %}{{ id }}{% endif %}
notification_feed = client.feed('notification', '1')
# Add two likes, one comment and two follows
activities = [
@tschellenbach
tschellenbach / getstream_example.py
Created December 15, 2014 13:02
GetStream.io aggregated notification feed example with if statement
# Instantiate a new client
import stream
client = stream.connect('key', 'secret')
# Assume the notification is aggregated on
# {% if verb.infinitive == 'like' %}{{ object }}{% else %}{{ id }}{% endif %}
notification_feed = client.feed('notification', '1')
# Add two likes, one comment and two follows
activities = [
@tschellenbach
tschellenbach / gist:b0f1cf65647cb0acd0ef
Created December 15, 2014 13:02
GetStream.io aggregated notification feed example
# Instantiate a new client
import stream
client = stream.connect('key', 'secret')
# Assume the notification is aggregated on
# {% if verb.infinitive == 'like' %}{{ object }}{% else %}{{ id }}{% endif %}
notification_feed = client.feed('notification', '1')
# Add two likes, one comment and two follows
activities = [
private void openIfNotHere(Class<? extends Activity> targetClass) {
if (!getClass().isAssignableFrom(targetClass)) {
/*
* When clicking a menu item we follow Google's best practices as defined here:
* https://developer.android.com/design/patterns/navigation.html
* and
* https://developer.android.com/guide/components/tasks-and-back-stack.html
*
* The result is that when you click to
* - people and subsequently
{
"coord":{
"lon":4.89,
"lat":52.37
},
"sys":{
"message":0.0094,
"country":"NL",
"sunrise":1390721381,
"sunset":1390752987
Environment:
Request Method: POST
Request URL: http://foodtrip.ph/facebook/connect/?facebook_login=1
Django Version: 1.5.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
2013-08-26 13:49:11,820 [INFO] snaptastic.snapshotter: Attaching volume vol-b3b128e6 to instance i-ce402f81
Aug 26 13:49:12 ip-10-37-176-131 startup: Traceback (most recent call last):
Aug 26 13:49:12 ip-10-37-176-131 startup: File "/usr/local/bin/snaptastic", line 9, in <module>
Aug 26 13:49:12 ip-10-37-176-131 startup: load_entry_point('snaptastic==0.2.10', 'console_scripts', 'snaptastic')()
Aug 26 13:49:12 ip-10-37-176-131 startup: File "/usr/local/lib/python2.7/dist-packages/snaptastic/cli.py", line 125, in main
Aug 26 13:49:12 ip-10-37-176-131 startup: p.dispatch()
Aug 26 13:49:12 ip-10-37-176-131 startup: File "/usr/local/lib/python2.7/dist-packages/argh/helpers.py", line 53, in dispatch
Aug 26 13:49:12 ip-10-37-176-131 startup: return dispatch(self, *args, **kwargs)
Aug 26 13:49:12 ip-10-37-176-131 startup: File "/usr/local/lib/python2.7/dist-packages/argh/dispatching.py", line 123, in dispatch
Aug 26 13:49:12 ip-10-37-176-131 startup: for line in lines:
@tschellenbach
tschellenbach / cached.py
Last active December 16, 2015 23:59
Makes the decorator syntax uniform Regardless if you call the decorator like @decorator or @decorator() or @decorator(staff=True) Complexity, Python's class based decorators are weird to say the least: http://www.artima.com/weblogs/viewpost.jsp?thread=240845 This function makes sure that your decorator class always gets called with __init__(fn,…
from functools import wraps
from django.utils.decorators import available_attrs
class CachedDecorator(object):
"""
Decorator which cached the call to the give function. Usage example ::
@cached(key='notification_settings_%(user_id)s', timeout=60 * 10)
@tschellenbach
tschellenbach / transaction_management.py
Created September 12, 2012 12:13
Testing transaction managemenet
@fashiolista_env
def health(request):
import random
from django.db import transaction, connections
from user.models import Profile
using = 'default'
def print_isolation_levels(using, msg):
autocommit_sql = "SHOW AUTOCOMMIT;"