Skip to content

Instantly share code, notes, and snippets.

View philwo's full-sized avatar
🌻
Available

Philipp Wollermann philwo

🌻
Available
View GitHub Profile
class DynamicFormValidation(Validation):
""" Validation class that allows dynamic form classes and initial data.
Initial data is only used to validate the form - it will not modify
the data that the user has posted. So form validation might pass,
but saving the model will fail.
"""
initial = {}
def __init__(self, **kwargs):
@philwo
philwo / gist:2396442
Created April 16, 2012 05:16
Chef attributes, roles and environment
### cookbooks/nova/attributes/default.rb:
# you should override controller_ip for a multi-node setup
default['nova']['controller_ip'] = "127.0.0.1"
default['nova']['db_ipaddress'] = node['mysql']['bind_address']
default['nova']['rabbitmq_ipaddress'] = node['nova']['controller_ip']
default['nova_api']['ipaddress'] = node['nova']['controller_ip']
[philwo@philwo ca-openstack]$ knife environment show stackcluster1 -fj
{
@philwo
philwo / attributes-default.rb
Created July 5, 2012 06:04
Chef cookbook for nginx + passenger (compiled from source)
default['nginx']['version'] = "1.2.0"
default['nginx']['passenger']['version'] = "3.0.12"
@philwo
philwo / recursive_imap.diff
Created September 16, 2012 11:45
Patches for isync
diff -ur isync-1.0.5~/src/drv_imap.c isync-1.0.5/src/drv_imap.c
--- isync-1.0.5~/src/drv_imap.c 2012-09-16 20:46:17.000000000 +0900
+++ isync-1.0.5/src/drv_imap.c 2012-09-16 20:48:16.000000000 +0900
@@ -22,6 +22,13 @@
* despite that library's more restrictive license.
*/
+#include <config.h>
+#if HAVE_LIBSSL
+# include <openssl/ssl.h>
@philwo
philwo / manage.py
Created October 1, 2012 02:23
Django manage.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airforce.settings")
from django.core.management import execute_from_command_line
@philwo
philwo / README.md
Created October 5, 2012 02:02
Database benchmark

Recommended settings for RAID

  • RAID 10
  • Stripe size 512K
  • Enable write-back cache
  • Disable read-ahead
  • Disable read cache
  • Disable drive write cache

Recommended settings for filesystems, etc.

@philwo
philwo / vmstat.py
Created November 12, 2012 09:19
vmstat output pre-processor
#!/usr/bin/env python
'''
tr -s ' ' < tpcc_pg_report.vmstat | sed 's/^ //g' | sed 's/ /,/g' > tpcc_pg_report.vmstat.csv
'''
from __future__ import division
import csv
from itertools import izip_longest
@philwo
philwo / dashboard.py
Created November 23, 2012 07:14
Clover Grappelli Dashboard Configuration
# -*- coding: utf-8 -*-
#
# Copyright 2012 Philipp Wollermann
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@philwo
philwo / BUILD
Created November 30, 2016 14:20
Bazel benchmark for sandboxing performance
# Benchmarks for sandbox performance
#
# Run with 'bazel build :gen_main' and measure the time it takes.
# Creates 15000 input files.
inputs = ["input_%s" % i for i in range(15000)]
genrule(
name = "gen_inputs",
outs = inputs,
cmd = "date | tee $(OUTS) > /dev/null",
@philwo
philwo / net_namespace-mutex.patch
Created November 7, 2017 23:32
Experimental patch to speed up network namespace destruction under high concurrency load
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 1fe58167d39a6fb907be443765693e328a1e6b7e..506e6d32fda4ae5071fec1ea397117d161982cb4
100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -426,7 +426,9 @@ static void cleanup_net(struct work_struct *work)
* This needs to be before calling the exit() notifiers, so
* the rcu_barrier() below isn't sufficient alone.
*/
+ mutex_unlock(&net_mutex);