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
#reduce PDF size | |
#-dPDFSETTINGS | |
# /screen | |
# /ebook | |
# /printer | |
# /prepress | |
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -sOutputFile=out.pdf in.pdf |
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: |
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 |
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+\)$/, '')] |
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 |
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 'yaml' | |
def compare_yaml_hash(cf1, cf2, context = []) | |
cf1.each do |key, value| | |
if cf2.key?(key) | |
puts "Contains key : #{key} in path #{context.join(".")}" | |
end | |
value2 = cf2[key] | |
next unless value2 |
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
#http://tools.ietf.org/html/rfc2397 | |
img_path = '...pictures/img.jpg' | |
img = File.open(img_path, 'rb').read | |
img_type = case img[0..10] | |
when /^GIF8/ | |
'gif' | |
when Regexp.new('^\x89PNG', nil, 'n') | |
'png' | |
when Regexp.new('^\xff\xd8\xff\xe0\x00\x10JFIF', nil, 'n'), Regexp.new('^\xff\xd8\xff\xe1(.*){2}Exif', nil, 'n') | |
'jpeg' |