Skip to content

Instantly share code, notes, and snippets.

View janithl's full-sized avatar

Janith Leanage janithl

View GitHub Profile
@janithl
janithl / feed.php
Last active November 18, 2021 07:54
PHP script for turning your Google+ feeds into valid RSS. You need to edit a couple of places but I'm sure you're smart enough to figure that out... :)
<?php
header('Content-type: text/xml');
$gendate = date('r', time());
$config = array(
'gplusid' => '116783522121096138585',
'gplusname' => 'Janith Leanage',
'hosturl' => 'http://janith.vacau.com/gplus'
@janithl
janithl / timer.c
Created March 23, 2012 13:27
Silly little C code I wrote to record the time I spent doing past paper questions. Not technically sound or anything, but it works for me. :P
/*
Silly program to lap time and stuff, by Janith Leanage.
Uses signal handling code. :P
*/
#include<stdio.h>
#include<signal.h>
int count[100];
int c = 0;
@janithl
janithl / Obstang.xml
Created August 30, 2012 05:23
Gedit theme, a cross between Vim's mustang and Gedit's Oblivion
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2012
Author: Bernhard Posselt <[email protected]>
Henrique C. Alves <[email protected]>
Janith Leanage
This file is free software; you can redistribute it and/or
@janithl
janithl / subreddit.css
Created March 7, 2015 16:06
Old /r/srilanka stylesheet
/* New Style Beta Header */
#header{background-image:url(%%disp3%%);height:110px;background-color:#540f12;background-repeat:no-repeat;background-position:right;border-bottom:3px solid #f8c221}
.user a,.separator,.pref-lang,.logout a{color:#fff}
#header-bottom-right{background:none}
#header-bottom-left{position:absolute;bottom:0}
.tabmenu li{display:inherit}
.tabmenu li a{font-size:20px;font-weight:100;color:#fff;background:none;border:none;}
.tabmenu li.selected a{background:none;border:none;}
.formtab li{display:inline; padding-left:0;}
.formtab li a{font-size:100% !important;font-weight:100;color: #369 !important;background:none;border:none;}
@janithl
janithl / sinhala.js
Created October 19, 2015 09:16
The Sinhala Object for transliterating Latin <-> Sinhala
/**
* Sinhala transliterator class
* Based on the UCSC Real Time Unicode Converter
* http://www.ucsc.cmb.ac.lk/ltrl/services/feconverter/t1.html
The MIT License (MIT)
Copyright (c) 2014 Janith Leanage
Permission is hereby granted, free of charge, to any person obtaining a copy
"Post ID",
Permalink,
"Post Message",
Type,
Countries,
Languages,
Posted,
"Lifetime Post Total Reach",
"Lifetime Post organic reach",
"Lifetime Post Paid Reach",
@janithl
janithl / unp.csv
Created September 11, 2016 07:10
UNP general election electoral numbers, 1947 - 2015
Election Leader Valid Votes Votes Won % Votes Total Seats Seats Won % Seats W/L Diff
1947 D. S. Senanayake 1887364 751432 39.81 95 42 44.21 W 4.40
1952 Dudley Senanayake 2327626 1026005 44.08 95 54 56.84 W 12.76
1956 John Kotelawala 2647247 738810 27.91 95 8 8.42 L 19.49
March 1960 Dudley Senanayake 3041420 909043 29.89 151 50 33.11 W 3.22
July 1960 Dudley Senanayake 3076869 1144166 37.19 151 30 19.87 L 17.32
1965 Dudley Senanayake 4046720 1590929 39.31 151 66 43.71 W 4.39
1970 Dudley Senanayake 4991798 1892525 37.91 151 17 11.26 L 26.65
1977 J. R. Jayewardene 6243573 3179221 50.92 168 140 83.33 W 32.41
1989 R. Premadasa 5596468 2838005 50.71 225 125 55.56 W 4.84
@janithl
janithl / getlang.py
Last active December 18, 2016 06:23
from collections import defaultdict
UNICODE_BLOCKS = {
'en': range(0x0000, 0x02AF),
'si': range(0x0D80, 0x0DFF),
'ta': range(0x0B80, 0x0BFF),
'dv': range(0x0780, 0x07BF)
}
def getlang(text):
import unittest
from getlang import getlang
class TestLang(unittest.TestCase):
"""Tests for `getlang.py`."""
def test_is_english(self):
self.assertTrue(getlang('hello') == 'en')
self.assertTrue(getlang('<2323$(@*(*&^&@^#>e') == 'en')
self.assertTrue(getlang('a') == 'en')
@janithl
janithl / httpClient.go
Created September 3, 2018 11:09
Simple client that HTTP gets and JSON parses an endpoint
package main
import "net/http"
import "fmt"
import "io/ioutil"
import "encoding/json"
// Artist is a struct to hold artist values
type Artist struct {
Name, Shortname, Reknown, Bio string