Skip to content

Instantly share code, notes, and snippets.

View thameera's full-sized avatar

Thameera Senanayaka thameera

View GitHub Profile
@ghostrocket
ghostrocket / tweet-linkify.js
Created December 31, 2010 16:54
Linkify Tweet in Javascript
String.prototype.linkify_tweet = function() {
var tweet = this.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>");
};
@briancavalier
briancavalier / simple-promise-retry.js
Created February 24, 2011 18:35
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@pvieytes
pvieytes / read_tweets.py
Created May 18, 2011 07:16
Parsing Twitter's user time with Python
import Tweet
import simplejson
import urllib2
def read_tweets(user, num_tweets):
tweets = []
url = "http://api.twitter.com/1/statuses/user_timeline.json?\
screen_name=%s&count=%s&include_rts=true" % (user, num_tweets)
file = urllib2.urlopen(url)
@gaveen
gaveen / .vimrc-snip
Created December 9, 2011 19:27
Part of my vimrc which sets indentation (tabs, spaces, etc.)
" I'm using the following config to make my code look the same everywhere.
set bs=indent,eol,start " allow backspacing over everything
set autoindent " enable auto-indentation
set tabstop=2 " no. of spaces for tab in file
set shiftwidth=2 " no. of spaces for step in autoindent
set softtabstop=2 " no. of spaces for tab when editing
set expandtab " expand tabs into spaces
set smarttab " smart tabulation and backspace
@febuiles
febuiles / songs.md
Last active July 1, 2022 03:45
Fetching lyrics in Unix

Fetching lyrics in the command line

Objective: Print the lyrics for the current playing song.

How: We'll create a small bash script to do the fetching for us (using curl) and then we'll display it either in the terminal or in our $EDITOR

Get the current song

First we'll need to get the name of the current song and its artist:

@chanux
chanux / fixsrt.py
Created March 15, 2012 07:11
A simple python tool to fix time of srt files
#!/usr/bin/env python
from sys import argv, exit
from os import path
import datetime
if len(argv) == 5:
(script, inputf, outputf, sign, msec) = argv
else:
print "fixsrt <input.srt> <output.srt> <+/-> <milli seconds>"
exit(1)
@sfate
sfate / vim-on-heroku.sh
Created June 7, 2012 14:39 — forked from naaman/vim-on-heroku.sh
vim on heroku
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active June 13, 2024 02:39
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@tfnico
tfnico / git-developers.md
Last active December 22, 2021 13:59
When and how to contact the Git developers

Before you send an email to the Git developers' mailing list

If you are a normal Git user, and you have problems using Git, you can also try:

If you believe you've found a bug in Git for Windows or msysGit (Windows-specific), first check their issue tracker to see if the problem has already been reported. If not, send a message to msysgit@googlegroups.com or visit the online forum version.

# Get the compile-dependencies of vim
sudo apt-get build-dep vim
# If you haven't got mercurial, checkinstall
sudo apt-get install mercurial checkinstall
# Get the source
hg clone https://vim.googlecode.com/hg/ vim
# Compile it
cd vim
./configure \
--enable-luainterp=dynamic \