Skip to content

Instantly share code, notes, and snippets.

@jargnar
jargnar / 0062_unique_paths_stupid_solution.py
Created March 21, 2020 15:48
0062_unique_paths_stupid_solution.py
"""
The naive/stupid version where I actually created a tree... for unique paths...
<https://leetcode.com/problems/unique-paths>
before I realised we could just do simple DP of: #paths(i, j) = #paths(i, j + 1) + #paths(i + 1, j)
ouch.
"""
s0, r0, g0, p0, n0 = :C3, :D3, :E3, :G3, :B3
s, r, g, p, n = :C4, :D4, :E4, :G4, :B4
s2, r2, g2, p2, n2 = :C5, :D5, :E5, :G5, :B5
define :maya do
sleep 3
play_pattern_timed [s, s, r, s, r, s, r, r], 0.75, release: 3
sleep 3
play_pattern_timed [s, r, g, s, r, s, r, r], 0.75, release: 3
@jargnar
jargnar / duplicated_accumulator.go
Last active December 9, 2018 14:09
Find duplicated accumulator from a stream
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"github.com/AndreasBriese/bbloom"
)
@jargnar
jargnar / mysqrt.rkt
Last active October 7, 2018 08:39
Square-rooting in Racket
#lang racket
(define (mysqrt x)
;; a procedure to calculate square root of a number
;; starts with a guess and improves it until it is good enough
;; a guess can be improved by averaging itself with x/guess
(define (avg a b) (/ (+ a b) 2.0))
(define (improve-guess guess x) (avg guess (/ x guess)))
@jargnar
jargnar / restoreS3DeletedObjects.sh
Created July 28, 2018 08:57
Restore deleted S3 Objects by Prefix
bucket="SOME_BUCKET_NAME"
prefix="SOME_PREFIX"
objects="["
printf "\n\n>>> SALVAGING LOST DATA NOW\n\n"
while :
do
count=0
@jargnar
jargnar / .vimrc
Created July 15, 2018 09:51
vimrc
" Suhas vimrc
" MIT License
" Copyright 2018, <[email protected]>
"----------------------------------------
" System: plugin manager
"----------------------------------------
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
@jargnar
jargnar / lightitup.ino
Last active May 6, 2018 13:01
Light it up - use photo resistor to light LED automatically in darkness
#define LED 8
#define PHOTORESISTOR A0
#define THRESHOLD 200
void setup()
{
Serial.begin(9600);
pinMode(LED, OUTPUT);
pinMode(PHOTORESISTOR, INPUT_PULLUP);
Serial.println("Hello, Arduino");
@jargnar
jargnar / hello.ino
Last active May 6, 2018 12:18
Hello Arduino
#define BUTTON 5
#define LED 8
void setup()
{
Serial.begin(9600);
pinMode(LED, OUTPUT);
pinMode(BUTTON, INPUT_PULLUP);
Serial.println("Hello, Arduino");
}
@jargnar
jargnar / asciiart.scala
Last active December 11, 2017 11:00
ASCII Art from Codingame
/*
MIT License
Copyright 2017 Suhas SG <[email protected]>
*/
import scala.util._
object Solution extends App {
val l = readInt
val h = readInt
@jargnar
jargnar / style.mss
Last active May 4, 2017 03:35
Example carto css
Map {
background-color: #444;
}
#countries {
::outline {
line-color: #aaa;
line-width: 1;
line-join: round;
}