Skip to content

Instantly share code, notes, and snippets.

View thameera's full-sized avatar

Thameera Senanayaka thameera

View GitHub Profile
@thameera
thameera / timer
Last active December 15, 2015 07:59
Small bash script I use to create timers from the terminal. Place it in your $PATH. When the alarm goes, a message is printed on terminal, a beep sound is played, a native notification is displayed and a message box pops up.
#!/bin/bash
# USAGE
# timer <time> <optional message>
# timer 15 You've lived enough. Go die!
echo "Will go off in" $1 "minutes..."
sleep $(($1*60))
shift
echo "Time's up!"
@thameera
thameera / .ttytterrc
Created March 30, 2013 11:30
My primary .ttytterrc file. Filtered screen names have been removed.
# colors
ansi=1
# use streaming API
dostream=1
# use ssl
ssl=1
# prompt before sending tweet
@thameera
thameera / tpbsort.user.js
Last active December 15, 2015 15:28
User script to automatically sort search results in The Pirate Bay (http://thepiratebay.*) by seeders count.
// ==UserScript==
// @name The Pirate Bay Seeder Sort
// @namespace http://thameera.com
// @description Sorts the Pirate Bay results by seeder count
// @include *://thepiratebay.*/*/99/*
// @version 0.1
// ==/UserScript==
(function() {
document.location.pathname = document.location.pathname.replace(/99/, '7');
@thameera
thameera / tmuxtest.sh
Created April 16, 2013 16:27
Sample bash script to draw a tmux layout
#!/bin/bash
SN="tmuxwork"
tmux has-session -t $SN &>/dev/null
if [ $? != 0 ]
then
tmux new -s $SN -n conf -d
tmux new-window -t $SN:2 -n misc
@thameera
thameera / mbb
Created October 8, 2013 17:12
Connect to mobile broadband via terminal
#!/bin/bash
# Source: http://aithinking.wordpress.com/2012/06/13/startingstopping-mobile-broadband-services-in-linux/
# To get the connection name (id) and connection uuid, execute the following command
# nmcli -p con
# Replace defaultConnection and defaultConnectionsUUID with your own settings
defaultConnection="Dialog GSM Postpaid"
@thameera
thameera / pkill
Created October 15, 2013 06:08
pkill script
#!/bin/sh
# pkill
# be VERY careful with parameter $1
case $1 in
'' )
cat "$0"
;;
* )
for pid in $( ps -aW | grep -i $1 | awk '{ print $4 }' );
@thameera
thameera / countdown
Last active December 26, 2015 23:58
countdown script
#!/bin/bash
# USAGE
# ./countdown <num of seconds> <msg>
# eg:
# ./countdown 300 Time to rock!
date1=$((`date +%s` + $1));
shift
@thameera
thameera / tweet-linkify.js
Last active December 28, 2015 12:39 — forked from ghostrocket/tweet-linkify.js
Linkify the text of a tweet
var linkify_tweet = function(tweet) {
tweet = tweet.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig,"<a href='$1'>$1</a>");
tweet = tweet.replace(/(^|\s|\.)@(\w+)/g, "$1<a href=\"http://www.twitter.com/$2\">@$2</a>");
return tweet.replace(/(^|\s)#(\w+)/g, "$1<a href=\"http://search.twitter.com/search?q=%23$2\">#$2</a>");
};
@thameera
thameera / server
Created January 6, 2014 15:26
Start a simple server in the current directory
#!/bin/bash
# USAGE
# server [optional port]
PORT=${1:-9000}
python -m SimpleHTTPServer $PORT
@thameera
thameera / twitternag.user.js
Created April 23, 2014 03:25
Removes the nagging 'try teh new profile' banner. For Chrome, go to Tools-> Extensions and drag this file to it.
// ==UserScript==
// @name fuck you twitter
// @namespace http://thameera.com
// @description Removes the nagging 'try the new profile' banner
// @include *://twitter.com/*
// @version 0.1
// ==/UserScript==
(function() {
document.getElementsByClassName('BannersContainer')[0].style.display = 'none';