Skip to content

Instantly share code, notes, and snippets.

Janith Leanage janithl

Block or report user

Report or block janithl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@janithl
janithl / himal.json
Created Apr 13, 2019
A JSON dump of ~4 months of Himal tweets
View himal.json
This file has been truncated, but you can view the full file.
[
{
"created_at": "Thu Nov 15 10:31:45 +0000 2018",
"id": 1063016696879824897,
"id_str": "1063016696879824897",
"text": "SLPP Muslims? Is that like Gestapo Jews?",
"truncated": false,
"entities": {
"hashtags": [],
View site.conf
server {
listen 80;
index index.php index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www;
location / {
try_files $uri $uri/ /index.php;
View docker-compose.yml
version: "2"
services:
webserver:
image: nginx:alpine
ports:
- "8000:80"
volumes:
- .:/var/www
- ./docker/nginx/site.conf:/etc/nginx/conf.d/default.conf
@janithl
janithl / version.go
Last active Oct 5, 2018
A simple Go utility for work, where we need to get the version of a site through its generator meta tag
View version.go
package main
import (
"bufio"
"fmt"
"io/ioutil"
"net/http"
"os"
"regexp"
"strconv"
@janithl
janithl / hello.go
Created Sep 3, 2018
HelloWorld in Go
View hello.go
package main
import "fmt"
import "time"
func main() {
fmt.Println("ආයුබෝවේවා, මහරජානනි.")
var t = time.Now()
fmt.Printf("දැන් වේලාව %02d:%02d\n", t.Hour(), t.Minute())
@janithl
janithl / goroutines.go
Created Sep 3, 2018
A simple Goroutine exercise, where a worker thread reads user input through a channel
View goroutines.go
package main
import (
"bufio"
"fmt"
"os"
"time"
)
type message struct {
@janithl
janithl / httpClient.go
Created Sep 3, 2018
Simple client that HTTP gets and JSON parses an endpoint
View httpClient.go
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
View testlang.py
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')
View getlang.py
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):
@janithl
janithl / unp.csv
Created Sep 11, 2016
UNP general election electoral numbers, 1947 - 2015
View unp.csv
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
You can’t perform that action at this time.