Skip to content

Instantly share code, notes, and snippets.

View nilsmartel's full-sized avatar
🦖

Nils Martel nilsmartel

🦖
View GitHub Profile
@nilsmartel
nilsmartel / quickhash.js
Created July 7, 2023 13:03
Quick and insecure string hashing function in js
export const quickhash = (n) => [...n].map(s => s.charCodeAt(0)).reduce((a, b) => ((a << 3) ^ b) & ((1 << 31) - 1), 0)
[keys.normal]
"K" = ["goto_prev_paragraph", "collapse_selection"]
"J" = ["goto_next_paragraph", "collapse_selection"]
0 = "goto_line_start"
"$" = "goto_line_end"
[keys.select]
p = "replace_selections_with_clipboard"
y = "yank_joined_to_clipboard"
@nilsmartel
nilsmartel / indocker.py
Created April 14, 2022 11:03
Mount current directory inside an docker container and continue working inside of linux
#!/usr/local/bin/python3
import os
import sys
# some basic argument parsing, so that ports, entrycommand and image can be specified
def args():
image = 'node'
cmd = 'bash'
ports = []
(ns beer-song
(:require [clojure.string :as string]))
(require '[clojure.core.match :refer [match]])
;; 2 bottles of beer on the wall, 2 bottles of beer.
;; Take one down and pass it around, 1 bottle of beer on the wall.
;; 1 bottle of beer on the wall, 1 bottle of beer.
;; Take it down and pass it around, no more bottles of beer on the wall.
@nilsmartel
nilsmartel / complexTyp3Grammar.js
Created November 21, 2020 15:46
Typ 3 Grammar to test if zipped representation of 2 binary numbers a and b is b= a+1
let log = n => console.log(n)
function binary(n) {
if (n == 0) return '0'
if (n == 1) return '1'
let last = String(n & 1 )
return binary(n >> 1) + last
}
use vulkano::device::Device;
use vulkano::device::DeviceExtensions;
use vulkano::device::Features;
use vulkano::instance::Instance;
use vulkano::instance::InstanceExtensions;
use vulkano::instance::PhysicalDevice;
const DEVICE_ID: usize = 1;
fn main() {
let instance =
@nilsmartel
nilsmartel / fibonacci.rs
Created September 14, 2017 15:56
Fibonacci in Rust (Testing out Gist)
fn main() {
fib(0, 1, 75);
}
fn fib(a: u64, b: u64, count: u32) {
println!("{}", a);
if count > 0 {
fib(b, a+b, count-1);
void rasterTri(double[][] v){
int len = v[0].length;
int up = 0;
int down = 0;
for(int i=1; i<3;i++){
if(v[i][1] < v[up][1]) up=i;
if(v[i][1] > v[down][1]) down=i;
}
int[] id= new int[3];