Skip to content

Instantly share code, notes, and snippets.

View bparks's full-sized avatar

Brian Parks bparks

View GitHub Profile
@bparks
bparks / screenshot.c
Last active December 1, 2019 20:14 — forked from bozdag/taking screenshot in linux with C
This C program takes the whole screenshot of the root window for a given display and saves it in PNG file format.
// Use the following command line to build:
// gcc -o screenshot screenshot.c -lX11 $(pkg-config cairo --cflags --libs)
/*
Grabs a screenshot of the root window.
Usage : ./scr_tool <display> <output file>
Example : ./scr_tool :0 /path/to/output.png
Author: S Bozdag <selcuk.bozdag@gmail.com>
*/
@bparks
bparks / array-gather.js
Created November 19, 2014 17:10
Gather elements in an array into an object where each key is a subset of the original array.
Array.prototype.gather = function(func) {
var fn = func;
if (typeof func == 'string') {
fn = function(item) { return item[func]; };
}
var out = {};
for (var i = 0; i < this.length; i++) {
var item = this[i];
var key = fn(item);
if (typeof out[key] == 'undefined')
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" Info.plist | awk -F. '{print $(NF)}')
assemblyVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" Info.plist)
majorVersion=$(echo $assemblyVersion | awk -F. '{print $1}')
minorVersion=$(echo $assemblyVersion | awk -F. '{ print (length($2) == 0) ? '0' : $2 ; }')
buildVersion=$(echo $assemblyVersion | awk -F. '{ print (length($3) == 0) ? '0' : $3 ; }')
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $majorVersion.$minorVersion.$buildVersion.$buildNumber" Info.plist
@bparks
bparks / fish_prompt
Created September 1, 2014 00:37
My fish_prompt function
set -g __fish_git_prompt_showdirtystate 1
# host:dir[git_info] user$
function fish_prompt
set -l EXIT_STATUS $status
set ORG_COLOR "\e[00m"
set WHITE_BOLD "\[\e[1;37m\]"
set BOLD "\[\e[01;32m\]"
set BLUE "\[\e[01;34m\]"

Keybase proof

I hereby claim:

  • I am bparks on github.
  • I am bparks (https://keybase.io/bparks) on keybase.
  • I have a public key whose fingerprint is ACB0 1131 0644 7B7D 77AB D50E E52F 721C 4377 6B95

To claim this, I am signing this object:

@bparks
bparks / logstash-setup-shorthand.md
Last active August 29, 2015 14:04
Logstash setup shorthand

First, some examples:

rsyslog -> nxlog||json -> logstash

(rsyslog sends to nxlog, which converts to json and sends to logstash)

rsyslog -> logstash

(rsyslog straight to logstash)

Syntax

@bparks
bparks / get_google.js
Created May 9, 2014 14:44
does the same as curl -q https://www.google.com (including doctype)
//get_google.js
//does the same as curl -q https://www.google.com (including doctype)
var page = require('webpage').create();
var url = 'https://www.google.com/';
page.open(url, function (status) {
var source = page.evaluate(function () {
return document.doctype + document.documentElement.outerHTML;