Skip to content

Instantly share code, notes, and snippets.

View brock's full-sized avatar
😎

Brock Angelo brock

😎
View GitHub Profile
@brock
brock / markdown-details-collapsible.md
Created July 17, 2019 19:48 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section with markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@brock
brock / __init__.py
Created December 26, 2018 15:50 — forked from theorm/__init__.py
Pluggable API using Flask MethodView.
# -*- 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__ = [
@brock
brock / extract_exceptions.py
Created September 4, 2018 15:05 — forked from originell/extract_exceptions.py
Python Traceback Extractor from text/log files.
"""
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
@brock
brock / logFedEx.js
Last active July 21, 2018 22:37
Log UPS & FedEx delivery times from Gmail to a Google Spreadsheet
// 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');
@brock
brock / gru
Created April 19, 2017 20:59
GRU: Git Remove Untracked Files
#!/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 ??)
@brock
brock / README.md
Last active May 10, 2016 18:26
Life Pro Tip for using Rsync
  • 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

@brock
brock / play-framework-templates.md
Last active July 31, 2017 12:58
Play Framework Template Cheat-Sheet

Play Framework

Cheat Sheet for View Template Variables

Inside of a file like index.scala.html, you may want to get or set variables between Scala and JavaScript. Here are some examples.

set a scala variable

@test = { "something" }

set a scala variable by evaluating a scala expression (this example would return true if logged in)

@test = @{ 
@brock
brock / delete-nulls-from-postgres.js
Last active October 23, 2015 23:29
Using Knex to remove null values from a Postgres JSON column
// 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});
@brock
brock / psql-with-gzip-cheatsheet.sh
Last active April 10, 2024 10:53
Exporting and Importing Postgres Databases using gzip
# 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
@brock
brock / json_postgres.js
Created October 14, 2015 14:52 — forked from lucdew/json_postgres.js
Example of json document storage in postgresql and querying (with knex.js)
var connectionString = 'postgres://localhost:5432/postgres';
var Promise=require('bluebird');
var knex = require('knex')({
client: 'pg',
connection: {
user: 'postgres',
database: 'postgres',
port: 5432,