Skip to content

Instantly share code, notes, and snippets.

🤦‍♂
Permanent 418 status code.

Jon Gjengset jonhoo

🤦‍♂
Permanent 418 status code.
Block or report user

Report or block jonhoo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jonhoo
jonhoo / seriex.markdown
Created Nov 30, 2010
A script for automatically give good filenames to TV-series episodes. Requires IMDB::Film >= 0.49
@jonhoo
jonhoo / atg-mode.el
Created Jan 22, 2011
SRI SAL mode for Emacs
View atg-mode.el
(require 'generic-x) ;; we need this
(define-generic-mode
'atg-mode ;; name of the mode to create
'("---") ;; comments start with '!!'
'("Path" "Step") ;; some keywords
'(("=" . 'font-lock-function-name-face)) ;; '=' is an operator
'("\\.atg$") ;; files for which to activate this mode
nil ;; other functions to call
"A mode for SRI SAL ATG generated files" ;; doc string for this mode
@jonhoo
jonhoo / index.gallery.php
Created Mar 19, 2011
A standalone, drop-in gallery for collections of videos and images
View index.gallery.php
@jonhoo
jonhoo / README
Created Apr 7, 2011
A busybox bash script for determining the progress of a copy operation
View README
A simple script that estimates the progress, speed and probable completion time of a copy operation.
It was originally written for a QNAP NAS running busybox, but should be compatible with any busybox install.
Should also work for most Linux systems, but the options to du and df will have to be modified since the busybox uses a simplified syntax (The -m for both of them is to get the output in MB).
The script is called with the same arguments given to cp
The script estimates by using:
- Difference in df-used for speed
- Difference in du for percentage
- A combination of the above for ETC (Estimated Time to Completion)
@jonhoo
jonhoo / vpn.sh
Created Dec 16, 2011
Script for connecting to VPN using OpenVPN configs
View vpn.sh
#!/bin/bash
if [ -n "$1" ];
then
if [ -e "$HOME/.openvpn/$1.ovpn" ]
then
sudo openvpn --cd ~/.openvpn --config "$1.ovpn" --daemon
STATUS=$?
if [ $STATUS -eq 0 ]
then
echo "Connected to VPN network $1"
@jonhoo
jonhoo / wifi.markdown
Created Mar 5, 2012
Perl script for scanning for wireless networks and creating NetCFG profiles
@jonhoo
jonhoo / gist:2205417
Created Mar 26, 2012
Swipe and click handlers in simple JS
View gist:2205417
try{
document.createEvent("TouchEvent");
// Here we're ensured touch capabilities
var scroll = document.getElementById('myid');
var start = null;
var clickIfEnd = true;
scroll.addEventListener('touchstart', function (e) {
start = e.touches[0].pageX;
clickIfEnd = true;
@jonhoo
jonhoo / getElementsByClassName.min.js
Created May 11, 2012
Simple polyfill for fetching all elements on the page with the given class
View getElementsByClassName.min.js
"getElementsByClassName"in document||(document.getElementsByClassName=document.evaluate?function(a){var a="[contains(concat(' ', @class, ' '), ' "+a+" ')]",d="http://www.w3.org/1999/xhtml"===document.documentElement.namespaceURI?"http://www.w3.org/1999/xhtml":null,b;try{b=document.evaluate(".//*"+a,document,d,0,null)}catch(c){b=document.evaluate(".//*"+a,document,null,0,null)}return b}:function(a){for(var a=RegExp("(^|\\s)"+a+"(\\s|$)"),d=document.all||document.getElementsByTagName("*"),b=[],c=0,e=
d.length;c<e;c+=1)a.test(d[c].className)&&b.push(d[c]);return b});
@jonhoo
jonhoo / imdb-lookup.pl
Created Sep 18, 2012
File for looking up movie files in IMDb
View imdb-lookup.pl
#!/usr/bin/perl
use strict;
use warnings;
use IMDB::Film;
my $promptDelete = 0;
if (@ARGV > 0 and $ARGV[0] eq "-d") {
$promptDelete = 1;
shift @ARGV;
}
@jonhoo
jonhoo / cssmin
Created Feb 6, 2013
A very minimal CSS minifier
View cssmin
#!/bin/bash
cat $1 \
| tr '\r\n' ' ' \
| perl -pe 's:/\*.*?\*/::g' \
| sed \
-e 's/\s\+/ /g' \
-e 's/\([#\.:]\)\s\?/\1/g' \
-e 's/\s\?\([;{}]\)\s\?/\1/g' \
-e 's/\s\?\([,!+~>]\)\s\?/\1/g' \
-e 's/;}/}/g' \
You can’t perform that action at this time.