Skip to content

Instantly share code, notes, and snippets.

@varver
varver / .Title
Created November 29, 2016 21:57 — forked from congjf/.Title
Using MongoDB in golang with mgo
Using MongoDB in golang with mgo
@OdinsPlasmaRifle
OdinsPlasmaRifle / managers.py
Last active February 5, 2024 16:56
Haversine formula in Django using Postgres SQL
from django.db import models, connection
"""
Haversine formula in Django using Postgres SQL
Queries a model for all rows that are within a certain radius (given in meters) of a central point.
The 'location_model' placeholder should be raplaced with the name of the table (full name) that includes a latitude and longitude column.
The latitude and longitude columns should be decimal fields.
@vkotovv
vkotovv / app.py
Created August 20, 2013 14:08
Clear data for all tables via flask-sqlalchemy
def clear_data(session):
meta = db.metadata
for table in reversed(meta.sorted_tables):
print 'Clear table %s' % table
session.execute(table.delete())
session.commit()
@samalba
samalba / main_test.go
Created July 23, 2013 02:50
How to assert values in golang unit tests
package main
import (
"fmt"
"testing"
)
func assertEqual(t *testing.T, a interface{}, b interface{}, message string) {
if a == b {
return