Skip to content

Instantly share code, notes, and snippets.

View islandjoe's full-sized avatar

Arthur Kho islandjoe

  • Helsinki, Finland
View GitHub Profile
@islandjoe
islandjoe / rust--print-name-starts-with-a
Created May 30, 2020 06:51
Rust: Print name if it starts with 'A'
```rust
use std::env::args;
fn main() {
for name in args() {
if let Some(char_1) = name.chars().next() {
match char_1 {
'A' => println!("Hello, {}!", name),
_ => {}
}
@islandjoe
islandjoe / minmax.md
Created August 17, 2019 06:46
Clamp value to between 0 and 5
let v = 0

min( max( v, 0), 5)

if v <= 0 { v = 0 }
else
if v >= 5 { v = 5 }

v &lt;= 0 ? 0 : (v &gt;= 5 ? 5 : (v))
@islandjoe
islandjoe / compile.sh
Last active July 18, 2020 16:37 — forked from adisuryadi/compile.sh
Run ES6 in Coderunner via Babel
#!/bin/bash
#
# This script will create transpile ES6 (with JSX) support in babel
# to ES5 that evaluatable in regular node.js
# Script will create a filename.out file, evaluates it, then remove the file.
#
# First off, you'll need Node.js.
#
# Steps:
# 1) Install babel globally npm install -g babel-cli
@islandjoe
islandjoe / func_locationManager.md
Created December 28, 2018 16:16
Stop updating the location immediately as soon as the location manager gets a valid value.
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    let location = locations[locations.count - 1]
    if location.horizontalAccuracy > 0 {
      locationMgr.stopUpdatingLocation()
    }
  }
@islandjoe
islandjoe / Reflective Exercise.md
Created December 26, 2018 19:56
Read and answer the questions when you complete big/new/challenging tasks.

Relection on ______________

What did I do well?

How closely did expectations match reality?

If I did this again, would I do differently?

What surprised me? Problems, obstacles, people, shortcuts, help?

@islandjoe
islandjoe / machine learning data preprocessing.md
Created December 8, 2018 11:30
Data preprocessing template for Machine Learning in R
# Import dataset:
dataset = read.csv('Data.csv')
#dataset = dataset[, 2:3]

# Split dataset into training and test sets:
#install.packages('caTools')
library(caTools)
set.seed(101)
split = sample.split(dataset$Purchased, SplitRatio = 0.8)
@islandjoe
islandjoe / gist:5c971213887ac59baf27282eeec52db2
Created November 23, 2018 12:50
Print "Hello world" in MicroView.
#include <MicroView.h>

void setup() {
	uView.begin();
	uView.clear(PAGE);
	
	uView.print("Hello world");
	
	uView..display()

In a Column Space, the coefficient vector is post-multiplied:

col space

In a Row Space, the coefficient vector is pre-multiplied:

row space

@islandjoe
islandjoe / meme-machine-02-03.txt
Created June 25, 2018 08:30
Meme Machine: home.leaf
#set("title") { Home }
#set("body") {
<h1>Files</h1>
#for(file in files) {
<a href="/uploads/originals/#(file)" target="_blank">
<img src="/uploads/thumbs/#(file)"
style="border: 1px solid black; margin: 20px;" />
</a>
@islandjoe
islandjoe / meme-machine-02-02.txt
Created June 25, 2018 08:27
Meme Machine: configure.swift - Config Leaf template engine
try services.register(LeafProvider())
config.prefer(LeafRenderer.self, for: ViewRenderer.self)
var middleware = MiddlewareConfig.default()
middleware.use(FileMiddleware.self)
services.register(middleware)