Skip to content

Instantly share code, notes, and snippets.

View wteuber's full-sized avatar

Wolfgang Teuber wteuber

View GitHub Profile
@wteuber
wteuber / reduce_pdf.sh
Created February 1, 2024 16:18 — forked from knugie/reduce_pdf.sh
reduce pdf size
#reduce PDF size
#-dPDFSETTINGS
# /screen
# /ebook
# /printer
# /prepress
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -sOutputFile=out.pdf in.pdf
@wteuber
wteuber / iterm-colors-to-vscode.js
Created May 18, 2022 13:10 — forked from experimatt/iterm-colors-to-vscode.js
A simple script to use your iTerm color profile in vscode's built-in terminal.
// 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:
@wteuber
wteuber / mysql-install.sh
Created May 28, 2019 07:53 — forked from cemeng/mysql-install.sh
Codeship Install MySQL 5.6
#!/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
@wteuber
wteuber / rubocop_stable_auto_correct.rb
Created June 2, 2017 10:51
Script to check & commit all stable auto-corrections of Rubocop
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+\)$/, '')]
@wteuber
wteuber / memo.rb
Created January 11, 2017 11:19 — forked from LeFnord/memo.rb
ruby memoization benchmarks
require "benchmark"
class A
def name
@name ||= begin
rand
end
end
end
@wteuber
wteuber / yaml_cmp.rb
Created September 5, 2016 07:21 — forked from carlosveucv/yaml_cmp.rb
Compare 2 yaml's in ruby (print matching keys)
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
#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'