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 get_dot(d, dotkey): | |
"""Get value from a dict-like object with dot notation keys""" | |
try: | |
value = d | |
for key in dotkey.split('.'): | |
value = value.get(key, {}) | |
return value if value else None | |
except AttributeError: | |
return None |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
$script = <<SCRIPT | |
set -e | |
if [ ! -f /usr/local/bin/ansible-playbook ] | |
then | |
sudo apt-get update | |
sudo apt-get -y install python-setuptools python-dev | |
sudo easy_install pip |
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
* Python Database API Spec (PEP 243): | |
http://www.python.org/dev/peps/pep-0249/ | |
* PostgreSQL DBAPI2 Implementations: | |
http://wiki.python.org/moin/PostgreSQL | |
* PostgreSQL DBAPI2 Implementations: | |
http://wiki.python.org/moin/MySQL | |
* psycopg2 documentation: |
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 json | |
from flask import Flask, abort | |
app = Flask(__name__) | |
data = { | |
1: {'id': 1} | |
} | |
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
function doQuery(type, user) { | |
var d = $q.defer(); | |
var result = Alert.get({ 'type': type, 'user': user.id }, function() { | |
d.resolve(result); | |
}); | |
return d.promise; | |
} | |
function getAllAlerts(user, alertsConfigured){ | |
var d, |
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 sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, Integer, ForeignKey, String | |
from sqlalchemy.orm import relationship, sessionmaker, aliased | |
from sqlalchemy import create_engine, func | |
DATABASE_URI = 'postgresql://gonz@localhost:5432/ger' | |
engine = create_engine(DATABASE_URI, echo=True) | |
Session = sessionmaker(bind=engine) |
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 get_dot(self, d, dotkey): | |
"""Get value from a dict with dot notation keys""" | |
try: | |
value = d | |
for key in dotkey.split('.'): | |
value = value.get(key) | |
return value | |
except AttributeError: | |
return None |
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
# -*- encoding: utf-8 -*- | |
from datetime import datetime | |
from scrapy.item import Item, Field | |
from scrapy.contrib.loader.processor import TakeFirst | |
from scrapy.contrib.loader import ItemLoader as ScrapyItemLoader | |
from sqlalchemy import DateTime | |
from sqlalchemy.orm import class_mapper | |
from sqlalchemy.orm.properties import ColumnProperty | |
from kickscraper.db.models import Project, User, Location, Category |
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
;; Join next line or join all lines in region | |
(defun smart-join-line () | |
"Join the current line with the line beneath it or all region lines." | |
(interactive) | |
(if (use-region-p) | |
(save-excursion | |
(let ((start-line (line-number-at-pos (region-beginning))) | |
(current-line (line-number-at-pos (region-end)))) | |
(goto-char (region-end)) | |
(while (> current-line start-line) |
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 flask.ext.wtf import (Form, TextField, PasswordField, Required, | |
Email, BooleanField, EqualTo) | |
from prism.models.user import User | |
from sqlalchemy import or_ | |
class RegistrationForm(Form): | |
username = TextField('Username', | |
validators=[Required()]) | |
password = PasswordField('Password', validators=[Required()]) |