- Python 3
- Pip 3
$ brew install python3
# -*- coding: utf-8 -*- | |
from django.contrib import admin | |
from django.db.models import Q | |
from django.utils.translation import gettext_lazy as _ | |
from django.contrib.admin.utils import reverse_field_path | |
from django.contrib.admin.utils import get_model_from_relation | |
from django.core.exceptions import ValidationError | |
from django.contrib.admin.options import IncorrectLookupParameters |
import React from 'react' | |
import { BrowserRouter as Router, Switch } from 'react-router-dom' | |
import routes from './routes' | |
import FancyRoute from './components/tools/FancyRoute' | |
const App = props => | |
<Router> | |
<Switch> | |
{routes.map((route, i) => | |
<FancyRoute key={i} {...route} /> |
krace@hotbox /m/u/code> cat json_pg.py | |
import psycopg2 | |
def run(stmt): | |
cur = psycopg2.connect(database='test', user='postgres', password='password', host='localhost').cursor() | |
cur.execute(stmt) | |
result = cur.fetchall() | |
print(list(result)) |
/** | |
* Basic example to pass values between parent and child components in React | |
* Seems to be in line with this | |
* http://stackoverflow.com/questions/24147331/react-the-right-way-to-pass-form-element-state-to-sibling-parent-elements | |
* Now I have the state in parent and child. Is that good or bad? Why would I need it in child? | |
* Could probably take that out | |
* */ | |
class Parent extends React.Component { | |
constructor(props) { | |
super(props); |
First, check your current config (example output in homebrew.mxcl.postgresql.plist.xml
lower down in this gist):
cat ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Most importantly, note the -D /usr/local/var/postgres
argument.
Second, shut down your current PostgreSQL.
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
import boto3 | |
import logging | |
#setup simple logging for INFO | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) | |
#define the connection | |
ec2 = boto3.resource('ec2') |
Cities1 Birmingham Boston Buffalo Chicago Cleveland Dallas Denver Detroit El Paso Houston Indianapolis Kansas City Los Angeles Louisville Memphis Miami Minneapolis New Orleans New York Omaha Philadelphia Phoenix Pittsburgh St. Louis Salt Lake City San Francisco Seattle Washington | |
Birmingham, Ala. — 1194 947 657 734 653 1318 754 1278 692 492 703 2078 378 249 777 1067 347 983 907 894 1680 792 508 1805 2385 2612 751 | |
Boston, Mass. 1194 — 457 983 639 1815 1991 702 2358 1886 940 1427 3036 996 1345 1539 1402 1541 213 1458 304 2664 597 1179 2425 3179 3043 440 | |
Buffalo, N.Y. 947 457 — 536 192 1387 1561 252 1928 1532 510 997 2606 571 965 1445 955 1294 436 1011 383 2234 219 749 1978 2732 2596 386 | |
Chicago, Ill. 657 983 536 — 344 931 1050 279 1439 1092 189 503 2112 305 546 1390 411 947 840 493 758 1729 457 293 1458 2212 2052 695 | |
Cleveland, Ohio 734 639 192 344 — 1205 1369 175 1746 1358 318 815 2424 379 773 1325 763 1102 514 819 432 2052 131 567 1786 2540 2404 369 | |
Dallas, Tex. 653 1815 1387 931 1205 — 801 1167 625 242 877 5 |
# YOU MAY WANT TO CHECK THIS OUT: https://github.com/douglasmiranda/ddpt/blob/master/{{cookiecutter.django_project_name}}/{{cookiecutter.django_project_name}}/config/local.py | |
# If you don't do this you will have to add the host IP in INTERNAL_IPS = ('127.0.0.1',) | |
# And it will change, then you will have to change INTERNAL_IPS again. | |
def show_toolbar(request): | |
if request.is_ajax(): | |
return False | |
return True |
import UIKit | |
// Notes: | |
// - You must explicitly weak link to UIKit to support iOS 7 | |
// - Action sheets on iOS 7 only show a title | |
func showAlert(viewController: UIViewController, style: UIAlertControllerStyle = .Alert, title: String? = nil, message: String? = nil, sourceView: UIView? = nil, completion: (() -> ())? = nil, buttons: (UIAlertActionStyle, String, (() -> ())?)...) { | |
if (NSClassFromString("UIAlertController") != nil) { | |
// iOS 8+ |