Cloudapp, git-open, lyrics & showme scripts.
This commit is contained in:
parent
dede296618
commit
e3bddfe05f
62
bin/cloudapp
Executable file
62
bin/cloudapp
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
#
|
||||||
|
# cloudapp
|
||||||
|
# Zach Holman / @holman
|
||||||
|
#
|
||||||
|
# Uploads a file from the command line to CloudApp, drops it into your
|
||||||
|
# clipboard (on a Mac, at least).
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
#
|
||||||
|
# cloudapp drunk-blake.png
|
||||||
|
#
|
||||||
|
# This requires Aaron Russell's cloudapp_api gem:
|
||||||
|
#
|
||||||
|
# gem install cloudapp_api
|
||||||
|
#
|
||||||
|
# Requires you set your CloudApp credentials in ~/.cloudapp as a simple file of:
|
||||||
|
#
|
||||||
|
# email
|
||||||
|
# password
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
|
|
||||||
|
['json', 'cloudapp_api'].each do |gem|
|
||||||
|
begin
|
||||||
|
require gem
|
||||||
|
rescue LoadError
|
||||||
|
puts "You need to install #{gem}: gem install #{gem}"
|
||||||
|
exit!(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
config_file = "#{ENV['HOME']}/.cloudapp"
|
||||||
|
unless File.exist?(config_file)
|
||||||
|
puts "You need to type your email and password (one per line) into "+
|
||||||
|
"`~/.cloudapp`"
|
||||||
|
exit!(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
email,password = File.read(config_file).split("\n")
|
||||||
|
|
||||||
|
if ARGV[0].nil?
|
||||||
|
puts "You need to specify a file to upload."
|
||||||
|
exit!(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
urls = []
|
||||||
|
ARGV.each do |x|
|
||||||
|
CloudApp.authenticate(email,password)
|
||||||
|
puts "Attempting to upload #{x}"
|
||||||
|
url = CloudApp::Item.create(:upload, {:file => x}).url
|
||||||
|
|
||||||
|
# Say it for good measure.
|
||||||
|
puts "Uploaded #{x} to #{url}"
|
||||||
|
|
||||||
|
# Get the embed link.
|
||||||
|
url = "#{url}/#{ARGV[0].split('/').last}"
|
||||||
|
urls << url
|
||||||
|
end
|
||||||
|
|
||||||
|
# Copy it to your (Mac's) clipboard.
|
||||||
|
`echo '#{urls.join(',')}' | tr -d "\n" | pbcopy`
|
86
bin/git-open
Executable file
86
bin/git-open
Executable file
@ -0,0 +1,86 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
## Usage: git-open FILE [LINE]
|
||||||
|
## Open GitHub file/blob page for FILE on LINE. FILE is the path to the
|
||||||
|
## file on disk; it must exist and be tracked with the current HEAD
|
||||||
|
## revision. LINE is the line number or line number range (e.g., 10-50).
|
||||||
|
##
|
||||||
|
## Open foo/bar.rb in browser:
|
||||||
|
## $ git-open foo/bar.rb
|
||||||
|
##
|
||||||
|
## Open foo/bar in browser w/ lines 50-57 highlighted:
|
||||||
|
## $ git-open foo/bar.rb 50-57
|
||||||
|
##
|
||||||
|
## Open current file in vim on line 20:
|
||||||
|
## :!git-open % 20
|
||||||
|
##
|
||||||
|
## https://github.com/jacobwg/dotfiles/blob/master/bin/github-open
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
FILE="$1"
|
||||||
|
LINE="$2"
|
||||||
|
|
||||||
|
# usage and help
|
||||||
|
test -z "$FILE" -o "$FILE" = '--help' && {
|
||||||
|
cat "$0" | grep '^##' | cut -c4- 1>&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# bail out with message to stderr and exit status 1
|
||||||
|
die() {
|
||||||
|
echo "$(basename $0):" "$@" 1>&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# figure out relative path to the file from the root
|
||||||
|
# of the work tree
|
||||||
|
path="$(basename $FILE)"
|
||||||
|
cd $(dirname $FILE)
|
||||||
|
while test ! -d .git ;
|
||||||
|
do
|
||||||
|
test "$(pwd)" = / && {
|
||||||
|
echo "error: git repository not found" 1>&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
path="$(basename $(pwd))/$path"
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
|
||||||
|
# get the current branch in refs/heads/<branch> form
|
||||||
|
ref=$(git symbolic-ref -q HEAD)
|
||||||
|
test -n "$ref" ||
|
||||||
|
die "you're not on a branch"
|
||||||
|
|
||||||
|
# just the branch name please
|
||||||
|
branch=$(echo "$ref" | sed 's@^refs/heads/@@')
|
||||||
|
test -n "$branch" ||
|
||||||
|
die "you're in a weird place; get on a local branch"
|
||||||
|
|
||||||
|
# remote we're tracking
|
||||||
|
remote=$(git config --get "branch.$branch.remote" || true)
|
||||||
|
test -n "$remote" ||
|
||||||
|
die "you're not tracking a remote branch"
|
||||||
|
|
||||||
|
# remote branch we're tracking
|
||||||
|
merge=$(
|
||||||
|
(git config --get "branch.$branch.merge") |
|
||||||
|
sed 's@refs/heads/@@'
|
||||||
|
)
|
||||||
|
test -n "$merge" ||
|
||||||
|
die "you're not tracking a remote branch"
|
||||||
|
|
||||||
|
# at this point we're in root of the work tree and $path is
|
||||||
|
# the relative path to file.
|
||||||
|
remote_url=$(git config --get remote.$remote.url)
|
||||||
|
repo=$(echo "$remote_url" | sed 's/^.*:\(.*\)\.git/\1/')
|
||||||
|
url="http://github.com/$repo/blob/$branch/$path"
|
||||||
|
|
||||||
|
# debugging
|
||||||
|
# echo "url: $remote_url"
|
||||||
|
# echo "repo: $repo"
|
||||||
|
|
||||||
|
# throw the line number on there if specified
|
||||||
|
test -n "$LINE" && url="$url#L$LINE"
|
||||||
|
|
||||||
|
open "$url"
|
14
bin/lyrics
Executable file
14
bin/lyrics
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# lyrics.sh
|
||||||
|
#
|
||||||
|
# A fine piece of work by @febuiles
|
||||||
|
# https://gist.github.com/1549979
|
||||||
|
|
||||||
|
artist=`osascript -e'tell application "iTunes"' -e'get artist of current track' -e'end tell'`
|
||||||
|
title=`osascript -e'tell application "iTunes"' -e'get name of current track' -e'end tell'`
|
||||||
|
|
||||||
|
song=`curl -G --data-urlencode "artist=$artist" \
|
||||||
|
--data-urlencode "title=$title" -s http://makeitpersonal.co/lyrics`
|
||||||
|
|
||||||
|
echo -e "$artist - $title\n$song"
|
41
bin/showme
Executable file
41
bin/showme
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Takes N pictures of you via your iSight camera, animates them, uploads them to CloudApp, and puts the url in your clipboard.
|
||||||
|
#
|
||||||
|
# USAGE: showme [shots]
|
||||||
|
#
|
||||||
|
# Author: Artem Sapegin, sapegin.me
|
||||||
|
# Inspired by https://gist.github.com/832125
|
||||||
|
#
|
||||||
|
# Requirements:
|
||||||
|
# brew istall imagemagick imagesnap
|
||||||
|
# gem install gifme cloudapp_api json
|
||||||
|
# https://github.com/holman/dotfiles/blob/master/bin/cloudapp
|
||||||
|
# http://www.getcloudapp.com/
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# 3 shots by default
|
||||||
|
shots=${1-3}
|
||||||
|
dir=`basename "$(pwd)"`
|
||||||
|
|
||||||
|
TMPDIR=`mktemp -d` && {
|
||||||
|
cd $TMPDIR
|
||||||
|
|
||||||
|
for ((shot=1; shot<=$shots; shot++)); do
|
||||||
|
echo "Prepare for shot $shot..."
|
||||||
|
echo "3..."
|
||||||
|
sleep 1
|
||||||
|
echo "2..."
|
||||||
|
sleep 1
|
||||||
|
echo "1..."
|
||||||
|
sleep 1
|
||||||
|
echo "GO!"
|
||||||
|
imagesnap -q "shot$shot.jpg"
|
||||||
|
done
|
||||||
|
|
||||||
|
gifme -w 200 -o hereisapictureofme.gif *.jpg
|
||||||
|
|
||||||
|
rm -rf $TMPDIR
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user