Skip to content

Instantly share code, notes, and snippets.

View Kobold's full-sized avatar

Andy Kish Kobold

  • TenantBase
  • Santa Monica, CA
View GitHub Profile
from django import template
from django.core.urlresolvers import reverse
def do_if_active_url(parser, token):
try:
tag_name, request, urls = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError, ("%r tag requires exactly two arguments, received" %
token.contents.split()[0], len(token.contents.split()[0]))
if not (urls[0] == urls[-1] and urls[0] in ('"', "'")):
@panuta
panuta / gist:1897940
Created February 24, 2012 05:14
Generate a document thumbnail (doc, xls, ppt and openoffice formats) in Ubuntu Server 10.04
  1. Install OpenOffice headless package

    $ sudo apt-get install openoffice.org-headless openoffice.org-java-common openoffice.org-writer openoffice.org-calc openoffice.org-impress
    
  2. Install UNO python library

$ sudo apt-get install python-uno unoconv

@rnapier
rnapier / fix-xcode
Last active March 18, 2022 01:17
Links Xcode SDKs from the /SDKs directory (which you maintain yourself)
#!/usr/bin/python
# fix-xcode
# Rob Napier <robnapier@gmail.com>
# Script to link in all your old SDKs every time you upgrade Xcode
# Create a directory called /SDKs (or modify source_path).
# Under it, put all the platform directories:
# MacOSX.platform iPhoneOS.platform iPhoneSimulator.platform
# Under those, store the SDKs:
@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@brian-mann
brian-mann / FadeTransitionRegion.js
Created October 24, 2012 16:28
Allows jQuery animation transitions between marionette regions
var FadeTransitionRegion = Backbone.Marionette.Region.extend({
show: function(view){
this.ensureEl();
view.render();
this.close(function() {
if (this.currentView && this.currentView !== view) { return; }
this.currentView = view;
@thisboyiscrazy
thisboyiscrazy / django-login-required-template-view.py
Created March 5, 2013 16:01
A TemplateView mixed with a Login Required view
from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from django.views.generic import TemplateView
class LoginRequiredMixin(object):
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(LoginRequiredMixin, self).dispatch(*args, **kwargs)
class LoginRequiredTemplateView(LoginRequiredMixin,TemplateView):
@SzymonPobiega
SzymonPobiega / gist:5220595
Last active April 25, 2024 17:19
DDD/CQRS/ES/Architecture videos

If you have two days to learn the very basics of modelling, Domain-Driven Design, CQRS and Event Sourcing, here's what you should do:

In the evenings read the [Domain-Driven Design Quickly Minibook]{http://www.infoq.com/minibooks/domain-driven-design-quickly}. During the day watch following great videos (in this order):

  1. Eric Evans' [What I've learned about DDD since the book]{http://www.infoq.com/presentations/ddd-eric-evans}
  2. Eric Evans' [Strategic Design - Responsibility Traps]{http://www.infoq.com/presentations/design-strategic-eric-evans}
  3. Udi Dahan's [Avoid a Failed SOA: Business & Autonomous Components to the Rescue]{http://www.infoq.com/presentations/SOA-Business-Autonomous-Components}
  4. Udi Dahan's [Command-Query Responsibility Segregation]{http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation}
  5. Greg Young's [Unshackle Your Domain]{http://www.infoq.com/presentations/greg-young-unshackle-qcon08}
  6. Eric Evans' [Acknowledging CAP at the Root -- in the Domain Model]{ht
@stonehippo
stonehippo / RPi-Dashing-howto.md
Last active October 6, 2021 13:52
Setting up a Raspberry Pi as a dashboard server with Dashing

Setting up a Raspberry Pi as a dashboard server with Dashing

Why the heck did I do this?

I wanted to set up one of my Raspberry Pi's as a data dashboard, pushing sensor data to a web interface that's easy to digest. I decided to use Shopify's Dashing framework. Dashing is based on Sinatra, and is pretty lightweight.

Dashing does require Ruby 1.9.3 to run. In addition, it makes use of the execjs gem, which needs to have a working Javascript interpreter available. Originally, I tried to get therubyracer working, but decided to switch over to Node.js when I ran into roadblocks compiling V8.

One warning: The RPi is a very slow system compared with modern multi-core x86-style systems. It's pretty robust, but compiling all this complex software taxes the system quite a bit. Expect that it's going to take at least half a day to get everything going.

@SalGnt
SalGnt / force-rgb-mode-in-mac-os-x-to-fix-the-picture-quality-of-an-external-monitor.md
Last active July 5, 2023 19:30
Force RGB mode in Mac OS X to fix the picture quality of an external monitor.

Force RGB mode in Mac OS X to fix the picture quality of an external monitor (Original)

Update: I have heard that 10.8.3 has solved this problem for some people, so I rolled back my changes and installed the update. No change on my monitor. Nevertheless, it’d be a good idea to update OS X before trying this, since it may fix the issues with your particular hardware.

I recently bought a MacBook Pro (with ‘Retina’ screen), but when I hooked it up to my Dell U2410 monitor via HDMI cable I was shocked by the poor picture quality. The contrast was all wrong and text was misshapen. No amount of calibration in the monitor or software would fix it.

Short answer: OS X thinks my monitor is a TV, and is using the YCbCr colour space rather than RGB. I had to override an EDID setting to force the RGB colour space, and it is now working correctly.

Long answer: I haven’t owned a Mac for a while and h

@icub3d
icub3d / main.go
Last active October 11, 2016 14:59
An example of using doozer to keep track of your groupcache instances. If you want to run it yourself, you'll want to: go get github.com/golang/groupcache go get github.com/ha/doozer
package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"github.com/golang/groupcache"
"github.com/ha/doozer"
"io"