Skip to content

Instantly share code, notes, and snippets.

let session = URLSession.shared
let task = session.dataTask(with: request as URLRequest, completionHandler: {(data, response, error) in
if (error == nil) {
do {
let json = try! JSONSerialization.jsonObject(with: data!, options: [])
let books = Mapper<BookResponse>.mapArray(json) // ERROR: Argument labels '(_:)' do not match any available overloads
if let jsonResult = try JSONSerialization.jsonObject(with: data!, options: []) as? NSDictionary {
import datetime
from uuid import uuid4
from sqlalchemy import Column, Unicode, String, Integer, ForeignKey, UnicodeText
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import relationship
from websauna.system.model.meta import Base
from websauna.system.model.columns import UTCDateTime
folder/f976c2d2-31c1-4e0c-977f-b997eba57c2c
[{
TrackNameInEnglish = "01 Mateo 01";
TrackNameInSpanish = "01 Mateo 01";
TrackPath = "/media/tracks/tracks_all/cf70554c-8354-443c-93a6-ae88a892bb39/e95acdeb-b812-486f-a91e-3c15442c4_8bFILXo.mp3";
id = "9a45ad00-f3af-4830-a57e-834d588da19a";
trackFrombucket = "https://s3-us-west-2.amazonaws.com/rvg-tracks-cdn/e95acdeb-b812-486f-a91e-3c15442c4_8bFILXo.mp3";
}, {
TrackNameInEnglish = "01 Mateo 02";
# pserve and command line configuration for a local development machine
[includes]
include_ini_files =
resource://websauna/conf/development.ini
resource://kjvrvg/conf/base.ini
resource://websauna/conf/base.ini
[app:main]
websauna.site_id = kjvrvg_dev
@mazz
mazz / views.py
Last active March 25, 2017 20:24
from cornice.service import Service
import jwt
from jwt import ExpiredSignatureError
import pem
from ccxact.token.generator import TokenGenerator
from ccxact.token.validator import TokenValidator
# Configure view named home at path / using a template ccxact/home.html
@simple_route("/", route_name="home", renderer='ccxact/home.html')
@mazz
mazz / gist:cdc1a4fbaecfb32c1d4dfa20b8124bb7
Created March 5, 2017 22:18
myapp playbook pg (psycopg2.OperationalError) fe_sendauth: no password supplied
fatal: [myapp_production]: FAILED! => {"changed": true,
"cmd": ["/srv/pyramid/myapp/venv/bin/ws-alembic",
"-c",
"/srv/pyramid/myapp/myapp/conf/generated.ini",
"upgrade",
"head"],
"delta": "0:00:02.786108",
"end": "2017-03-05 16:33:24.749291",
"failed": true,
"rc": 1,
* start ssh-agent on server *
* generate priv and pub rsa key in ~/.ssh/ *
* add rsakey.pub to bitbucket.org *
on server:
maz@sidha:~/.ssh$ ssh -T [email protected]
The authenticity of host 'bitbucket.org (2401:1d80:1010::150)' can't be established.
RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,2401:1d80:1010::150' (RSA) to the list of known hosts.
@mazz
mazz / gist:7cf208041e5c5b2356936480e1d9df48
Created February 25, 2017 21:31
The Ansible server connection did not have SSH agent forwarding enabled or you have become_user\\:root in your playbook which you should not have
~/src/ansible/websauna.ansible (master ✔) ᐅ ansible-playbook -i hosts.ini playbook-myapp.yml
PLAY [myapp_development] *******************************************************
TASK [setup] *******************************************************************
ok: [myapp_development]
TASK [include_vars] ************************************************************
ok: [myapp_development]
~/src/ansible/websauna.ansible (master ✔) ᐅ ansible-playbook -i hosts.ini playbook-myapp.yml -k -K -s
SSH password:
SUDO password[defaults to SSH password]:
PLAY [myapp_development] *******************************************************
TASK [setup] *******************************************************************
ok: [myapp_development]
TASK [include_vars] ************************************************************
"""App entry point and configuration."""
import pem
from pyramid.authorization import ACLAuthorizationPolicy
import websauna.system
class Initializer(websauna.system.Initializer):
"""An initialization configuration used for starting xact.
Override parent class methods to customize application behavior.