Skip to content

Instantly share code, notes, and snippets.

@jepler
jepler / 0000README.md
Last active March 13, 2024 15:09
Reading RP2040 BOOTSEL pin from code

It turns out you CAN read the pico BOOTSEL pin from software.

I became aware of this possibility after pimoroni tweeted that you could use the BOOTSEL button as a MIDI trigger on their upcoming "Tiny2040". We speculated whether there was a small HW circuit to accomplish this, or if it was SW only. Now I have the answer.

I was also heavily informed by the bootloader source, the body of the reading code is taken directly from there with adjusted timings.

The general idea:

  • Pressing the button applies a strong pull-down.
  • Normally after start-up, this pin is always being driven by the Pico's QSPI peripheral, so the button has no effect
@calexandre
calexandre / merge-zsh-history.sh
Last active April 3, 2024 14:11
Merge two zsh history files
#!/bin/bash
# Inspired on https://david-kerwick.github.io/2017-01-04-combining-zsh-history-files/
set -e
history1=$1
history2=$2
merged=$3
echo "Merging history files: $history1 + $history2"
test ! -f $history1 && echo "File $history1 not found" && exit 1
@technomancy
technomancy / gist:cc0e7800878c39e4c245fc041c11df4b
Last active April 21, 2023 01:16
Clojure namespaces, spec, and why they're confusing

To me, "require-and-automatically-visible" is violating the beauty of namespace. But, maybe I felt this way because I don't understand Clojure's registry or how require works.

I thought about this more, and I think I have a better understanding of why this feels strange. Clojure has one thing called "namespaces" which are clojure.lang.Namespace objects created by the ns macro. Functionally speaking they are a storage location which mostly just contain vars and references to vars in other namespaces. They are used for code organization: specifically for organizing vars and occasionally Java classes and interfaces.

Clojure also has a completely different thing called "namespaces" which are prefixes that get attached to keywords and symbols. These can interact with ns namespaces thru the reader in a handful of ways (for instance, ::double-colon keywords and symbols inside backtick forms are resolved according to the current clojure.lang.Namespace) but for the most part should be considered a di

@dhermes
dhermes / README.md
Last active August 27, 2019 22:43
WSL failure on closures with gfortran

Ubuntu install, Fortran compiler and valgrind installed via apt install gfortran valgrind.

$ gfortran --version
GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
@barrywoolgar
barrywoolgar / hb_all_books_dl.js
Created September 2, 2016 11:06 — forked from graymouser/hb_all_books_dl.js
Humble bundle book bundles - download all books at once
/*
After purchasing a humble book bundle, go to your download page for that bundle.
Open a console window for the page and paste in the below javascript.
This will download all the books in all the formats available.
*/
$('a').each(function(i){
if (['MOBI', 'PDF', 'EPUB'].indexOf($.trim($(this).text())) >= 0) {
$('body').append('<iframe id="dl_iframe_'+i+'" style="display:none;">');
document.getElementById('dl_iframe_'+i).src = $(this).data('web');
}
@rochacbruno
rochacbruno / mainpython.md
Last active July 5, 2023 10:56
Use of __main__.py

The use of __main__.py to create executables

myprojectfolder/
    |_ __main__.py
    |_ __init__.py

Being __main__.py:

print("Hello")

@O-I
O-I / weighted_random_sampling.md
Last active February 21, 2024 19:02
[TIx 8] Weighted Random Sampling in Ruby

One of the many reasons I love working with Ruby is it has a rich vocabulary that allows you to accomplish your goals with a minimal amount of code. If there isn't a method that does exactly what you want, it's usually possible to build an elegant solution yourself.

Let's take the example of simulating the rolling of a die.

We can represent a die as an array of its faces.

die = [*?⚀..?⚅]
# => ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]
@bradfitz
bradfitz / diskchecker.pl
Created July 24, 2012 21:05
diskchecker.pl
#!/usr/bin/perl
#
# Brad's el-ghetto do-our-storage-stacks-lie?-script
#
sub usage {
die <<'END';
Usage: diskchecker.pl -s <server[:port]> verify <file>
diskchecker.pl -s <server[:port]> create <file> <size_in_MB>
diskchecker.pl -l [port]
@e000
e000 / donotuse.py
Created June 13, 2011 23:30
How to NEVER use lambdas.
##########################################################
# How to NEVER use Lambdas. An inneficient and yet educa-#
# tonal guide to the proper misuse of the lambda constru-#
# ct in Python 2.x. [DO NOT USE ANY OF THIS EVER] #
# by: e000 (13/6/11) #
##########################################################
## Part 1. Basic LAMBDA Introduction ##
# Well, it's worth diving straight into what lambdas are.
# Lambdas are pretty much anonymous "one line" functions