Skip to content

Instantly share code, notes, and snippets.

@kates
kates / main.c
Last active July 29, 2021 02:25
Simple IRQ Button Debounce for Raspberry Pi Pico
#include <stdio.h>
#include "hardware/irq.h"
#include "hardware/gpio.h"
#include "pico/stdlib.h"
#include "pico/time.h"
static const uint8_t DEBOUNCE = 50;
static bool pressed = false;
static int32_t alarm_id = 0;
@kates
kates / klass.js
Created November 5, 2019 09:14
A tiny JS framework.
var Klass = (function() {
var Klass = function() {};
Klass.extend = function(constructor, props) {
var _super = this.prototype;
if (arguments.length < 2) {
props = constructor;
constructor = function(){};
}
@kates
kates / mp3tomp4.sh
Created May 13, 2017 15:36
convert mp3 to mp4 with image loop using ffmpeg
ffmpeg -loop 1 -i logo.jpg -i source.mp3 -c:a libmp3lame -c:v libx264 -b:a 128k -shortest output.mp4
@kates
kates / unassigned.sh
Created March 17, 2016 03:19
elasticsearch unassigned
curl -X PUT http://localhost:9200/_settings -d '{ "number_of_replicas" :0 }'
curl -X PUT http://localhost:9200/_cluster/settings -d '{"transient" : {"cluster.routing.allocation.enable": true}}'
@kates
kates / tlc.rs
Created October 16, 2014 00:59
toy vm bytecode compiler
use std::os;
use std::io;
use std::fmt;
struct Compiler {
source: String
//bytecode: String
}
enum Instruction {
@kates
kates / keybase.md
Created September 23, 2014 08:55
keybase.md

Keybase proof

I hereby claim:

  • I am kates on github.
  • I am kates (https://keybase.io/kates) on keybase.
  • I have a public key whose fingerprint is 4F22 399E A2EF AC24 2E69 B88E 9166 6DC5 BB54 2901

To claim this, I am signing this object:

@kates
kates / pip_update_all.sh
Created July 21, 2014 08:10
pip update all packages in virtualenv
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
@kates
kates / Makefile
Last active August 29, 2015 14:02
lock macosx screen from terminal
TARGET=lockscreen
all: clean compile
compile:
clang -framework Foundation -framework IOKit main.m -o ${TARGET}
clean:
rm -f ${TARGET}
@kates
kates / media
Last active August 29, 2015 14:02
controlling media in macosx terminal
$ media [TAB] [TAB]
pause   play    skip    volume

$ media play [TAB] [TAB]
itunes spotify

$ media pause [TAB] [TAB]
itunes spotify
@kates
kates / assets.rake
Created April 24, 2014 09:56
Detect modified assets in a gemified rails engine
task :fix_precompile_hook do
module Fixassets
module Assets
extend ActiveSupport::Concern
included do
def dependency_fresh_with_path_fix?(environment, dep)
path = dep.pathname.to_s
return false unless environment.paths.find { |env_path| path.starts_with? env_path }
dependency_fresh_without_path_fix?(environment, dep)
end