View iterm-colors-to-vscode.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This script takes an iTerm Color Profile as an argument and translates it for use with Visual Studio Code's built-in terminal. | |
// | |
// usage: `node iterm-colors-to-vscode.js [path-to-iterm-profile.json] | |
// | |
// To export an iTerm Color Profile: | |
// 1) Open iTerm | |
// 2) Go to Preferences -> Profiles -> Colors | |
// 3) Other Actions -> Save Profile as JSON | |
// | |
// To generate the applicable color settings and use them in VS Code: |
View git_branch_gone_prune_delete.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
git remote prune origin && git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d |
View mysql-install.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install a custom MySQL 5.7 version - https://www.mysql.com | |
# | |
# To run this script on Codeship, add the following | |
# command to your project's setup commands: | |
# \curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/packages/mysql-5.7.sh | bash -s | |
# | |
# Add the following environment variables to your project configuration | |
# (otherwise the defaults below will be used). | |
# * MYSQL_VERSION |
View colored_git_diff_html.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mac OS X: | |
script -q colored_word_diff.txt git diff --word-diff | |
cat colored_word_diff.txt|ansi2html > colored_word_diff.html |
View redirection.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|| visible in terminal || visible in file || existing | |
Syntax || StdOut | StdErr || StdOut | StdErr || file | |
==========++==========+==========++==========+==========++=========== | |
> || no | yes || yes | no || overwrite | |
>> || no | yes || yes | no || append | |
|| | || | || | |
2> || yes | no || no | yes || overwrite | |
2>> || yes | no || no | yes || append | |
|| | || | || | |
&> || no | no || yes | yes || overwrite |
View benford_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r=rand;(1..9).map{|n|Math.log10(1+1.0/n)}.inject([]){|a,e|a+[(a[-1]||0)+e]}.map.with_index{|p,i|[i+1,p]}.find{r<_2}[0] |
View trace.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set_trace_func -> (event, file, line, id, binding, classname) do | |
if event == 'call' && meth = binding.eval('__method__') | |
params = binding.method(meth).parameters.select{|e| e[0] != :block} | |
values = params.map{|_, var| [var, binding.local_variable_get(var)]} | |
printf "%8s %s:%-2d %15s %8s %s\n", event, file, line, id, classname, values.inspect | |
else | |
printf "%8s %s:%-2d %15s %8s\n", event, file, line, id, classname | |
end | |
end |
View rubocop_stable_auto_correct.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
# TODO get list of Cops that support auto-correct | |
# for each cop, run the following | |
# only commit if change was stable | |
# (each run takes ~2 minutes) | |
prefix = ARGV[0] | |
files = Dir["#{prefix}/**/*.rb"].sort | |
orig = Hash[files.map do |file| | |
FileUtils.cp(file, "#{file}.orig") | |
[file, %x(ruby --dump insns #{file}).gsub(/\s+\(\s*\d+\)$/, '')] |
View mov2gif.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
if [ -f "$1" ]; then | |
echo "ffmpeg -i $1 -vcodec copy -acodec copy $1.mp4 ..." | |
ffmpeg -i $1 -vcodec copy -acodec copy $1.mp4 | |
else | |
echo "ERROR: Could not find $1" | |
fi | |
if [ \( $? -eq 0 \) -a \( -f $1.mp4 \) ]; then |
View memo.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "benchmark" | |
class A | |
def name | |
@name ||= begin | |
rand | |
end | |
end | |
end |
NewerOlder