Skip to content

Instantly share code, notes, and snippets.

View thekarel's full-sized avatar

Charles Szilagyi thekarel

View GitHub Profile
var tweet = "Currently chilling out at W1B 2EL, then on to WC2E 8HA or maybe even L1 8JF! :-)";
// Here's a simple regex that tries to recognise postcode-like strings.
// See http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation
// for the rules on how UK postcodes are formatted.
var postcode_regex = /[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}/g;
var postcodes = tweet.match(postcode_regex);
console.log(postcodes);
@thekarel
thekarel / git-track
Last active August 29, 2015 13:56 — forked from sstephenson/git-track
Track the branch with the same name as the current on origin
#!/bin/sh
# Track the branch with the same name as the current on origin
# To set up an alias `git track`, run
#
# git config --global --add alias.track '!git-track'
#
# (via https://gist.github.com/graysky/29079/)
branch=$(git describe --contains --all HEAD)
@thekarel
thekarel / index.html
Created April 8, 2014 14:14 — forked from zhchbin/index.html
Create screenshot in node-webkit app
<html>
<body style="background: #333">
<script >
var gui = require('nw.gui');
var win = gui.Window.get();
function takeSnapshot() {
win.capturePage(function(img) {
var popWindow = gui.Window.open('popup.html',
{width: 420, height: 300});
popWindow.on('loaded', function() {
@thekarel
thekarel / ft.js
Created May 14, 2014 14:39 — forked from macdonst/ft.js
Download with Cordova example
var remoteFiles = [];
function downloadRemotePDF() {
var local2User = JSON.parse( localStorage["locallessons"] );
$.each(local2User, function(key) {
remoteFiles.push(optionsJSON + local2User[key].idcountries + '/' + local2User[key].idcurriculum + '/' + local2User[key].idoptions + '/pdf/' + local2User[key].pdfname);
}
downloadFile();
}