Skip to content

Instantly share code, notes, and snippets.

View kiranshila's full-sized avatar

Kiran Shila kiranshila

View GitHub Profile
@kiranshila
kiranshila / 1.clj
Created December 1, 2019 19:03
AoC 2019 - Day 1
(ns aoc2019.core)
;; Part 1
(defn fuel [mass]
(- (int (Math/floor (/ mass 3))) 2))
;; Read File
(def input
(->> (slurp "1.txt")
clojure.string/split-lines
@kiranshila
kiranshila / 2.jl
Created December 2, 2019 05:23
AoC 2019 - Day 2
program = [parse(Int64,i) for i in split(readline("2.txt"),',')]
program[2] = 12
program[3] = 2
function runIntcode!(program,offset=1)
# Step 1 - Get opcode
opcode = program[offset]
if opcode == 1
# Add routine
(defmacro comprehension [binding & body]
`(lazy-seq (map (fn [~(first binding)] ~@body) ~(second binding))))

Keybase proof

I hereby claim:

  • I am kiranshila on github.
  • I am kiranshila (https://keybase.io/kiranshila) on keybase.
  • I have a public key whose fingerprint is 3543 5D6C 3513 E5F6 E4DB A128 91B5 B58D 98E0 3214

To claim this, I am signing this object:

@kiranshila
kiranshila / big_flash.md
Created August 14, 2020 04:28
Expanding Espruino's js_code partition for larger ESP32s

Motivation

Recently, I have been playing around with the Esprit project which is an attempt to run ClojureScript on microcontrollers using the Espruino microcontroller-based JS interpreter. As per Mike's talk here, the real trick is to setup Espruino such that it has enough space to hold cljs.core and all your program code. This ends up at least around 900KB.

Now for those unfamiliar, the ESP32 is configured with a partition table - allocating different sections of memory to the program code, non-volatile storage, the bootloader, etc. These partitions can be arbitrarily resized. Additionally, one can make partitions that don't mean anything to the ESP32, but can yield pointers in the C code that help manage the separate parts of memory.

As modern ESP32s ship with TONS of flash, we want to make the partition that Espruino calls js_code as large as possible to take full advant

@kiranshila
kiranshila / coax_thermal.jl
Last active June 14, 2021 01:36
Coax heat transfer analysis
using DifferentialEquations
using BoundaryValueDiffEq
using DiffEqCallbacks
using ForwardDiff
using Plots
struct Material
k_coefs::Vector
end
Temperature k
4 0.00288
7 0.00531
10 0.00796
15 0.0129
20 0.0183
25 0.0241
30 0.0304
40 0.0438
50 0.0566
Temperature k
15.11301551884327 0.07465345102636006
16.325628243123717 0.07884802260357432
20.076097262888098 0.08268964562569214
23.494475529653513 0.08662403517098391
27.634850794789116 0.08985372781740777
32.15806896327027 0.09409680300788886
37.2771158187594 0.09912418088410396
45.66492795653713 0.10343154243428185
50.89389884139038 0.10772070911868079
Temperature rho
1 12.4e-6
4 12.4e-6
7 12.4e-6
10 12.4e-6
15 12.4e-6
20 12.4e-6
30 12.5e-6
40 12.6e-6
50 12.8e-6
@kiranshila
kiranshila / Makefile
Last active November 15, 2021 01:40
Makefile for NOVAS C3.1
.PHONY : clean
CFLAGS = -fPIC -O2
LDFLAGS = -shared
TARGET = novas.so
SOURCES = solsys1.c readeph0.c eph_manager.c nutation.c novascon.c novas.c
OBJECTS = $(SOURCES:.c=.o)
all: $(TARGET)