Skip to content

Instantly share code, notes, and snippets.

View kyledinh's full-sized avatar

Kyle Dinh kyledinh

View GitHub Profile
@kyledinh
kyledinh / IsEven.elm
Created June 13, 2018 15:46
Elm on the command line
module IsEven exposing (output)
import List
getFirstArg : List String -> String
getFirstArg list =
case List.head list of
Nothing ->
"0"
Just val ->

Interactive Ruby Interface

  • irb
  • load file into IRB irb -r "./some_file.rb"
  • irb> load ".some_file.rb"

Escape codes

\n
\t
\"
let people = [
{ name: 'Bob', age: 28, child: { name: 'Sally', age: 8, grade: 3 } },
{ name: 'Sara', age: 46, child: { name: 'Lois', age: 14, grade: 9 } },
{ name: 'Ann', age: 27, child: { name: 'George', age: 9, grade: 4 } },
{ name: 'Dave', age: 52, child: { name: 'Hale', age: 17, grade: 11 } },
];
const add1 = (x) => x + 1;
const toFieldApplyFunc = (field, fn) => {
return (obj) => {
var APP = APP || {};
APP.deckURL = "https://gfx.tarot.com/images/site/decks/rider/full_size/"; // xx.jpg
APP.randCard = function () { return Math.floor((Math.random() * 77)) }; // 0 - 77
APP.mkTarotImg = function (id, cardNum) {
var cardNum = cardNum || APP.randCard();
var card = document.createElement("img");
card.id = id;
card.className = "tarot";
card.src = APP.deckURL + cardNum + ".jpg";
card.width = 100;
@kyledinh
kyledinh / golang-tls.md
Last active January 15, 2019 15:21 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
    
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
@kyledinh
kyledinh / v4.html
Last active August 29, 2015 14:05
Countdowner with xhr call
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h2><span id="countdown_clock"></span></h2>
<p>This is a countdown clock</p>
@kyledinh
kyledinh / countdown
Last active August 29, 2015 14:05
Simple Countdown Clock with a queue - example
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h2><span id="countdown_clock"></span></h2>
<p>This is a countdown clock</p>
@kyledinh
kyledinh / 0.md
Created October 13, 2013 01:33 — forked from disolovyov/0.md
  • [App Engine Go SDK][appengine-go-sdk]
  • [App Engine Go manual][appengine-go-manual]
  • [Go Specification][go-spec]
  • [Go standard library docs][go-core-docs]
  • Go's [error handling][thispltlife]. You can try figuring it out: there's a [blog post][errors-blog] and a [book section][errors-book]. Alternatively, you can give up and use two error-handling functions provided below.
func error2(err error, c appengine.Context) bool {
    if err != nil {
 c.Errorf("%v", err.Error())
@kyledinh
kyledinh / Installing-Ubuntu-on-Macbook-Air
Last active December 14, 2015 06:39
Direction to install Ubuntu 12 on Macbook Air hardware. I preferred to dual-boot.
Get the specs for the model MBA. My version was the Mac Book Air 3.1 11". Noted the graphics card so I could load the proper video driver post-installation.
http://www.everymac.com/systems/apple/macbook-air/specs/macbook-air-core-2-duo-1.4-11-late-2010-specs.html
Ubuntu 12.10 (Quantal Quetzal)
http://releases.ubuntu.com/12.10/
64-bit Mac (AMD64) desktop image
http://releases.ubuntu.com/12.10/ubuntu-12.10-desktop-amd64+mac.iso
Since my MBA doesn't have a floppy or cd-rom, I have to install it via USB-stick. I found several pages to install the ubuntu iso onto a usb-stick.