Skip to content

Instantly share code, notes, and snippets.

@ggarnier
ggarnier / check-git-status.sh
Created June 11, 2013 22:36
Checks the status for all my git projects
#!/bin/bash
# check-git-status.sh - Checks the status for all my git projects
# Usage: check-git-status.sh <main projects directory>
if [ -z "$1" ]; then
mainDir="$HOME/Projects"
else
mainDir="$1"
fi
@ggarnier
ggarnier / x11docker.sh
Created September 29, 2015 20:58
Run graphical applications in Docker containers in OSX
# https://github.com/docker/docker/issues/8710#issuecomment-72669844
# display IP address isn't boot2docker ip, it's the address from vboxnet0 (run `ifconfig`)
brew install socat
brew cask install xquartz
open -a XQuartz
socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
# in another window
docker run -e DISPLAY=192.168.59.3:0 jess/geary
@ggarnier
ggarnier / gist:1158192
Created August 19, 2011 22:25
Remove undesired audio tracks from a video file
# extracted from http://superuser.com/questions/56093/remove-audio-stream-from-xvid-files
# replace -aid value with the audio track number you wish to keep
mencoder orig.avi -o new.avi -oac copy -ovc copy -aid 1
@ggarnier
ggarnier / tga-to-jpg.sh
Created December 10, 2010 13:34
Batch conversion from tga to jpg
#!/bin/bash
# Batch conversion from tga to jpg
# Author: Guilherme Garnier - http://blog.guilhermegarnier.com
# Adapted from:
# http://linux.strangegamer.com/index.php?title=Converting_A_directory_of_TGA%27s_To_JPG
# http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
#!/usr/bin/env ruby
#
# Put this script in your PATH and download from onemanga.com like this:
# onemanga_downloader.rb Bleach [chapter number]
#
# You will find the downloaded chapters under $HOME/Documents/OneManga/Bleach
#
# If you run this script without arguments, it will check your local manga downloads
# and check if there are any new chapters
#
@ggarnier
ggarnier / find_replace.sed
Last active September 3, 2015 18:28
Find/replace in multiple files
oldstring="describe"
newstring="RSpec.describe"
path=path/to/files
grep -rl $oldstring $path/* | xargs sed -i '' s/$oldstring/$newstring/g
@ggarnier
ggarnier / block_test.rb
Created August 6, 2015 15:58
Ruby block has a different priority when using "do..end" or "{}"
def test1(params)
p "test1 #{params}"
end
def test2(&block)
if block_given?
p "test2 with block"
yield
else
p "test2 without block"
@ggarnier
ggarnier / capybara_list_requested_domains.rb
Created August 5, 2015 19:10
Capybara - list requested domains
page.driver.network_traffic.map do |req|
req.url.gsub(/^(https?:\/\/[^\/]+)\/.*$/, '\1')
end.uniq
@ggarnier
ggarnier / textile_to_md.sed
Created January 13, 2015 16:00
textile_to_md.sed
# sed -f textile_to_md.sed original.textile > destination.md
s/"\([^"]*\)":\([^\. ]*\.html\)/[\1](\2)/g
s/^h3[^.]*\./###/
s/^h4\./####/
s/^h5\./#####/
s/^<js>$/~~~json/
s/^<\/js>$/~~~/
s/^<plain>$/~~~sh/
s/^<\/plain>$/~~~/
@ggarnier
ggarnier / textile_to_markdown.rb
Created June 3, 2014 18:09
Textile to Markdown
def process_file oldfilename
markdown_content = textile_to_markdown(File.read(oldfilename))
filename = oldfilename.split("/").last.split(".").first.gsub("-", "_")
File.open("doc_src/content/#{filename}.md", "w") do |f|
f.write <<-CONTENT
---
title: #{filename.capitalize}
group: Base
---