Skip to content

Instantly share code, notes, and snippets.

Allen Fair afair

Block or report user

Report or block afair

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@afair
afair / time-count
Last active Jul 31, 2019
Takes (log) lines with ISO timestamp at start, counts by year/month/day/hour/minute(default)/second. Useful for log analysis counts, like "uniq -c" for time periods.
View time-count
#!/usr/bin/env perl
################################################################################
# time-count : Counts log lines per time (number of chars of timestamp)`
# Takes (log) lines with timestamp near the start, looking for:
# * ISO/ISO-8601 : yyyy-mm-dd.hh:mm:ss
# * Common Log Format: [dd/mmm/yyyy:hh:mm:ss -zzzz]
# * Unix epoch : 1521458735.901159500
# counts by year/month/day/hour/minute(default)/second.
# Useful for log analysis counts, like "uniq -c" for time periods.
# Intended for use as a Unix command taking its input as a pipe.
@afair
afair / et-25k-songs.txt
Created Feb 11, 2019
MagicSing ET-25K Song Database, normalized for search
View et-25k-songs.txt
?? Title Artist
07992 Ah Doo Doo Doo Willie Revillame
07993 Bilog Ang Mundo Manny Pacquiao
07994 Boom Tarat Tarat Willie Revillame
07995 Champion Sa Kantahan Manny Pacquiao
07996 Hephep Hooray (Happy Birthday) Willie Revillame
07997 Ikaw At Ako Manny Pacquiao
07998 Laban Nating Lahat Ito Manny Pacquiao
07999 Panalo Ka Sa Puso Ko (Extreme Jingle) Sarah Geronimo
08000 Para Sa 'yo Ang Laban Na 'to Manny Pacquiao
@afair
afair / pgbackup
Last active Apr 8, 2019
Simple PostgreSQL pg_backup/pg_restore wrapper for multi-job processing. Not that generic, but does the hard work!
View pgbackup
#!/usr/bin/env bash
################################################################################
# pgbackup - Run without arguments for help.
# - Wrapper for PG backup/restore utilities
# (C) 2018 Allen Fair. All rights reserved.
################################################################################
# Use ENV Variables to override these defaults
user=${PGUSER-$USER}
@afair
afair / http_request.php
Last active Aug 7, 2018
PHP Function to make a remote HTTP request (POST, Authentication, API, Files, etc.) and returns the response
View http_request.php
<?php
/**
* Makes a remote HTTP request and returns the response.
*
* @author Allen Fair <allen.fair@gmail.com>
* @copyright 2018 Allen Fair
* @license https://opensource.org/licenses/MIT MIT
*
* @param string $url The full URL endpoint: "https://example.com/endpoint"
* @param array $opt An Associative Array of extended request options
@afair
afair / vimdiffmergetool.md
Last active May 21, 2019
Merge/Rebase with git mergetool vimdiff usage
View vimdiffmergetool.md

Using 'vimdiff' as your git mergetool

.vimrc

" vimdiff
if &diff
  map <silent> <leader>1 :diffget LOCAL<CR>
  map <silent> <leader>2 :diffget BASE<CR>
  map <silent> <leader>3 :diffget REMOTE<CR>
  map <silent> <leader>u :diffupdate<CR>
  map <silent> <leader>s :wqall<CR>
@afair
afair / hackintosh3.md
Last active May 14, 2019
Hackintosh #3 [2018]
View hackintosh3.md

Hackintosh #3 (2018)

Build

  • Corsair Carbide 200R Windowed Compact ATX Case
  • Corsair CX Series CX750M 750 Watt 80 Plus Bronze ATX Modular Power Supply
  • Gigabyte GA-Z270M-D3H LGA 1151 mATX Intel Motherboard
    • Intel Z270
    • Core i7 / i5 / i3 / Pentium / Celeron (LGA1151)
    • 4x288pin up to 64GB DR4 3866(O.C.)/ 3800(O.C.)/ 3733(O.C.)/ 3666(O.C.)/ 3600(O.C.)/ 3466(O.C.)/ 3400(O.C.)/ 3333(O.C.)/ 3300(O.C.)/ 3200(O.C.)/ 3000(O.C.)/ 2800(O.C.)/ 2666(O.C.)/ 2400(O.C.)/ 2133
    • Realtek ALC892
@afair
afair / issue.rb
Created Dec 4, 2017
Possible AR Polymorphic Association Regression (5.2.0.beta2)?
View issue.rb
# frozen_string_literal: true
# https://raw.githubusercontent.com/rails/rails/master/guides/bug_report_templates/active_record_master.rb
gem "bundler", "< 1.16"
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
@afair
afair / alternate-dot-vim.md
Last active Jul 13, 2017
Create a separate dot-vim configurations for alternate users or re-building your own.
View alternate-dot-vim.md

Manage multiple dot-vim configurations

The final repo is available here.

This technique is useful to:

  • Refresh your vim configuration but keep using the old one until ready to cut over.
  • Give another user (pair programmer) thier own vim configuration on your account
  • Have an alternate configuration for a special purpose
@afair
afair / ZenCode.js
Created Aug 23, 2016
To study the React Redux Starter Kit Tutorial
View ZenCode.js
// https://suspicious.website/2016/04/29/starting-out-with-react-redux-starter-kit/
// ################################################################################
// src/routes/Zen/interfaces/zen.js
/* @flow */
export type ZenObject = {
id: number,
value: string
@afair
afair / vm.sh
Last active Mar 6, 2019
VM command to wrap virtualbox vboxmanage commands
View vm.sh
#!/bin/bash
# install - http://www.unixmen.com/install-oracle-virtualbox-and-manage-it-using-phpvirtualbox-on-ubuntu-15-10-headless-server/
# remoting - http://www.virtualbox.org/manual/ch07.html
# vboxmanage - http://www.virtualbox.org/manual/ch08.html
if [ "$1" = "" ]; then
echo "Usage: vm command vmname args..."
exit
fi
You can’t perform that action at this time.