Skip to content

Instantly share code, notes, and snippets.

@ludekstepan
ludekstepan / max31855.c
Created February 7, 2021 20:58
max31855 Raspberry Pi Pico lib
#include "pico/stdlib.h"
#include "hardware/spi.h"
#include "max31855.h"
static inline void max31855_cs_select(uint pin_cs) {
asm volatile("nop \n nop \n nop");
gpio_put(pin_cs, 0); // Active low
asm volatile("nop \n nop \n nop");
}
@ludekstepan
ludekstepan / day7p1.ts
Created December 7, 2019 19:59
Advent of code 2019
type Word = number
type Reader = Iterable<Word>
function* run(mem: Word[], input: () => Word) {
let position = 0
function* program() {
while (position < mem.length) {
yield mem[position++]
@ludekstepan
ludekstepan / day6.ts
Created December 7, 2019 18:53
Advent of code 2019
const input =
`COM)B
B)C
C)D
D)E
E)F
B)G
G)H
D)I
E)J
@ludekstepan
ludekstepan / day5.ts
Created December 6, 2019 20:57
Day 5 - Advent of code 2019
type Word = number
type Reader = Iterable<Word>
function run(mem: Word[], input: () => Word, output: (value: Word) => void) {
let position = 0
function* program() {
while (position < mem.length) {
yield mem[position++]
const input = [240298, 784956] as const
function findCodes(min: number, max: number) {
const results: number[] = []
next:
for (let i = min; i <= max; i++) {
const code = String(i)
const lineA = 'R997,D443,L406,D393,L66,D223,R135,U452,L918,U354,L985,D402,R257,U225,R298,U369,L762,D373,R781,D935,R363,U952,L174,D529,L127,D549,R874,D993,L890,U881,R549,U537,L174,U766,R244,U131,R861,D487,R849,U304,L653,D497,L711,D916,R12,D753,R19,D528,L944,D155,L507,U552,R844,D822,R341,U948,L922,U866,R387,U973,R534,U127,R48,U744,R950,U522,R930,U320,R254,D577,L142,D29,L24,D118,L583,D683,L643,U974,L683,U985,R692,D271,L279,U62,R157,D932,L556,U574,R615,D428,R296,U551,L452,U533,R475,D302,R39,U846,R527,D433,L453,D567,R614,U807,R463,U712,L247,D436,R141,U180,R783,D65,L379,D935,R989,U945,L901,D160,R356,D828,R45,D619,R655,U104,R37,U793,L360,D242,L137,D45,L671,D844,R112,U627,R976,U10,R942,U26,L470,D284,R832,D59,R97,D9,L320,D38,R326,U317,L752,U213,R840,U789,L152,D64,L628,U326,L640,D610,L769,U183,R844,U834,R342,U630,L945,D807,L270,D472,R369,D920,R283,U440,L597,U137,L133,U458,R266,U91,R137,U536,R861,D325,R902,D971,R891,U648,L573,U139,R951,D671,R996,U864,L749,D681,R255,U306,R154,U706,L817,D798,R109,D594,R496,D867,L217,D572
import { getHello } from './some-dep'
console.log(getHello())
@ludekstepan
ludekstepan / javascript
Last active August 29, 2015 14:17
Block scoping of 'let' in for loop
"use strict";
var stack = [];
for (let i = 0; i < 10; i++) {
console.log("inner: " + i);
i += 4;
stack.push(() => console.log("outer: " + i));
}
stack.forEach(f => f());
@ludekstepan
ludekstepan / Output
Last active August 29, 2015 14:17
Let in for loop
node --version
v0.12.0
node --harmony for-let.js
iterating 0
timeout 10
#!/bin/bash -e
# DECLARE FUNCTIONS
# branch_exists_local <branch>
function branch_exists_local {
git show-ref --verify --quiet "refs/heads/$1"
}
# branch_exists_remote <remote_branch>