Skip to content

Instantly share code, notes, and snippets.

View philoserf's full-sized avatar
Remote and happy

Mark Ayers philoserf

Remote and happy
View GitHub Profile
@fcrespo82
fcrespo82 / .bash_completion
Last active August 29, 2015 13:57
A shell completion for Brett Terpstra's doing command line utility http://brettterpstra.com/projects/doing/
_doing()
{
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(doing help -c)" -- $cur) )
}
complete -F _doing doing
@KirkMunro
KirkMunro / HackingCommandHistory.ps1
Last active August 29, 2015 14:07
Hacking PowerShell command history
# IMPORTANT NOTE: This hack has evolved, and HistoryPx is now a full PowerShell module
# that is hosted on GitHub and can be found here: github.com/KirkMunro/HistoryPx
# First set up some interesting hacks
New-Module -Name HistoryPx -ScriptBlock {
$PSModule = $ExecutionContext.SessionState.Module
$global:__ = $null
$global:MaximumDetailedHistoryCount = 50
$global:PSDefaultParameterValues['Out-Default:OutVariable'] = 'global:__'
$commandHistory = [ordered]@{}
@phiggins
phiggins / benchmark_append.rb
Created October 22, 2014 03:20
What is the fastest way to add one thing to an array without mutating the array?
require 'benchmark/ips'
a = (0..10).to_a
Benchmark.ips do |x|
x.report("push") { a.dup.push(100) }
x.report("shovel") { a.dup << 100 }
x.report("concat") { a.dup.concat([100]) }
x.report("+") { a + [100] }
x.report("unshift") { a.dup.unshift(100) }
anonymous
anonymous / image_size.rb
Created June 16, 2012 14:09
Nanoc filter that computes image dimensions and injects height and width attributes into img tags for much faster and smoother image loading in browsers
# vim: set ts=2 sw=2 et ai ft=ruby:
# Idea from here:
# http://userprimary.net/posts/2011/01/10/optimizing-nanoc-based-websites/
# Also uses code from other filters that are shipped with Nanoc itself.
#
# Implementation enhanced by Pascal Bleser <loki@fosdem.org>,
# under either GPL2 (GNU General Public License) or ASL2.1 (Apache Software License)
# or BSD-3-Clause, as you wish (short version: do whatever you want with it ;)).
#
anonymous
anonymous / gist:8075952
Created December 21, 2013 22:30
Tags files and directories per Brett Terpstra's approach.
#!/usr/bin/env ruby
def package?(file)
results = `mdls -name kMDItemContentTypeTree "#{file}" | grep com.apple.package`
results.length > 0
end
base = ARGV[0]
if !base
script = File.basename("#{__FILE__}")
@craigeley
craigeley / sifttter.rb
Last active July 23, 2018 16:37
This script looks for text files in a specific folder that include completed tasks ('@done') and timestamps, and then collects them into a daily log for the Day One journaling application. It works especially well when it's connected to IFTTT. See more details at http://craigeley.com/tagged/sifttter
#!/usr/bin/ruby
# SIFTTTER 1.5: An IFTTT-to-Day One Logger by Craig Eley 2014 <http://craigeley.com>
# Based on tp-dailylog.rb by Brett Terpstra 2012 <http://brettterpstra.com>
# Multiple Date Function by Paul Hayes 2014 <http://paulrhayes.com>
#
# Notes:
# * Uses `mdfind` to locate a specific folder of IFTTT-generated text files changed in the last day
# * The location of your folder should be hardcoded in line 67, and the location of your Day One in line 66
# * Scans leading timestamps in each line matching the selected dates
# * Does not alter text files in any way
@ttscoff
ttscoff / lazylink.rb
Created October 19, 2013 18:56
Marked 2 Preprocessor for "lazy links"
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep -B6 bindings:.*: