Skip to content

Instantly share code, notes, and snippets.

View kieranajp's full-sized avatar
🎧

Kieran kieranajp

🎧
View GitHub Profile
@kieranajp
kieranajp / FocusTextBox.cs
Created February 22, 2012 19:30
Creating a System.Windows.Forms.TextBox that automatically selects text on focus (like a browser's URL bar)
public class FocusTextBox : System.Windows.Forms.TextBox
{
private bool _focussed;
protected override void OnEnter(EventArgs e)
{
base.OnEnter(e);
if (MouseButtons == MouseButtons.None)
{
SelectAll();
@kieranajp
kieranajp / gist:1917510
Created February 26, 2012 16:32
Open as TextMate Project
-- Add this in Automator as a Service
-- Service receives selected <folders> in <Finder>
on run {input, parameters}
tell application "TextMate"
open input
end tell
end run
@kieranajp
kieranajp / randIP.php
Created March 28, 2012 15:40
Random IP address
<?php
long2ip(rand(0, "4294967295")); // random up to 255.255.255.255
?>
@kieranajp
kieranajp / hack.sh
Created March 31, 2012 17:13 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with useful tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl https://raw.github.com/gist/2266840/9a55fa74b72089ac8654a48e5988652cfc9f664c/hack.sh | sh
#
@kieranajp
kieranajp / Notification.cs
Created April 21, 2012 16:07
My little notification class (:
/* Create a form, controlBox and everything turned off, so there are no Window controls on it.
* Put a label on it (lblNotification) and a timer, I used a tick of 2500, and you're set!
* Call Notification n = new Notification("Some text", false); - the instance kills itself after 2.5 seconds (with timer tick of 2500)
*/
public partial class Notification : Form
{
public Notification(string txt, bool perma)
{
InitializeComponent();
this.Show();
@kieranajp
kieranajp / hidden.sh
Created June 20, 2012 15:53
Alfred: Toggle Hidden Files
# Paste this as a shell script extension in the Powerpack
SHOW=`defaults read com.apple.finder AppleShowAllFiles`
if [ "${SHOW}x" = "1x" ]; then
defaults write com.apple.finder AppleShowAllFiles -bool FALSE
else
defaults write com.apple.finder AppleShowAllFiles -bool TRUE
fi
killall Finder
@kieranajp
kieranajp / taxCalc.rb
Created September 6, 2012 23:09
Employment Income Tax Calculator in Ruby
class Tax
attr_accessor :threshold
def initialize(threshold)
# There's probably a better way of doing default values
@threshold = threshold.to_i || 7592
end
def parseTaxCode(taxCode)
# Try this bit in ruby 1.9

News pages

Variables & functions

First things first, we're going to want to declare all our variables. We'll begin with caching some selectors so we can put them to good use later (we're going to use these guys a lot so we should keep them around here - beats parsing the DOM every time)

$head = $(".page-header")
$auth = $("#targeted_authority")
$focus = $("#targeted_focus")
var canvas = document.getElementById("canvas")
, ctx = canvas.getContext("2d")
, x = 1, y = 1;
var colors = [
"9DB0AC",
"829995",
"5D7975",
"3E5D58",
"18332F",
@kieranajp
kieranajp / svg.html
Last active August 29, 2015 14:03
Create colours of varying opacities and very quickly testing them against various backgrounds, using SVG & coffeescript
<!doctype html>
<html>
<head>
<style>
body {
margin: 0;
}
div {
width: 50%;