Skip to content

Instantly share code, notes, and snippets.

View wteuber's full-sized avatar

Wolfgang Teuber wteuber

View GitHub Profile
@wteuber
wteuber / iterm_open_file_in_intellij_idea.md
Last active May 24, 2023 13:22
iterm_open_file_in_intellij_idea
[ -z "\2" ] &&  /Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea \1 || /Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea --line \2  \1

image

@wteuber
wteuber / iterm_open_file_in_rubymine.md
Created May 22, 2023 13:10
iTerm open file in RubyMine
[ -z "\2" ] &&  /usr/local/bin/mine \1 || /usr/local/bin/mine --line \2  \1

image

@wteuber
wteuber / benford_generator.rb
Last active September 20, 2021 15:29
Random number generator with Benford's law distribution, fmi see https://en.wikipedia.org/wiki/Benford%27s_law and https://rosettacode.org/wiki/Benford%27s_law#Ruby
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]
ary.inject(Hash.new(0)) { |total, e| total[e] += 1 ;total}
@wteuber
wteuber / test.sh
Created November 11, 2013 13:35
ruby --dump
ruby --dump version
ruby --dump copyright
ruby --dump usage #??
ruby --dump yydebug file.rb
ruby --dump syntax file.rb
ruby --dump parsetree file.rb
ruby --dump parsetree_with_comment file.rb
@wteuber
wteuber / breakout_bot.js
Last active March 5, 2021 16:06
minimalistic bot for Google's atari breakout
/* go to https://elgoog.im/breakout/ and run the snippet in your js console (works only for one level): */
hit = function($) { $('#breakout-paddle').style.left = (parseInt($('#breakout-ball').style.left, 10)-50).toString()+'px'; window.setTimeout(function(){ hit($); }, 10)}; hit($);
@wteuber
wteuber / git_branch_gone_prune_delete.sh
Last active October 29, 2019 13:36
git: prune and delete gone local branches
#!/usr/bin/env bash
git remote prune origin && git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d
@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 / colored_git_diff_html.sh
Created May 27, 2019 12:59
Colored git word diff
# Mac OS X:
script -q colored_word_diff.txt git diff --word-diff
cat colored_word_diff.txt|ansi2html > colored_word_diff.html
@wteuber
wteuber / locale_yaml_formatter.rb
Last active April 18, 2019 12:34
Sort your rails locale yamls alphabetically and adds an empty line when indent lowers 2 or more levelsPrints everything to stdout. Watch your yaml anchors and aliases (fix manually, if needed).usage: chmod +x ./locale_yaml_formatter.rb ./locale_yaml_formatter.rb <path/to/locale.yml>In a rails project, runfind . -type f -name *.yml | grep -v spec…
#!/usr/bin/env ruby
# Sort your rails locale yamls alphabetically and adds an empty line when indent lowers 2 or more levels
# Prints everything to stdout. Watch your yaml anchors and aliases (fix manually, if needed).
# usage:
# chmod +x ./locale_yaml_formatter.rb
# ./locale_yaml_formatter.rb <path/to/locale.yml>
#
# In a rails project, run
# find . -type f -name *.yml | grep -v spec | grep locales | _