Skip to content

Instantly share code, notes, and snippets.

@Coornail
Coornail / serverReachable.js
Created September 17, 2011 10:33 — forked from louisremi/serverReachable.js
better navigation.onLine: serverReachable()
function serverReachable() {
// Cross-browser XHR creation
var request = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" ),
status_code;
request.open(
// requesting the headers is faster, and just enough
"HEAD",
// append a random string to the current hostname,
// to make sure we're not hitting the cache
@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
@Coornail
Coornail / gist:4985036
Last active December 13, 2015 22:29
Todo.txt helper which lists Pronovix todos on weekdays from 9-6 and anything else other times.
#!/bin/sh
HOUR=`date +%H | sed -e 's/^0//g'`
DAY=`date +%A`
# Don't list work related tasks...
FILTER='-+Pronovix'
# ... Except at work time.
if [[ $HOUR -gt 8 && $HOUR -lt 18 ]]; then
@Coornail
Coornail / gist:4996947
Created February 20, 2013 16:43
Todo.txt progress bar
#!/bin/bash
ALL_TASKS=`cat ~/todo.txt | wc -l`
COMPLETED_TASKS=`cat ~/todo.txt | grep '^x\ ' | wc -l`
echo -n '['
for i in $(seq 1 $COMPLETED_TASKS); do
echo -n '='
done;
Host *
Compression=yes
CompressionLevel=9
ControlMaster auto
ControlPath /tmp/%r@%h:%p
ServerAliveInterval 100
Host bastion
HostName bastion-21.network.hosting.acquia.com
User attilafekete
#,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
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()
@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
@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
#!/usr/bin/env bash
DEBIAN_PACKAGES="
apache2 \
curl \
default-jre-headless \
git \
python-pip
python-typogrify \
unzip \