Skip to content

Instantly share code, notes, and snippets.

View smallnest's full-sized avatar

smallnest smallnest

View GitHub Profile
@smallnest
smallnest / webapp_android.java
Created September 6, 2016 05:34 — forked from karthiks/webapp_android.java
Convert HTML5 into standalone Android App
//Ref. http://stackoverflow.com/questions/12840977/convert-html5-into-standalone-android-app
//Ref. http://gamedev.stackexchange.com/questions/8599/packaging-html5-games-as-applications-for-iphone-android
//1. Create an Android app using Eclipse.
//2. Create a layout that has a <WebView> control.
public class WebApp extends Activity {
protected void onCreate(Bundle savedInstanceState) {
WebView wv = new WebView(this);
wv.loadUrl("http://www.myapp.com/");

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@smallnest
smallnest / etc-init.d-hello-world
Created September 27, 2016 04:29 — forked from josephspurrier/etc-init.d-hello-world
/etc/init.d Script for Go Application
#!/bin/bash
#
# chkconfig: 35 95 05
# description: Hello world application.
# Run at startup: sudo chkconfig hello-world on
# Load functions from library
. /etc/init.d/functions
@smallnest
smallnest / HaversinFormula.go
Created September 27, 2016 06:48 — forked from cdipaolo/HaversinFormula.go
Golang functions to calculate the distance in meters between long,lat points on Earth.
// haversin(θ) function
func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
// Distance function returns the distance (in meters) between two points of
// a given longitude and latitude relatively accurately (using a spherical
// approximation of the Earth) through the Haversin Distance Formula for
// great arc distance on a sphere with accuracy for small distances
//
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@smallnest
smallnest / grace.go
Created February 10, 2017 06:29 — forked from rcrowley/grace.go
Graceful stop in Go
package main
import (
"log"
"net"
"os"
"os/signal"
"sync"
"syscall"
"time"
#install pdftk
#export LC_CTYPE=C # if you encounter "sed: RE error: illegal byte sequence"
pdftk original.pdf output uncompressed.pdf uncompress
sed -e "s/Download from Wow! eBook \<www.wowebook.com\>/ /g" < uncompressed.pdf > temp.pdf
pdftk temp.pdf output fixed.pdf compress
rm temp.pdf
//https://github.com/lemonlatte/raft-example
package main
import (
// "encoding/json"
"encoding/json"
"fmt"
"github.com/hashicorp/raft"
"github.com/hashicorp/raft-boltdb"
"io"
{
"Name": "Elvis",
"Location": "Memphis"
}
@smallnest
smallnest / translate.go
Created May 12, 2017 09:17 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//