Skip to content

Instantly share code, notes, and snippets.

View tandibar's full-sized avatar

Andreas Bade tandibar

  • Freelancer
  • Remscheid, Germany
View GitHub Profile
# patch array for pairwise function
class Array
def pairwise
pairs = []
a = self.slice(1..-1).each_slice(2).to_a
self.each_slice(2).to_a.each_with_index do |el, idx|
pairs << el if el.size > 1
pairs << a[idx] if a[idx] && a[idx].size > 1
end
pairs.each do |pair|
@tandibar
tandibar / find_non_ascii_characters.sh
Created February 12, 2013 17:34
find non ascii characters in a directory tree
find app/* | xargs pcregrep --color='auto' -n "[\x80-\xFF]"
@tandibar
tandibar / multiZeroClipboards.html
Created January 8, 2013 11:17
This gist describes the issue i have with multiple ZeroClipboards on one page.
<pre id="n1" class="prettyprint">
some code
</pre>
<button class="clip_button" data-clipboard-ref="#n1"><b>Copy To Clipboard</b></button>
<pre id="n2" class="prettyprint">
some other code
</pre>
<button class="clip_button" data-clipboard-ref="#n1"><b>Copy To Clipboard</b></button>
@tandibar
tandibar / detect_merged_remote_branches.sh
Created February 22, 2012 09:56
Check wheather a branch has differences with master or not
#!/usr/bin/env bash
for branch in $(git branch -a | grep "remotes/origin/" | grep -v "master" | sed 's|remotes/||')
do
echo "checking $branch for unmerged changes"
if git diff --exit-code master...$branch > /dev/null
then
echo "no commits found which were not already merged into master"
echo "should i delete the branch $branch?(y/n): "
read answer
if [ $answer = "y" ]
@tandibar
tandibar / copy_commit_hash_to_clipboard.sh
Created November 22, 2011 13:34
Copy latest commit hash to clipboard
git log -1 | grep "commit .*" | ruby -e "print ARGF.read.split(' ')[1]" | pbcopy
# add this line to the Gemfile
gem "gelf", :git => 'git://github.com/galaxycats/gelf-rb.git' # as long as our changes are not merged
# add this lines to your config
config.logger = GELF::RailsLogger.new("<host>", 12201, "WAN", { :facility => "<app-name>" })
config.logger.level = Logger::INFO
# deactivate colorizing of the log-messages
config.active_record.colorize_logging = false