This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using MongoDB in golang with mgo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"testing" | |
) | |
func assertEqual(t *testing.T, a interface{}, b interface{}, message string) { | |
if a == b { | |
return |