Skip to content

Instantly share code, notes, and snippets.

@nikhilm
nikhilm / Cargo.toml
Created September 4, 2019 19:50
rustc staticlib bug
[package]
edition = "2018"
name = "hello_world"
version = "0.1.0"
[lib]
crate-type = ["staticlib"]
name = "hello_world"
[dependencies]
@nikhilm
nikhilm / code.py
Created October 24, 2021 22:13
Adafruit Bluefruit BLE bluetooth proximity bike light
import time
import adafruit_ble
from adafruit_ble import BLERadio
from adafruit_ble.advertising import Advertisement
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.standard.device_info import DeviceInfoService
# from adafruit_ble.services.standard.hid import HIDService
from adafruit_circuitplayground import cp
@nikhilm
nikhilm / confine.sh
Created October 27, 2022 15:58
Run a process in a cgroupv1 to limit CPU and memory usage. Useful for Ubuntu Bionic
#!/bin/bash
# All credit for figuring out these incantations goes to https://utcc.utoronto.ca/~cks/space/blog/linux/CgroupsForMemoryLimiting
#
# Script to run a command in a v1 cgroup limiting CPU and memory.
# Use as `./confine.sh command <other args>`.
# This is tested on Ubuntu Bionic.
# You will need to install the `cgroup-tools` package from `apt` first.
# Remember to tweak the limits based on your machine.
# `sudo` is required to create the cgroup, but the build itself is run as a normal user.
{
inputStream: {
name: "Live",
type: "LiveStream",
constraints: {
width: {min:640},
height: {min:480},
facingMode: "environment",
aspectRatio: {min:1,max:2},
},
@nikhilm
nikhilm / main.rkt
Created August 7, 2023 02:17
experimenting with continuations in racket
#lang racket/base
(define kont #f)
(define my-prompt (make-continuation-prompt-tag))
(begin
(call-with-continuation-prompt
(λ ()
(printf "Before everything~n")
(printf "The call current/composable returned ~v~n"
(call/cc