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
class TestNestedListing(TestCase): | |
def setUp(self): | |
super(TestNestedListing, self).setUp() | |
create_basic_categories(self) | |
create_and_place_a_publishable(self) | |
create_and_place_more_publishables(self) | |
list_all_publishables_in_category_by_hour(self, category=self.category_nested_second) | |
list_all_publishables_in_category_by_hour(self, category=self.category_nested) | |
def test_get_listing_with_all_children_in_nested_category(self): |
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
static void detail_window_set_place(Place place) { | |
if (!detail_window) { | |
detail_window = detail_window_init(); | |
} | |
text_layer_set_text(address_layer, place.address); | |
snprintf(distance_buffer, sizeof(distance_buffer), "%d m", place.distance); | |
place_direction = place.direction; | |
text_layer_set_text(distance_layer, distance_buffer); | |
text_layer_set_text(hours_layer, place.hours); | |
write_direction_to_ui(); // computes orientation of arrow |
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
navigator.geolocation.getCurrentPosition(function (position) { | |
xhrRequest('https://api.csas.cz/sandbox/webapi/api/v2/places?radius=500&country=CZ&types=ATM&limit=1&lat=' + position.coords.latitude + '&lng=' + position.coords.longitude, | |
'GET', | |
'7f29f5d5-c9d4-4266-8e6b-3733064da14x', | |
function (status, data) { | |
var response = {}; | |
var json = JSON.parse(data).items[0]; | |
response = { | |
'KEY_DISTANCE': json.distance, | |
'KEY_DIRECTION': computeBearing(position.coords, { // computes azimuth |
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
# http://initd.org/psycopg/docs/advanced.html#asynchronous-notifications | |
import select | |
import psycopg2 | |
import psycopg2.extensions | |
conn = psycopg2.connect(DSN) | |
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) | |
curs = conn.cursor() | |
cursor.execute("LISTEN field_value_change") |
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
// .. omit some imports | |
@Injectable() | |
export class WebSocketService { | |
private sockets: {[name: string]: WrappedSocket} = {}; | |
public connect(url: string, options?: any): WrappedSocket { | |
if (! this.sockets[url]) { | |
this.sockets[url] = new WrappedSocket({url: url, options: options}); | |
} | |
return this.sockets[url]; |
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
// omit imports | |
const SOCKET_URL = '/* @echo SOCKET_URL */'; | |
@Component({ | |
templateUrl: 'dashboard.component.html', | |
styleUrls: ['dashboard.component.less'] | |
}) | |
export class Dashboard implements OnInit, OnDestroy { | |
public mainSocket: WrappedSocket; |
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 flask import Flask | |
from flask_socketio import SocketIO | |
from flask_cors import CORS | |
app = Flask(__name__) | |
app.config.from_envvar('FLASKR_SETTINGS', silent=True) | |
CORS(app) | |
socketio = SocketIO(app) |
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
-- simple table definition, sequence omitted | |
CREATE TABLE field_value ( | |
id integer NOT NULL, | |
value character varying(255) NOT NULL, | |
field character varying(80) | |
); | |
CREATE FUNCTION field_value_notify_change() RETURNS trigger | |
LANGUAGE plpgsql | |
AS $$ |
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 eventlet.hubs import trampoline | |
def start_listening(queue): | |
"""Connects to PgSQL and listens to notifications, inspired by http://initd.org/psycopg/articles/2010/12/01/postgresql-notifications-psycopg2-eventlet/""" | |
if not queue: | |
return | |
connection = psycopg2.connect(DSN) | |
cursor = connection.cursor() | |
cursor.execute("LISTEN field_value_change") |
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
//... | |
// java code | |
//... | |
/** | |
* https://stackoverflow.com/a/38675842 | |
*/ | |
protected boolean isInside(Point p, Polygon polygon) { | |
if (polygon == null) { | |
return false; | |
} |
OlderNewer