Skip to content

Instantly share code, notes, and snippets.

Simon Schoeters cimm

Block or report user

Report or block cimm

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
@cimm
cimm / image_width.js
Created Feb 2, 2015
Get the image width in client side JavaScript
View image_width.js
var file = ... // a File web API interface: https://developer.mozilla.org/en-US/docs/Web/API/File
img = new Image();
img.src = URL.createObjectURL(file);
img.onload = function() {
alert(this.naturalWidth);
};
@cimm
cimm / vpn-warning.sh
Created Mar 26, 2018
Intended to run in cron, a little nudge to warn me to turn on my VPN
View vpn-warning.sh
#!/bin/sh
eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)";
if /sbin/ifconfig tun0; then
echo "VPN is active";
else
DISPLAY=:0 notify-send "VPN is not active"
fi
@cimm
cimm / localized_ruby.rb
Created Nov 23, 2012 — forked from jimeh/__readme.md
Let's not localize programming languages. Please >_<
View localized_ruby.rb
# Let's not localize programming languages. Please >_<
#
# Feel free to fork and expand and/or add more languages as an example
# to why this would be horrible, and I'll add them here :)
# Ruby in English
if user.is_alive?
# send spam mail
@cimm
cimm / gist:1359553
Created Nov 11, 2011
Imports a folder in iPhoto
View gist:1359553
-- debugging
on log_event(themessage)
set theLine to (do shell script "date +'%Y-%m-%d %H:%M:%S'" as string) & " " & themessage
do shell script "echo " & theLine & " >> ~/Library/Logs/AppleScript-events.log"
end log_event
-- Extract the album name from the session file
on extractAlbumName(sessionContents)
set albumName to ""
set allLines to every paragraph of sessionContents
@cimm
cimm / gist:736953
Created Dec 10, 2010
Creates an Heroku dump and downloads the result, removing the old local backup if needed.
View gist:736953
#!/usr/bin/env ruby
app = "your-heroku-app"
STDOUT.sync = true
start_time = Time.now
# Fail if the previous dump did not end well
if File.exist?("#{app}.dump.backup")
puts "\e[31mThe previous dump did not end well, check manually.\e[0m"
@cimm
cimm / gRaphael.js
Created Jul 28, 2010
Easiest way to draw a line graph with gRaphael
View gRaphael.js
// Initialize the Raphael object
var r = Raphael("holder");
// Assign the values for the X axis
var x = [1, 2, 3, 4];
// Assign the values for the Y axis
var y = [1, 2, 1, 3];
// Draw a line chart (startX, startY, width, height, valuesX, valuesY)
r.g.linechart(0, 0, 300, 220, x, y);
View gpx2image
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'gnuplot'
if ARGV[0]
source = ARGV[0]
else
puts "usage: ./gpx2image source_file"
exit(0)
@cimm
cimm / gist:463765
Created Jul 4, 2010
Creates an Heroku bundle and downloads the result, removing the old local backup if needed.
View gist:463765
#!/usr/bin/env ruby
app = "your-heroku-app"
STDOUT.sync = true
start_time = Time.now
# Prepare old backup for rotate if needed
if File.exist?("#{app}.tar.gz.backup")
puts "\e[31mThe previous backup did not end well, check manually.\e[0m"
@cimm
cimm / train.rb
Last active Sep 4, 2015
Gets the NMBS/SNCB trains leaving from a given station in Belgium.
View train.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'cgi'
require 'open-uri'
require 'hpricot'
current_time = Time.now.strftime("%H:%M")
url = ""
user_agent = "Mozilla/5.0 (X11; U; CrOS i686 9.10.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.253.0 Safari/532.5"
@cimm
cimm / NEMA2KML.scpt
Created Jan 16, 2010
This AppleScript converts a NMEA input file and converts all real coordinates to Google placemarks in a KML file.
View NEMA2KML.scpt
property script_name : "NMEA2KML"
property script_version : "0.3"
property script_description : "This script converts a NMEA input file and converts all real coordinates to Google placemarks in a KML file."
property script_copyright : "Creative Commons Attribution 3.0 License"
property script_author : "Simon Schoeters"
property script_website : "http://www.suffix.be/"
-- Get the file and its path
set filePath to (choose file with prompt "Select a NMEA file:") as Unicode text
set filePath to replace_chars(filePath, ":", "/")
You can’t perform that action at this time.