Skip to content

Instantly share code, notes, and snippets.

function cdgem {
bundle="$(bundle show $1)"
gem="$(gem which $1 2>/dev/null | grep '^/')"
for gem_dir in "${bundle}" "${gem:h}"; do
if [[ -d "${gem_dir}" ]]; then
cd "${gem_dir}"
return
fi
done
print 'not found'
@slumos
slumos / return-block.rb
Created July 8, 2015 21:55
Explicit returns can improve clarity
def all
return ld.get_features.map do |feature|
new_feature = {}
[:key, :name, :on].each do |k|
new_feature[k] = feature[k]
end
new_feature[:id] = new_feature[:key]
new_feature
end
end
#! /bin/bash
# Control an xterm window
name=`basename $0`
bq='`'
eq="'"
usage ()
{
#! /bin/sh
SOCK_DIR=${HOME}/.ssh
SOCK_NAME=auth.sock
if [ -n "$SSH_AUTH_SOCK" ]; then
[ -d "$SOCK_DIR" ] || mkdir -m 0700 "$SOCK_DIR"
ln -nfs "$SSH_AUTH_SOCK" "$SOCK_DIR/$SOCK_NAME"
export SSH_AUTH_SOCK="$SOCK_DIR/$SOCK_NAME"
fi
#screen_command='screen -xRR'
screen_command="tmux attach"

Keybase proof

I hereby claim:

  • I am slumos on github.
  • I am slumos (https://keybase.io/slumos) on keybase.
  • I have a public key ASBdn-52LO1HzxXYtc6_MTvDuuXYOy6oaj1KOQv5fMBsFAo

To claim this, I am signing this object:

#! /usr/bin/env zsh
echo \\a
title=Ding
message="${*:-DONE}"
function is_available {
command -v $* >& /dev/null
}
%{remote_ip} says %{http_code}
%{content_type}
downloaded %{size_download} bytes at %{download_speed} bytes/s
DNS lookup: %{time_namelookup}
TCP connect: %{time_connect}
SSL connect: %{time_appconnect}
Time to FB: %{time_starttransfer}
Total: %{time_total}
function l {
if [[ ! -t 0 ]]; then
# stdin is not connected to a tty
pager -
elif [[ $# -eq 1 && -f "$1" ]]; then
# single argument names a file
pager "$1"
else
ls -CFL $*
fi
@slumos
slumos / osx-for-hackers.sh
Created May 28, 2017 04:17 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@slumos
slumos / fssh.sh
Created September 21, 2017 21:12
21Sep 14:10:47 ~ 0% which fssh
fssh () {
hosts="$1 $(getent hosts $1)"
if [ -x /usr/bin/dscl ]
then
hosts="$hosts $(dscl . read /Hosts/$1 | awk '/^IPAddress/ { print $2 }')"
fi
for h in ${=hosts}
do
ssh-keygen -R $h >&/dev/null