This file contains hidden or 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 query(request): | |
latitude_pass = request.GET.get('lat', None) | |
longitude_pass = request.GET.get('long', None) | |
if latitude_pass and longitude_pass: | |
Track( | |
time=datetime.now().isoformat(' '), | |
longitude = longitude_pass, | |
latitude = latitude_pass | |
).save() | |
else: |
This file contains hidden or 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
require 'spec_helper' | |
describe MoviesController do | |
describe 'searching TMDb' do | |
before :each do | |
@fake_results = [mock('movie1'), mock('movie2')] | |
end | |
it 'should call the model method that performs TMDb search' do | |
Movie.should_receive(:find_in_tmdb).with('hardware'). | |
and_return(@fake_results) |
This file contains hidden or 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
protected Boolean doInBackground(final Void... args) { | |
File dbFile = new File(Environment.getDataDirectory() + LOCTABLE_PATH); | |
String state = Environment.getExternalStorageState(); | |
if (Environment.MEDIA_MOUNTED.equals(state)) { | |
File exportDir = new File(Environment.getExternalStorageDirectory(), EXPORT_PATH); | |
if (!exportDir.exists()) { | |
exportDir.mkdirs(); | |
} |
This file contains hidden or 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
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
This file contains hidden or 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
Windows/system32/drivers/etc/host | |
/private/etc/hosts |
This file contains hidden or 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
class List(models.Model): | |
name = models.CharField(max_length=200, unique=True) | |
start_date = models.DateTimeField(verbose_name='date started', | |
default=datetime.now()) | |
slug = models.SlugField(max_length=200, unique=True) | |
progress = models.FloatField(default=0.0, | |
validators=[MaxValueValidator(100.0), | |
MinValueValidator(0.0)]) | |
def __unicode__(self): |
This file contains hidden or 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 math import sqrt, floor | |
def euler12(): | |
D = 0 | |
n = 1 | |
step = 2 | |
while D < 500: | |
n += step | |
step += 1 | |
D = findDivisor(n) |
This file contains hidden or 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
{% extends "base.html" %} | |
{% load url from future %} | |
{% block content %} | |
{% if form.errors %} | |
<p>Your username and password didn't match. Please try again.</p> | |
{% endif %} | |
<form method="post" action="{% url 'django.contrib.auth.views.login' %}"> |
This file contains hidden or 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
CREATE TABLE cities ( | |
city varchar(80) primary key, | |
location point | |
); | |
CREATE TABLE weather ( | |
city varchar(80) references cities(city), | |
temp_lo int, | |
temp_hi int, | |
prcp real, |
This file contains hidden or 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
>>> datetime.now() | |
datetime.datetime(2012, 7, 7, 16, 31, 24, 604514) | |
>>> datetime.today() | |
datetime.datetime(2012, 7, 7, 16, 31, 27, 340110) | |
>>> datetime.utcnow() | |
datetime.datetime(2012, 7, 7, 20, 31, 58, 227201) | |
>>> d = datetime.strptime("2012-07-07 16:00", "%Y-%m-%d %H:%M") | |
>>> d | |
datetime.datetime(2012, 7, 7, 16, 0) | |
>>> datetime.utcnow().timetuple() |
OlderNewer