Skip to content

Instantly share code, notes, and snippets.

View danfairs's full-sized avatar

Dan Fairs danfairs

View GitHub Profile
@danfairs
danfairs / gist:8916480
Created February 10, 2014 14:02
Error while running fabtools tests
This file has been truncated, but you can view the full file.
(fabtools)skater:fabtools danfairs$ FABTOOLS_TEST_BOXES='precise64 opscode-ubuntu-13.04' tox -epy27
GLOB sdist-make: /Users/danfairs/Envs/fabtools/src/fabtools/setup.py
py27 inst-nodeps: /Users/danfairs/Envs/fabtools/src/fabtools/.tox/dist/fabtools-0.18.0-dev.zip
py27 runtests: PYTHONHASHSEED='559934745'
py27 runtests: commands[0] | /Users/danfairs/Envs/fabtools/src/fabtools/.tox/py27/bin/python -m unittest discover
................................[localhost] local: rm -f Vagrantfile
[localhost] local: vagrant init precise64
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on

Elasticsearch configuration for high sustainable bulk feed

Test on single node, MacBook Pro, 16 GB RAM, 1TB SSD, OS X Maverick

ES 1.1.0 with Java 8, G1 GC, 12 GB heap

/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/java -Xms12g -Xmx12g -Djava.awt.headless=true -XX:+UseG1GC -Delasticsearch -Des.foreground=yes -Des.path.home=/Users/es/elasticsearch-1.1.0 -cp :/Users/es/elasticsearch-1.1.0/lib/elasticsearch-1.1.0.jar:/Users/es/elasticsearch-1.1.0/lib/:/Users/es/elasticsearch-1.1.0/lib/sigar/ org.elasticsearch.bootstrap.Elasticsearch

Node

@danfairs
danfairs / gist:956803
Created May 5, 2011 09:42
Python memory usage
>>> x = range(0, 100000000)
>>> import gc
>>> x = None
>>> gc.collect()
0
<!doctype html>
<html>
<script>
var response = prompt("Do you like me?");
if (response === "yes") {
console.log("I like you too!");
}
if (response === "no") {
console.log("GTFO");
}
@danfairs
danfairs / gist:2891161
Created June 7, 2012 19:51
couchapp dispatch
def get_or_create_db(self, db_name, designs=ALL_DESIGNS):
from couchapp import dispatch
couchapp_dir = os.path.join(
settings.PROJECT_DIR, '..', '..', 'couchdb', 'tweet_counts'
)
server = couchdbkit.Server(uri=settings.COUCHDB_SERVER_URI,
resource_class=couchdb.RequestsResource)
db = server.get_db(db_name)
try:
db.info()
class UserProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
def __init__(self, *args, **kwargs):
super(UserProfileForm, self).__init__(*args, **kwargs)
self.fields['country'].queryset = Country.on_site.all()
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
configure:3747: $? = 0
configure:3754: gcc -V >&5
llvm-gcc-4.2: argument to `-V' is missing
configure:3758: $? = 1
configure:3780: checking for C compiler default output file name
configure:3802: gcc -I/Users/dan/tmp/build-couchdb/build/include -I/Users/dan/tmp/build-couchdb/build/include/js -Xlinker -rpath=/Users/dan/tmp/build-couchdb/build/lib -L/Users/dan/tmp/build-couchdb/build/lib conftest.c >&5
ld: unknown option: -rpath=/Users/dan/tmp/build-couchdb/build/lib
collect2: ld returned 1 exit status
@danfairs
danfairs / gist:3499547
Created August 28, 2012 16:06
Class-based task
class BaseEnrich(object):
def __init__(self):
self.guesser = Guesser()
@task(ignore_result=True, base=BaseEnrich)
def enrich(self, data):
data['guess'] = self.guesser.guess('text')
return data
@task(ignore_result=True)
@danfairs
danfairs / gist:3817368
Created October 2, 2012 08:35
Recruiters
Hi,
This is an automated message.
I've sent several emails to recruiters at g2 over the past months
saying that I don't want any CVs. I'm not recruiting.
However, you've ignored me. Why would I use a recruitment agency
who ignores what I want? Hence, I'll never use you. I will also
strongly recommend that none of my contacts use you.
@danfairs
danfairs / gist:3905379
Created October 17, 2012 12:57
Reverse filtering on ForeignKey/ToManyFields
from tastypie.fields import NOT_PROVIDED, ToManyField
class OrmToManyField(ToManyField):
def __init__(self, to, attribute, related_name=None, default=NOT_PROVIDED,
null=False, blank=False, readonly=False, full=False,
unique=False, help_text=None, orm_attribute=None):
super(OrmToManyField, self).__init__(
to, attribute, related_name=related_name, default=default,