Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / private.js
Last active December 25, 2015 16:39
Javascript private functions
// Reference: http://javascript.crockford.com/private.html
Test = function() {
function private() {
return "private";
}
return {
public: function() {
return private();
}
@ggarnier
ggarnier / ordering.rb
Created November 21, 2013 18:03
Ordering an array in Ruby using 2 sorting criterias
# Ordering a list by field1 in descending order. If two elements have the same value, order by field2 in ascending order
list.sort do |a, b|
comp = (b.field1 <=> a.field2)
comp.zero? ? (a.field2 <=> b.field2) : comp
end
@ggarnier
ggarnier / html2markdown.rb
Created December 18, 2013 14:46
html2markdown
text.gsub(/<a href="([^"]*)">([^<]*)<\/a>/, '[\2](\1)')
@ggarnier
ggarnier / remove_line.sed
Created January 14, 2016 11:06
Remove line from files using sed
sed -i '' '/expression/d' ./file*
# or, if you have a deep directory tree...
find . -name file* -maxdepth 3 -exec sed -i '' '/expression/d' {} \;
package main
import (
"fmt"
"math"
"os"
"strconv"
)
func main() {
# Search available packages with "gimp" in the name or description
apt-cache search gimp
# Check available versions for package "gimp"
apt-cache madison gimp
# Check installed and available versions for package "gimp"
apt-cache policy gimp
# List packages installed via apt
@ggarnier
ggarnier / gist:fc306a58d9c6ec185545a3d944c9b8a3
Last active April 8, 2019 14:37
Adicionar certificados digitais da Receita Federal no Ubuntu
sudo mkdir -p /usr/share/ca-certificates/extra
for f in *.cer; do mv $f ${f%.*}.crt; done
sudo mv *.crt /usr/share/ca-certificates/extra/
sudo dpkg-reconfigure ca-certificates