Skip to content

Instantly share code, notes, and snippets.

View BrianMehrman's full-sized avatar
🏠
Working from home

Brian Mehrman BrianMehrman

🏠
Working from home
View GitHub Profile
@BrianMehrman
BrianMehrman / BeerSong.rb
Last active December 26, 2015 04:39
Make a Beer Songex. BeerSong.rb 100
limit = ARGV[0].to_i
limit.times {|i| system "say #{limit-i} bottles of beer on the wall, #{limit-i} bottles of beer. Take one down, pass it around, #{limit-(i+1)} bottles of beer on the wall."}
@BrianMehrman
BrianMehrman / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@BrianMehrman
BrianMehrman / git_branch_prompt
Created October 14, 2014 15:58
git branch in bash prompt
# ----------------------------------------------------------------------
# PROMPT
# ----------------------------------------------------------------------
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
}
# ------------------------------------
# Open Browser to URL
# ------------------------------------
unset gd
gdCall(){
unalias gd
open "http://bringvictory.com/"
if [[ "$#" -ge 1 ]]; then
echo "wat"
require 'benchmark/ips'
module ExtraMath
def self.build_math(attr_name)
attr_name = attr_name.to_s
class_eval %Q{
def #{attr_name}(x)
x + x
end
}
@BrianMehrman
BrianMehrman / .screenrc
Created June 12, 2017 01:27 — forked from ddrscott/.screenrc
screenrc with pretty colors
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
@BrianMehrman
BrianMehrman / Vim Capture Find and Replace
Created June 12, 2017 15:34
Every forget to wrap some text in some parenthesis or brackets. Yeah me too.
%s/\(Foo::SubFoo::.*\.name\)/"#{\1}"/g
[
Foo::SubFoo::One,
Foo::SubFoo::Two,
Foo::SubFoo::Three,
Foo::SubFoo::Four
]
# =>
@BrianMehrman
BrianMehrman / timeUtils.js
Last active June 17, 2017 22:36
Code to alter date quickly
const daysAgo = ((days, date) => { let d = date || new Date(); d.setDate(d.getDate() - (days || 1)); return d; });
const hoursAgo = ((hours, date) => { let d = date || new Date(); d.setHours(d.getHours() - (hours || 1)); return d; });
const mintuesAgo = ((mins, date) => { let d = date || new Date(); d.setMinutes(d.getMinutes() - (mins || 1)); return d; });
@BrianMehrman
BrianMehrman / TransisPropParser.rb
Created January 17, 2018 18:02
scans a JS file using TransisJS for prop dependencies
#!/usr/bin/env ruby
require 'pry'
class PropParser
HEX = %w(8 9 A B C D E F)
attr_reader :colors
def self.execute(source_file, out_file)
CREATE USER postgres;
SELECT rolname FROM pg_roles;
ALTER USER postgres WITH CREATEUSER;