Skip to content

Instantly share code, notes, and snippets.

View brock's full-sized avatar
😎

Brock Angelo brock

😎
View GitHub Profile
@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 / ZSH-Auto-Update-Date.md
Last active June 11, 2018 21:31
Update your ZSH Date in the shell automatically

Update your ZSH date automatically

update-time-automatically

[exec_sh] mLast updated: 2015-01-18

Searching for Files

###Find images in a directory that don't have a DateTimeOriginal###

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

@brock
brock / modulesize.sh
Last active September 7, 2017 15:25
ModuleSize - shows the percentage of storage your node_modules are taking up
#!/bin/bash
ALL=$(du -s | awk '{print $1}');
NODEMODULES=$(find . -type d -depth 1 -name node_modules | xargs du -s | awk '{print $1}' | awk '{sum+=$1} END {print sum}');
DECIMAL=$(awk "BEGIN {printf \"%.2f\", $NODEMODULES/$ALL}")
PERCENT=$(echo "$DECIMAL*100" | bc)
echo "node_modules are using $PERCENT% of space in the current directory."
@brock
brock / mcd.md
Created March 27, 2015 01:37
mcd needs to be a shell built-in function

mcd

I see this code used in so many README files and I always scratch my head...

mkdir myAppName
cd myAppName

This is perhaps the simplest possible function you can write in bash, and should be a built-in function:

@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 / 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 / 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