Skip to content

Instantly share code, notes, and snippets.

View c4urself's full-sized avatar

Christian Verkerk c4urself

  • Tubular Labs
  • Mountain View
View GitHub Profile
@c4urself
c4urself / url_patterns.py
Created June 16, 2011 08:39
URL Patterns with Optional Arguments
(r'^articles/(?P<year>\d{4}/?$, 'main.views.year'),
# When a use case comes up that a month needs to be involved as
# well, you add an argument in your regex:
(r'^articles/(?P<year>\d{4}/(?P<month>\d{2})/?$, 'main.views.year_month'),
# That works fine, unless of course you want to show something
# different for just the year, in which case the following case can be
# used, making separate views based on the arguments as djangoproject
@c4urself
c4urself / theme_override.dart
Created May 21, 2020 17:16
theme_override.dart
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// Overrides the default Theme to force a light app bar
class LightAppBarOverride extends StatelessWidget
implements PreferredSizeWidget {
const LightAppBarOverride({this.child});
final AppBar child;
@override
Widget build(BuildContext context) {
@c4urself
c4urself / django_orm_inner_join.py
Created February 7, 2012 21:43
Django ORM INNER JOIN SQL test
from django.db import models
class Banana(models.Model):
name = models.CharField(max_length=255)
father = models.ForeignKey('self', null=True)
def __unicode__(self):
return self.name
import asyncio
import tornado
from tornado import gen, ioloop
SLEEPY = 0.2
async def native_coroutine():
print('hi from native')
await asyncio.sleep(SLEEPY)
@c4urself
c4urself / bazel_talk_02.py
Created April 4, 2018 18:17
Bazel Talk 02
pex_binary(
name = "ingestion",
main = "manage.py",
deps = [
"//pkg-rubberband:rubberband",
]
)
@c4urself
c4urself / bazel_talk_01.py
Created April 4, 2018 17:45
Bazel Talk 01
pex_library(
name = "rubberband",
srcs = glob(["rubberband/**/*.py"]),
reqs = [
third_party_req("lazy"),
third_party_req("tornado"),
third_party_req("ujson"),
],
deps = [
"//pkg-mon:mon",
@c4urself
c4urself / terraform.sh
Created September 28, 2016 20:50
Wrapper around Terraform
#!/bin/sh
set -e
TERRAFORM_BUCKET_REGION='us-east-1'
TERRAFORM_BUCKET_NAME=''
TERRAFORM_VERSION="0.7.4"
actions="plan apply fmt plan-destroy destroy refresh graph validate"
#!/usr/bin/env python
import re
import sys
keyspace, table, size_in_gb = 'unknown', 'unknown', 0.0
for line in sys.stdin.readlines():
if 'Keyspace:' in line:
m = re.search(r'Keyspace: (?P<keyspace>\w+)', line)
keyspace = m.group('keyspace')
@c4urself
c4urself / tagging_instances.tf
Created June 8, 2016 17:50
How to dynamically tag instance via a module in Terraform?
variable "ami_id" { }
variable "subnet_id" { }
variable "security_group_id" { }
variable "key_name" { }
variable "instance_profile" { }
variable "instance_type" { }
variable "instance_name" { }
variable "hostname" { }
variable "tag_role" { }
variable "tag_cost_environment" { }

Keybase proof

I hereby claim:

  • I am c4urself on github.
  • I am c4urself (https://keybase.io/c4urself) on keybase.
  • I have a public key ASBaqM5prpaQZAoTI4cL1wNlBEMYaRPAHyenuaahYJRxpAo

To claim this, I am signing this object: