Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Joe Chasinga jochasinga

🏠
Working from home
Block or report user

Report or block jochasinga

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jochasinga
jochasinga / bst.es6
Created Feb 6, 2017
Binary search tree implemented in ES6
View bst.es6
'use strict';
class Node {
constructor(data) {
this.data = data;
this.left = undefined;
this.right = undefined;
}
@jochasinga
jochasinga / app.js
Last active Oct 8, 2019
Node/Socket.io server code for syncing data from Firebase
View app.js
var Firebase = require("firebase");
var express = require("express");
// Create HTTP Server
var app = express();
var server = require("http").createServer(app);
// Attach Socket.io server
var io = require("socket.io")(server);
// Indicate port 3000 as host
var port = process.env.PORT || 3000;
@jochasinga
jochasinga / DemoFingerprintActivity.java
Created Oct 3, 2019
Example of HeadSpin's HSFingerprintManager usage
View DemoFingerprintActivity.java
/*-
* #%L
* Demo Fingerprint Authentication Activity
* %%
* Copyright (C) 2019 Headspin Inc.
* %%
* #L%
*/
package com.nextunicorn.app;
View zipcode.ipynb
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 Mar 22, 2019
Fork and wait system calls
View fork_and_wait.c
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.
View refactor3.js
const baseConfig = {
mode: "cors",
cache: "no-cache",
credentials: "same-origin",
headers: {
"Content-Type": "application/json; charset=utf-8",
},
redirect: "follow",
referrer: "no-referrer",
};
View refactor2.js
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 Mar 7, 2019
Step one in refactor
View refactor1.js
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 / json_to_instances.go
Last active Jan 9, 2019
How to convert JSON blob into an array of instances
View json_to_instances.go
package main
import (
"encoding/json"
"fmt"
)
type Person struct {
Name string
Age int
@jochasinga
jochasinga / newton-sqrt.scm
Created Nov 19, 2018
Newton's method of finding a square root
View newton-sqrt.scm
(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
You can’t perform that action at this time.