Skip to content

Instantly share code, notes, and snippets.

View janithl's full-sized avatar

Janith Leanage janithl

View GitHub Profile
@janithl
janithl / SlotSelector.tsx
Last active July 4, 2021 18:22
A simple React Native component to select slots in a timeline
import React, { useState } from 'react';
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
const SlotSelector = () => {
const [selected, setSelected] = useState([0, 0]);
const slots = [1, 2, 3, 4, 5, 6, 7, 8];
const onSelect = (index: number) => {
if (selected[0] === selected[1] && selected[1] === 0) {
setSelected([index, index]);
@janithl
janithl / timeline.svg
Last active May 17, 2020 16:35
Timeline of US late night shows on the 3 major networks. This file is released under a CC0 license: https://creativecommons.org/share-your-work/public-domain/cc0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
package main
import (
"encoding/json"
"io/ioutil"
"net/http"
"os"
"regexp"
"time"
)
[{
"id": 1,
"name": "Grape Soda Lupine"
}, {
"id": 2,
"name": "Pseudoleskeella Moss"
}, {
"id": 3,
"name": "Rosette Lichen"
}, {
@janithl
janithl / himal.json
Created April 13, 2019 12:33
A JSON dump of ~4 months of Himal tweets
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": [],
@janithl
janithl / site.conf
Last active February 2, 2019 16:38
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;
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 October 5, 2018 06:12
A simple Go utility for work, where we need to get the version of a site through its generator meta tag
package main
import (
"bufio"
"fmt"
"io/ioutil"
"net/http"
"os"
"regexp"
"strconv"
@janithl
janithl / hello.go
Created September 3, 2018 11:11
HelloWorld in 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 September 3, 2018 11:10
A simple Goroutine exercise, where a worker thread reads user input through a channel
package main
import (
"bufio"
"fmt"
"os"
"time"
)
type message struct {