Skip to content

Instantly share code, notes, and snippets.

@jochasinga
jochasinga / DemoFingerprintActivity.java
Created October 3, 2019 17:05
Example of HeadSpin's HSFingerprintManager usage
/*-
* #%L
* Demo Fingerprint Authentication Activity
* %%
* Copyright (C) 2019 Headspin Inc.
* %%
* #L%
*/
package com.nextunicorn.app;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jochasinga
jochasinga / fork_and_wait.c
Created March 22, 2019 19:20
Fork and wait system calls
include <stdio.h>
include <stdlib.h>
include <unistd.h>
include <sys/wait.h>
int main(int argc, char *argv[])
{
printf("hello world (pid:%d)\n", (int) getpid());
int rc = fork();
// Fork failed, let's exit.
const baseConfig = {
mode: "cors",
cache: "no-cache",
credentials: "same-origin",
headers: {
"Content-Type": "application/json; charset=utf-8",
},
redirect: "follow",
referrer: "no-referrer",
};
const baseConfig = {
mode: "cors",
cache: "no-cache",
credentials: "same-origin",
headers: {
"Content-Type": "application/json; charset=utf-8",
},
redirect: "follow",
referrer: "no-referrer",
};
@jochasinga
jochasinga / refactor1.js
Last active March 7, 2019 01:40
Step one in refactor
async function postLoginData(data) {
const loginUrl = `${apiBaseUrl}/login`;
let response = await fetch(loginUrl, {
method: "POST",
mode: "cors",
cache: "no-cache",
credentials: "same-origin",
headers: {
"Content-Type": "application/json; charset=utf-8",
},
@jochasinga
jochasinga / newton-sqrt.scm
Created November 19, 2018 12:34
Newton's method of finding a square root
(define (square-of x)
(define (average x y)
(/ (+ x y) 2))
(define (improve guess x)
(average guess (/ x guess)))
(define (good-enough? guess x)
(< (abs (- (square-of guess) x)) 0.001))
(define (sqrt-iter guess x)
(if (good-enough? guess x)
guess
@jochasinga
jochasinga / newton.csv
Created November 19, 2018 11:38
Table demonstrating Newton's square root method derivation
Guess Quotient Average
1 2/1 = 2 (2 + 1)/2 = 1.5
1.5 2/1.5 = 1.3333 1.3333 + 1.5/2 = 1.4167
1.4167 2/1.4167 = 1.4118 (1.4167 + 1.4118)/2 = 1.4142
1.4142 ... ...
@jochasinga
jochasinga / two_mod.ml
Created November 7, 2018 18:06
Ocaml modules
module State = struct
type t = int
let inc (n: t) = Transformer.inc n
end
;;
module Transformer = struct
let inc (n: State.t) = n + 1
end
;;
@jochasinga
jochasinga / matrix.ml
Created October 28, 2018 13:44
Experiment with matrix multiplication and dot product
let transpose A =
let new_mat = Array.make_matrix (Array.length A.(0)) (Array.length A) 0
in
for y = 0 to (Array.length A) - 1 do
for x = 0 to (Array.length A) - 1 do
new_mat.(y).(x) <- A.(x).(y)
done
done;
new_mat
in