Skip to content

Instantly share code, notes, and snippets.

Chris hinzundcode

Block or report user

Report or block hinzundcode

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
View dispatcher.rs
use std::collections::HashMap;
use futures::Future;
use futures::prelude::*;
use std::pin::Pin;
use futures_timer::Delay;
use std::time::Duration;
use serde::de::DeserializeOwned;
use serde_json::{json, Value};
use serde::{Serialize, Deserialize};
View main.rs
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_assignments)]
#![allow(unused_mut)]
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(unreachable_code)]
use futures::lock::Mutex;
use futures::future::select_all;
@hinzundcode
hinzundcode / main.c
Created Jul 7, 2019
nrf52840 scan for ble advertisements, based on the nrf5 sdk ble_central/ble_app_hrs_c example
View main.c
/**
* Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
View scanlines.html
<!DOCTYPE html>
<canvas id="canvas" style="width: 200px; height: 200px; border: 1px solid #000;" width=200 height=200></canvas>
<script type="module">
const circle = (mx, my, r) => (x, y) => Math.pow(x - mx, 2) + Math.pow(y - my, 2) < Math.pow(r, 2);
let canvas = document.getElementById("canvas");
let context = canvas.getContext("2d");
let drawables = [
{
View stream-pair.js
"use strict";
const { Transform } = require("stream");
function createStreamPair() {
let config = {
objectMode: true,
transform(chunk, encoding, callback) {
this.other.push(chunk);
callback();
View clock.js
function update() {
var now = new Date();
var minutes = now.getMinutes();
if (minutes < 10)
minutes = "0"+minutes;
var seconds = now.getSeconds();
if (seconds < 10)
seconds = "0"+seconds;
var time = now.getHours()+":"+minutes+":"+seconds;
@hinzundcode
hinzundcode / StringView.js
Created May 5, 2018
read and write strings from arraybuffers
View StringView.js
function strlen(buffer, byteOffset, byteLength) {
let array = new Uint8Array(buffer, byteOffset, byteLength);
for (let i = 0; i < array.length; i++) {
if (array[i] == 0)
return i;
}
throw new Error("invalid string: not ending with null byte");
}
View pipe.js
"use strict";
const ffi = require("ffi");
const ref = require("ref");
const ArrayType = require("ref-array");
const { createReadStream, createWriteStream, readSync, writeSync, closeSync } = require("fs");
let IntArray = ArrayType("int");
let StringArray = ArrayType("string");
let voidPtr = ref.refType(ref.types.void);
View fork.js
"use strict";
const ffi = require("ffi");
const ref = require("ref");
const ArrayType = require("ref-array");
let StringArray = ArrayType("string");
let voidPtr = ref.refType(ref.types.void);
let stdlib = ffi.Library(null, {
"fork": ["int", []],
@hinzundcode
hinzundcode / libc.js
Created Jan 16, 2018
call execve from nodejs!
View libc.js
const { syscall, getAddress } = require("libsys");
const os = require("os");
if (os.endianess() != "LE")
throw "only little endian supported";
let dontGC = [];
function ref(buffer) {
dontGC.push(buffer);
return getAddress(buffer);
You can’t perform that action at this time.