Skip to content

Instantly share code, notes, and snippets.

@marick
marick / about_those_lava_lamps.md
Last active June 22, 2022 21:08
About Those Lava Lamps

Around 2006-2007, it was a bit of a fashion to hook lava lamps up to the build server. Normally, the green lava lamp would be on, but if the build failed, it would turn off and the red lava lamp would turn on.

By coincidence, I've actually met, about that time, (probably) the first person to hook up a lava lamp to a build server. It was Alberto Savoia, who'd founded a testing tools company (that did some very interesting things around generative testing that have basically never been noticed). Alberto had noticed that people did not react with any urgency when the build broke. They'd check in broken code and go off to something else, only reacting to the breakage they'd caused when some other programmer pulled the change and had problems.

@pirhoo
pirhoo / reindex.py
Created October 23, 2013 16:50
This Django command helps us to reindex a model (especialy with Neo4j).
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
from django.db.models.loading import get_model
class Command(BaseCommand):
help = "Reindex a given model."
args = 'app.Model'
def handle(self, *args, **options):
if not args:
@maxim
maxim / rails_load_path_tips.md
Last active April 13, 2023 13:28
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@n-kb
n-kb / owl2django.py
Last active December 19, 2015 18:28
This simple script roughly converts an OWL file created by Protégé into a models.py file to be used with Neo4Django. Comments/improvements very welcome!
from lxml import etree
# This string will contain the models.py file
modelsContents = "from neo4django.db import models\n\n"
# Enter the name of the OWL file to parse
# The relationships in the file should always start with has...
owlFile = "ontology.owl"
# Gives the ontology URI. Only needed for documentation purposes
@bramd
bramd / models.py
Created April 25, 2013 15:27
An example how to expose nodes through a custom Cypher query as a queryset. This assumes you are using Neo4Django. We have a Place (or point of interest) that has an address. The address is located in a city, is located in a state, is located in a country etc. For a given node we would like to retrieve the list of places in that node. Examples: …
from neo4django.db import connections
from neo4django.db.models.script_utils import LazyNode
from neo4django.db import models
from neo4django.db.models.manager import NodeModelManager
from django.utils.translation import ugettext_lazy as _
class Country(models.NodeModel):
code = models.StringProperty(verbose_name=_('Country code'), max_length=2, indexed=True)
name = models.StringProperty(verbose_name=_('Name'))
@gorsuch
gorsuch / gist:1418850
Created December 1, 2011 18:37
clojure uuid
(defn uuid [] (str (java.util.UUID/randomUUID)))
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')