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
import numpy as np | |
class Annealer(): | |
def __init__(self, step_function, energy_function): | |
self.step_function = step_function | |
self.energy_function = energy_function | |
def run( | |
self, state, temperature, room_temperature, cooling_factor |
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
# Countries of the world exercise. | |
# download cow.txt and put it in your project directory | |
import pandas as pd | |
def closes_to(data, abbreviated_name): | |
country = data[data.ISO3166A2 == abbreviated_name] | |
latitude = country.BGNc_latitude.values[0] | |
longitude = country.BGNc_longitude.values[0] | |
data['distance_from_{}'.format(abbreviated_name)] = \ |
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
t9 = {'a': '2', | |
'b': '22', | |
'c': '222', | |
'd': '3', | |
'e': '33', | |
'f': '333', | |
'g': '4', | |
'h': '44', | |
'i': '444', | |
'j': '5', |
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 find_items_to_buy(credit, items): | |
for i, item in enumerate(items[:-1]): | |
another = credit - item | |
if another in items[i + 1:]: | |
return i, items[i + 1:].index(another) + i + 1 | |
assert (1, 2) == find_items_to_buy(100, [5, 75, 25]) | |
assert (0, 3) == find_items_to_buy(200, [150, 24, 79, 50, 88, 345, 3]) | |
assert (3, 4) == find_items_to_buy(8, [2, 1, 9, 4, 4, 56, 90, 3]) |
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
SD card setup | |
============= | |
http://elinux.org/RPi_Easy_SD_Card_Setup | |
Headless first time run (without router) | |
======================================== | |
http://pihw.wordpress.com/guides/direct-network-connection/ | |
sudo ifconfig eth0 169.254.0.1 | |
ifconfig eth0 |
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 index(request): | |
return HttpResponse('in index') | |
def detail(request, item_pk): | |
return HttpResponse('in detail. pk = {}'.format(item_pk)) | |
def comment(request, item_pk): | |
return HttpResponse('in comment. pk = {}'.format(item_pk)) |
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' %} | |
{% block content %} | |
<h1 class="text-center">Add new comment for: {{ news_item.title }}</h1> | |
<form method="POST"> | |
{% csrf_token %} | |
<input type="text" class="form-control" placeholder="Write your comment here" name="content"> | |
<input type="submit" class="form-control"> | |
</form> |
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 A1(object): | |
def __init__(self): | |
print('A1>') | |
super(A1, self).__init__() | |
class B1(A1): | |
def __init__(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 Tkinter import * | |
class StocksGuiBuilder(object): | |
class Stock(object): | |
MODES = ('Up', 'Down', 'Unchanged') | |
def __init__(self, parent): |
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
import java.util.List; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
class Exercise { | |
public List<String> ex; | |
public Exercise(String[] input) { | |
ex = new ArrayList<String>(Arrays.asList(input)); |
OlderNewer