Skip to content

Instantly share code, notes, and snippets.

View indirect's full-sized avatar

André Arko indirect

View GitHub Profile
@indirect
indirect / prompt.sh
Last active December 20, 2015 14:49
Bash prompt with exit status, dotfiles git status, git status, and job status.
# Using this file, you prompt looks something like this:
# <exit status> <username color coded with dotfiles git status> <cwd> <git branch or rev-name> <job status> $
# 💙 andre ~/src/bundler/bundler v1.3.0.pre.2~13 👥 $
BLUE='\001\033[0;34m\002'
CYAN='\001\033[0;36m\002'
GREEN='\001\033[0;32m\002'
YELLOW='\001\033[0;33m\002'
RESET='\001\033[0m\002'
@indirect
indirect / gist:6127659
Created August 1, 2013 01:05
Rsync 3 homebrew dupe formula installed via boxen
# Homebrew::tap to get dupes
define homebrew::tap (
$ensure = present,
) {
if $ensure == 'present' {
exec { "homebrew_tap_${name}":
command => "brew tap ${name}",
unless => "brew tap | grep ${name}",
}
@indirect
indirect / app_log.txt
Created July 15, 2013 17:48
heroku ungraceful restart
Jul 15 06:05:43 bundler-api heroku/web.6: Cycling
Jul 15 06:05:48 bundler-api heroku/web.6: Stopping all processes with SIGTERM
Jul 15 06:05:51 bundler-api heroku/web.6: Process exited with status 0
Jul 15 06:05:51 bundler-api heroku/web.6: State changed from up to down
Jul 15 06:05:51 bundler-api heroku/web.6: State changed from down to starting
Jul 15 06:05:53 bundler-api heroku/web.6: Starting process with command `bundle exec puma --include lib --port 57130 --environment production --threads 0:32`
Jul 15 06:05:56 bundler-api heroku/web.6: State changed from starting to up
@indirect
indirect / remap.pp
Last active December 19, 2015 03:39
Remap capslock to control on all connected keyboards (now with a test to see if it's already done)
$keyboard_ids = 'ioreg -n IOHIDKeyboard -r | grep -E \'VendorID"|ProductID\' | awk \'{ print $4 }\' | paste -s -d\'-\n\' -'
$check = 'xargs -I{} sh -c \'defaults -currentHost read -g "com.apple.keyboard.modifiermapping.{}-0" | grep "Dst = 2" > /dev/null\''
$remap = 'xargs -I{} defaults -currentHost write -g "com.apple.keyboard.modifiermapping.{}-0" -array "<dict><key>HIDKeyboardModifierMappingDst</key><integer>2</integer><key>HIDKeyboardModifierMappingSrc</key><integer>0</integer></dict>"'
exec { 'Remap capslock to control on all keyboards':
command => "${keyboard_ids} | ${remap}",
unless => "${keyboard_ids} | ${check}"
}
@indirect
indirect / child.rb
Created June 14, 2013 18:46
ruby child process with non-buffered output
# give the child process a terminal so output isn't buffered
@master, slave = PTY.open
in_clean_environment do
@pid = ::Process.spawn(
config.env,
%Q(bash -c "#{config.command}"),
:in => slave,
:out => slave,
:err => slave,
:chdir => config.dir,
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
@indirect
indirect / broken-super.txt
Last active December 16, 2015 23:30
defined?(super) on Ruby 2.0.0-p0 is different from 1.9.3-p392
± aa+rm |ruby2 ✗| → bundle exec ruby reduced.rb
This is not nil, it is a PG::Result
#<PG::Result:0x007fb632e778a0 @connection=#<PG::Connection:0x007fb632e7fa28>>
This is a PG::Result on 1.9.3, but it is nil on Ruby 2.0 because defined?(super) returned nil
the value of defined?(super) is: nil
nil
|ruby-2.0.0-p0| Lyra-Heartstrings-5 in ~/workspace/makara
± aa+rm |ruby2 ✗| → rvm use 1.9.3
@indirect
indirect / tmux-named
Created April 25, 2013 17:43
Open multiple tmux sessions connected to the same set of windows
#!/bin/bash
# We need tmux. Obvs.
if [[ -z `which tmux` ]]; then echo "You need tmux first!"; exit 1; fi
# Named variables are much more flexible
name="$1"
# Make sure we got a session name to create or join
[[ -n "$name" ]] || { echo "Usage: tmux-named [SESSION_NAME]"; exit; }
@indirect
indirect / tmux.conf
Created April 25, 2013 17:42
Tmux config with powerline-like status
# change tmux prefix from ⌃b to ⌃t
unbind C-b
set -g prefix C-t
# tell tmux that terminal has 256 colors
set -g default-terminal "screen-256color"
# re-enable pbcopy and pbpaste inside tmux shells
set-option -g default-command "reattach-to-user-namespace -l bash"
@indirect
indirect / fix_mtime.rb
Created April 14, 2013 03:41
Restore the file creation and modification timestamps using the Dropbox API after the Dropbox client app throws them away
#!/usr/bin/env ruby
require 'yaml'
require 'time'
APP_KEY = "your app key"
APP_SECRET = "your app secret"
TOKEN_KEY = nil
TOKEN_SECRET = nil
lib = File.expand_path("../dropbox-sdk/lib", __FILE__)