Skip to content

Instantly share code, notes, and snippets.

@j05h
j05h / gitstats.rb
Created November 19, 2019 23:46
Git Stats that developers committed between two dates
#!/usr/bin/env ruby
# Super lame because I'm not even using optparse. Killme.
# gitstats.rb from-date to-date
# Will find the commit stats for all developers on a project within those dates.
# Example:
# gitstats.rb 2019-03-22 2019-04-01
# gets all stats betwee the above dates exclusive.
from = ARGV.shift

Keybase proof

I hereby claim:

  • I am j05h on github.
  • I am j05h (https://keybase.io/j05h) on keybase.
  • I have a public key ASD_v_EDxCewtVXpXod5dkFP97QtiZsec5DC8pxbBkPHLAo

To claim this, I am signing this object:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width"/>
<style>
/**********************************************
* Ink v1.0.5 - Copyright 2013 ZURB Inc *
**********************************************/
/* Client-specific Styles & Reset */
@j05h
j05h / gist:ad71379fb65b8ef69278
Created June 14, 2015 16:13
Stupid simple way of detecting file encoding
def detect_encoding file
result = `file --mime-encoding #{file}`
_, encoding = result.split
if File.exists? file
return encoding unless encoding.nil? || encoding.empty?
end
end
@j05h
j05h / FixKeyboardSettings
Created April 2, 2015 14:24
AppleScript to change the keyboard modifier settings. Yosemite doesn't remember these settings
# AppleScript to change the keyboard modifier settings. Yosemite doesn't remember these
# and reverts whenever you plug in a new keyboard.
# Options on the pane go from bottom to top of the window (at least in this case)
# If you use this, load it up in to Script Editor, run it. Assuming it works,
# Export to an application and save to the desktop. From there, you can execute
#x-help-script://com.apple.machelp/scpt/OpnPrefsBndID.scpt?com.apple.preference.keyboard
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
@j05h
j05h / howManyMeetings.scpt
Last active August 29, 2015 14:05
How many meetings were scheduled on your calendar in the last month?
(*
Determine how much time you spend in meetings over a month
*)
on sortEvents(theList)
-- if there's only one event then it is, by definition, sorted
if (count theList) = 1 then return theList
-- if we get here we have more than 2 items, so iterate through them
set sorted to false -- assume they're out of order
repeat until sorted = true
@j05h
j05h / whitespace.vim
Created August 30, 2013 13:55
Strip trailing whitespace on VIM save
"""""""""""""""" Functions """"""""""""""""
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
@j05h
j05h / gist:5309643
Created April 4, 2013 11:28
If you want to generate a hosts file with OpenStack nova, this little gem should set you straight. The last little bit pulls out any instances which don't have a private IP. In this case, we're assuming that our subnet begins with '10'. Feel free to change for whatever else you like.
$ nova list | awk 'BEGIN {FS="[|=,]"} {gsub(/[[:space:]]+/,"",$3);gsub(/[[:space:]]+/,"",$6); print $6" "$3}' | tail -n +3 | grep 10
10.1.1.141 Server2592
10.1.1.136 Server2598
10.1.1.140 Server2599
10.1.1.138 Server2600
10.1.1.143 Server2601
10.1.1.147 Server2602
@j05h
j05h / gist:3803998
Created September 29, 2012 13:22 — forked from retr0h/gist:3803315
Array.new.tap do |a|
# Break the directory into pieces for recursive creation.
# ["/opt", "MegaRAID", "MegaCli"]
parts = node['megaraidcli']['dir'].scan(/^\/(?:[a-zA-Z]+)|(?:[a-zA-Z]+)/)
parts.each do |parts|
a << parts
directory a.join(::File::SEPARATOR) do
owner "root"
group "root"
@j05h
j05h / gist:3803996
Created September 29, 2012 13:21 — forked from retr0h/gist:3803315
Array.new.tap do |a|
# Break the directory into pieces for recursive creation.
# ["/opt", "MegaRAID", "MegaCli"]
parts = node['megaraidcli']['dir'].scan(/^\/(?:[a-zA-Z]+)|(?:[a-zA-Z]+)/)
parts.each do |parts|
a << parts
directory a.join(::File::SEPARATOR) do
owner "root"
group "root"