Skip to content

Instantly share code, notes, and snippets.

View jrief's full-sized avatar

Jacob Rief jrief

View GitHub Profile
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@pfote
pfote / AsyncNotify.py
Created December 5, 2013 12:39
postgres LISTEN/NOTIFY psycopg2/twisted
import psycopg2
import psycopg2.extensions
from select import select
from twisted.internet import threads
class AsyncNotify():
"""
based on http://divillo.com/, adapted to newer psycopg version
Class to trigger a function via PostgreSQL NOTIFY messages.
@Nagyman
Nagyman / workflows-in-django.md
Last active January 27, 2024 08:29
Workflows in Django

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
@miklb
miklb / moonphase.py
Created July 1, 2015 07:12
Calculate Lunar Phase
#!/usr/bin/env python
"""
moonphase.py - Calculate Lunar Phase
Author: Sean B. Palmer, inamidst.com
Cf. http://en.wikipedia.org/wiki/Lunar_phase#Lunar_phase_calculation
"""
import math, decimal, datetime
dec = decimal.Decimal
@gamerxl
gamerxl / excel-formula-parser.pegjs
Last active December 30, 2022 12:31
PEG.js based parser for excel formula. It's only a simple prototype for evaluation. Test online at https://pegjs.org/online
// PEG.js based parser for excel formula.
// Executable on https://pegjs.org/online
{
// Implementation of builtin core functionality and some demo stuff.
// TODO: Remove demo stuff.
const builtinFunctions = {
/**
* Returns a number (Demo function).
* TODO: Remove demo function.