Skip to content

Instantly share code, notes, and snippets.

View geraintwhite's full-sized avatar
:octocat:

Geraint White geraintwhite

:octocat:
View GitHub Profile
@geraintwhite
geraintwhite / _notepad.html
Last active April 26, 2017 12:14 — forked from olls/notepad.html
HTML Notepad with save, open, local storage and markdown preview. Improved, live version http://dvbris.com/projects/notepad.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Notepad</title>
@geraintwhite
geraintwhite / twitter_api_proxy.js
Created April 7, 2014 00:23 — forked from olls/twitter_api_proxy.js
A Node.js app that allows the use of the Twitter API by client-side JavaScript.
/*
A simple Node.js proxy for Twitter's OAuth API.
*/
var http = require('http');
var url = require('url');
var t = require('twitter-js-client');
var twitter = new t.Twitter({
"consumerKey": "###",
@geraintwhite
geraintwhite / unlock.js
Last active August 6, 2020 01:31
A Node.js app to use NFC to unlock/lock Ubuntu.
var http = require('http'),
url = require('url'),
exec = require('child_process').exec;
var locked = false;
var app = http.createServer(function(request, response) {
var url_parts = url.parse(request.url, true);
var path = url_parts.pathname.replace(/^\/|\/$/g, '');
@geraintwhite
geraintwhite / bookmarklets.js
Created June 7, 2014 12:42
A selection of useful bookmarklets
/* Convert YouTube to MP3 */
javascript:window.open('http://www.video2mp3.net/loading.php?url='+window.location)
/* Include jQuery */
javascript:(function(a){if(!a.jQuery){var d=document,b=d.createElement('script');b.src='//code.jquery.com/jquery-latest.js';d.getElementsByTagName('head')[0].appendChild(b)}})(this)
/* View Source */
@geraintwhite
geraintwhite / github.js
Created June 7, 2014 12:50
GitHub user feed widget
function github_req(user, cb) {
makeRequest(
'https://api.github.com/users/' + user + '/events',
function (text) {
var data = JSON.parse(text);
cb(data);
}
);
}
@geraintwhite
geraintwhite / suspend.sh
Created June 14, 2014 15:44
Script to suspend the system. I use with keyboard shortcut ctrl-alt-backspace. Works with my NFC screen unlock (https://gist.github.com/grit96/11268473).
#!/bin/bash
# Trigger my NFC unlock to lock the computer
curl http://localhost:6001/?secret=secret
# Send standby signal
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
@geraintwhite
geraintwhite / colors.py
Last active August 29, 2015 14:07
Python terminal colours module
import sys
def _has_colors(stream):
if not hasattr(stream, 'isatty'):
return False
if not stream.isatty():
return False
try:
import curses
@geraintwhite
geraintwhite / analyser.py
Last active August 29, 2015 14:09
Disk Usage Analyser
import os
import sys
import colors
class Node():
_OPT = {
'depth': False,
'colors': True,
'abspath': False,
@geraintwhite
geraintwhite / console.py
Created November 12, 2014 10:10
Python module to get terminal size
import sys
def getTerminalSize():
import os
env = os.environ
def ioctl_GWINSZ(fd):
try:
import fcntl, termios, struct, os
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
@geraintwhite
geraintwhite / setup.sh
Last active January 25, 2016 09:40
Setup file for deployment system
#!/bin/bash
ssh_url="[email protected]"
base_path="/home/git/deploy"
repo_dir="$base_path/repos"
processing="$base_path/processing"
getter="$base_path/github-getter"
post_receive="$base_path/post-receive"
full_name="itsapi/github-getter"