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
# -*- coding: utf-8 -*- | |
from .bananas import Bananas | |
from .base import the_api | |
the_api.add_url_rule('/bananas', view_func=Bananas.as_view('bananas')) | |
the_api.add_url_rule('/farm/<farm_id>/bananas', view_func=Bananas.as_view('bananas_from_a_farm')) | |
__all__ = [ |
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
""" | |
Extract unique Python-Exceptions with their Traceback from a log/text file. | |
Usage:: | |
python extract_exceptions.py -f logfile.txt | |
Furthermore it supports excluding exceptions you don't want to have:: | |
python extract_exceptions.py -f logfile.txt -e ValueError,AttributeError |
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
// paste this into https://script.google.com | |
// setup a trigger to run on a schedule | |
// create a spreadsheet with these columns: | |
// "Tracking Code",Date,Time,Service,Carrier | |
var GOOGLE_SPREADSHEET_ID = "CHANGE_ME"; | |
function getFedExDeliveries() { | |
// get spreadsheet and tab | |
var ss = SpreadsheetApp.openById(GOOGLE_SPREADSHEET_ID); | |
var sheet = ss.getSheetByName('raw-data'); |
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
#!/bin/bash | |
# gru | |
# Git Remove Untracked (files) | |
# without this script, you have to manually delete files and directories in your git directory if | |
# you want to delete them and they are not tracked by git. | |
# this works as an alias or an executable file | |
# Explanation: | |
# git status -s (display the git status of each file, one line at a time, in short format) | |
# grep '^??' (untracked files will begin with ??) |
- Be me
- forget the exact syntax for using rsync.
- get nested folders by mistake or end up with lots of files in the current directory
- sync files then delete files like 100 times as you try to remember the syntax
- look at the man page and then try again
- get nested folders by mistake or end up with lots of files in the current directory
- sync files then delete files like 100 times as you try to remember the syntax
- finally figure it out
Inside of a file like index.scala.html, you may want to get or set variables between Scala and JavaScript. Here are some examples.
@test = { "something" }
@test = @{
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
// Remove rows from a JSON object where the value is null | |
// use module.export to pass in your postgres connection from knex | |
var pg = require('../index'); | |
var Promise = require('bluebird'); | |
// not included as a "require", but to use streams you'll need to have installed pg-query-stream | |
var Writable = require('stream').Writable; | |
// specify objectMode: true since we'll be passing in a JSON object | |
var ws = Writable({objectMode: true}); |
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
# This is just a cheat sheet: | |
# On production | |
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz | |
# On local | |
scp -C production:~/database.sql.gz | |
dropdb database && createdb database | |
gunzip < database.sql.gz | psql database |
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
var connectionString = 'postgres://localhost:5432/postgres'; | |
var Promise=require('bluebird'); | |
var knex = require('knex')({ | |
client: 'pg', | |
connection: { | |
user: 'postgres', | |
database: 'postgres', | |
port: 5432, |
NewerOlder