Skip to content

Instantly share code, notes, and snippets.

View drcircuit's full-sized avatar

Espen Sande Larsen drcircuit

View GitHub Profile
<canvas><script>for(g=150,c=document,c.bgColor=0,d=c.body.lastChild,e=d.getContext("2d"),q=[],R=Math.random,m=g;m--;)q[m]={x:0,y:0,z:R()*g};setInterval(t=>{for(e.reset(),i=0;i<g;i++)s=q[i],s.z-=2,s.z<=0&&(s.z=g,s.x=R()*g,s.y=R()*g),k=g/s.z,x=(s.x-g/2)*k+g/2,y=(s.y-g/2)*k+g/2,x>0&x<g&y>0&y<g&(c=g-g*s.z/g,e.fillStyle="rgb("+[c,c,c],e.fillRect(x,y,3,3))})</script>
#!/bin/sh
while getopts "dte:h?" opt ; do
case "$opt" in
h|\?)
printf "usage: %s -e KEY=VALUE prog [args...]\n" $(basename $0)
exit 0
;;
t)
tty=1
#ascii
def read(file):
with open(file, 'r') as file:
decimals = file.read().split()
ascii = [chr(int(decimal)) for decimal in decimals]
mesage = ''.join(ascii)
print(mesage)
@drcircuit
drcircuit / bankterminal.c
Last active August 28, 2019 18:20
SourceCode for the Bank Terminal
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <stdbool.h>
struct account
{
char name[16];
int balance;
bool is_gold_customer;
@drcircuit
drcircuit / matrisprojection.js
Created February 27, 2019 09:24
Some Matrix functions for 3d projection
function matrix(m){
return m || [
[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,0,0,1],
];
}
function projectionmatrix(fov,aspect,znear,zfar){
@drcircuit
drcircuit / mandel.js
Created February 13, 2019 17:16
Generalized Mandelbrot in JavaScript
/** mandel5 */
// Uses DrCiRCUiT's Canvas Library, but you can change the drawing / canvas methods for something else.
(function () {
var scr;
var plane = {
real: { min: -2, max: 2 },
imag: { min: -2, max: 2 }
};
function setup() {
scr = dcl.setupScreen(512, 512);
@drcircuit
drcircuit / sensor.ido
Last active December 12, 2018 14:28
Stuff For Einar
/***********************************************************************
Telenor NB-IoT Hello World
Configures NB-IoT, connects and sends a message every 15 minutes.
See our guide on how to connect the EE-NBIOT-01 to Arduino:
https://docs.nbiot.engineering/tutorials/arduino-basic.html
This example is in the public domain.
[Route("api/badbutpossible/[controller]")]
public class StuffController: Controller
{
[HttpGet]
public async Task Get()
{
var jsonString = "{\"foo\":\"bar\", \"index\":12}";
Response.ContentType = "application/json";
var buffer = System.Text.Encoding.UTF8.GetBytes(jsonString);
await Response.Body.WriteAsync(buffer, 0, buffer.Length);

My investigations into the Corda Framework and the Kotlin programming language.

Corda

Corda is a blockchain ledger framework written in Kotlin. It runs on the JVM 8 or later.

Kotlin

Kotlin is a multi-paradigm programming language for the JVM. Even though it supports a traditional strict object oriented programming style, it is super biased towards guiding you into a functional approach. Not that different from C# after C# 6.0. It has a lot of productivity gains over regular Java, since it provides things like getters / setter implicitly and does type inference. It strictly enforces immutability, so it forces you to use good programming practices and coding diciplines to create your applications.

SLOC count is held pretty low because you are not required to write heaps of boilerplate code like you do in Java.

@drcircuit
drcircuit / scopethisevilness.js
Created September 27, 2017 21:55
The evil that is "this"
//this is how we are taught to encapsulate in JavaScript, should be safe right?
function list(){
var protectedArray = [];
return {
append: function(val){
protectedArray.push(val);
},
store: function(idx, val){
protectedArray[idx] = val;
},