Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#line break for "for"
IFS=`echo -en "\n\b"`
# Function to optimize a jpeg image.
function optimize() {
ORIGINAL_FILE_SIZE=`du -b $1 | awk {'print $1'}`
jpegtran -copy none -optimize -perfect -outfile "$1-opt" "$1"
OPTIMIZED_FILE_SIZE=`du -b "$1-opt" | awk {'print $1'}`
@Coornail
Coornail / gist:4015909
Created November 5, 2012 07:57
Chrome sqlite vacuum on OsX
#!/bin/sh
DIRECTORY='~/Library/Application Support/Google/Chrome/'
TMPFILE=`mktemp /tmp/chrome_cleanup.XXXXXX`
find "$DIRECTORY" >> $TMPFILE
SQLITE_FILES=`mktemp /tmp/chrome_cleanup.XXXXXX`
SAVEIFS=$IFS
Sampling process 98304 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling KeePassXC (pid 98304) every 1 millisecond
Process: KeePassXC [98304]
Path: /Applications/KeePassXC.app/Contents/MacOS/KeePassXC
Load Address: 0x10c9a5000
Identifier: org.keepassx.keepassxc
Version: 2.1.0 (2.1.0)
Code Type: X86-64
Parent Process: ??? [1]
### Keybase proof
I hereby claim:
* I am Coornail on github.
* I am coornail (https://keybase.io/coornail) on keybase.
* I have a public key whose fingerprint is 5CF5 3947 B5BF FBE7 B511 0749 D616 27C1 2BF0 8790
To claim this, I am signing this object:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Tl/TCpIc7t0VYgmA2kbtTHCjS1zWJq6hxF456IlfkFIOZSqUosaXViWcbSlwQxjGLAlQpzj2wUlZy320bAvu9zHw3u7bfn9GM95mpfpvCfnAlxRJbRe2DvXDGZGHma/6UUrFr4xG11VZP7G6vPKeglnuSAP0lKa7I24rmAOg5yO++6pLnDEMhXP1JdRw0sCyflE0JvxF6rV9ulDcZ9Rd5mHEJnMkXeu9GVbx8v22o661hQnA3vHSB1ax2D0vm3TfkI2IAqu8ux/wLny91/u4t1wrWf2/VHtdYVpXX/sqjVDu+GQ2VgI+XdZQJOdVmUf1V4y4diFA8Siro60zFrGFQ== coornail@slash
#!/usr/bin/env bash
DEBIAN_PACKAGES="
apache2 \
curl \
default-jre-headless \
git \
python-pip
python-typogrify \
unzip \
@Coornail
Coornail / gist:6962932
Created October 13, 2013 14:26
dnsmasq config
cache-size=10000
all-servers
domain-needed
filterwin2k
bogus-priv
stop-dns-rebind
server=209.244.0.3
server=4.2.2.2
# OpenDNS AnyCast DNS servers
@Coornail
Coornail / export_rescuetime.sh
Created October 10, 2013 08:03
Export rescuetime current day data.
#!/bin/sh
KEY=xxx
DATE=`date +%Y-%m-%d`
curl "https://www.rescuetime.com/anapi/data?key=$KEY&format=csv&rb=$DATE&re=$DATE" > $DATE.csv
library(ggplot2)
# Load and format data.
bb <- read.csv("bb.csv")
fr <- data.frame(idx=as.numeric(1:57), rating=bb$User.Rating, season=factor(bb$Season))
# Print graph.
png("/tmp/bb.png", width=1280, height=768)
gplot(data=fr, aes(x=fr$idx, y=fr$rating, color=season)) + geom_point(size=3) + geom_smooth(aes(group=fr$season), method="lm") + labs(x="", y="User rating", color="Season", title="Breaking Bad episode rating")
dev.off()
#,Episode,"User
Rating","User
Votes",,Season
1.1,Pilot,8.8,3339,1 2 3 4 5 6 7 8 9 10 8.8/10 X,1
1.2,Cat's in the Bag...,8.5,2313,1 2 3 4 5 6 7 8 9 10 8.5/10 X,1
1.3,...And the Bag's in the River,8.6,2154,1 2 3 4 5 6 7 8 9 10 8.6/10 X,1
1.4,Cancer Man,8.3,2019,1 2 3 4 5 6 7 8 9 10 8.3/10 X,1
1.5,Gray Matter,8.3,1976,1 2 3 4 5 6 7 8 9 10 8.3/10 X,1
1.6,Crazy Handful of Nothin',9.1,2249,1 2 3 4 5 6 7 8 9 10 9.1/10 X,1
1.7,A No-Rough-Stuff-Type Deal,8.7,1972,1 2 3 4 5 6 7 8 9 10 8.7/10 X,1