Skip to content

Instantly share code, notes, and snippets.

Avatar
😎

Brock Angelo brock

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

A collapsible section with markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@brock
brock / __init__.py
Created Dec 26, 2018 — forked from theorm/__init__.py
Pluggable API using Flask MethodView.
View __init__.py
# -*- 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 Sep 4, 2018 — forked from originell/extract_exceptions.py
Python Traceback Extractor from text/log files.
View extract_exceptions.py
"""
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 Jul 21, 2018
Log UPS & FedEx delivery times from Gmail to a Google Spreadsheet
View logFedEx.js
// 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 Apr 19, 2017
GRU: Git Remove Untracked Files
View gru
#!/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
Life Pro Tip for using Rsync
View README.md
  • 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 Jul 31, 2017
Play Framework Template Cheat-Sheet
View play-framework-templates.md

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 Oct 23, 2015
Using Knex to remove null values from a Postgres JSON column
View delete-nulls-from-postgres.js
// 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 Feb 22, 2021
Exporting and Importing Postgres Databases using gzip
View psql-with-gzip-cheatsheet.sh
# 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 Oct 14, 2015 — forked from lucdew/json_postgres.js
Example of json document storage in postgresql and querying (with knex.js)
View json_postgres.js
var connectionString = 'postgres://localhost:5432/postgres';
var Promise=require('bluebird');
var knex = require('knex')({
client: 'pg',
connection: {
user: 'postgres',
database: 'postgres',
port: 5432,