Skip to content

Instantly share code, notes, and snippets.

@reegnz
reegnz / README.md
Last active October 15, 2024 20:10
Implementing a jq REPL with fzf

Implementing a jq REPL with fzf

Update: I created jq-zsh-plugin that does this.

One of my favourite tools of my trade is jq. It essentially enables you to process json streams with the same power that sed, awk and grep provide you with for editing line-based formats (csv, tsv, etc.).

Another one of my favourite tools is fzf.

@xobs
xobs / keytest.py
Created November 30, 2019 08:10
Fomu keyboard test
import time
import microcontroller
import digitalio
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode
# A simple neat keyboard demo in CircuitPython
@maptiler
maptiler / globalmaptiles.py
Created August 13, 2018 10:37
globalmaptiles.py
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: GDAL2Tiles, Google Summer of Code 2007 & 2008
# Global Map Tiles Classes
# Purpose: Convert a raster into TMS tiles, create KML SuperOverlay EPSG:4326,
# generate a simple HTML viewers based on Google Maps and OpenLayers
# Author: Klokan Petr Pridal, klokan at klokan dot cz
# Web: http://www.klokan.cz/projects/gdal2tiles/
@bitrot-sh
bitrot-sh / asanalyzer.py
Created December 8, 2017 18:02
Root cause analysis on ASan crash logs
#!/usr/bin/env python3
"""
Usage: ./asanalyzer.py -d 5 '/home/user/asan_logs/*.log'
Analyze multiple ASan report logs and classify them based on backtrace logs.
ASLR should be disabled prior to running test cases.
Default stack trace depth is 5. This can be changed by passing -d or --depth.
"""

Real depth in OpenGL / GLSL

http://olivers.posterous.com/linear-depth-in-glsl-for-real

So, many places will give you clues how to get linear depth from the OpenGL depth buffer, or visualise it, or other things. This, however, is what I believe to be the definitive answer:

This link http://www.songho.ca/opengl/gl_projectionmatrix.html gives a good run-down of the projection matrix, and the link between eye-space Z (z_e below) and normalised device coordinates (NDC) Z (z_n below). From there, we have

A   = -(zFar + zNear) / (zFar - zNear);

B = -2zFarzNear / (zFar - zNear);

@maxammann
maxammann / main.c
Last active May 21, 2018 01:51
Example how to visualize libav output in a spectrum
int open_file(char *file_path, AVFormatContext **fmt_ctx, AVCodecContext **dec_ctx) {
int audio_stream_index;
AVCodec *codec;
// Find codec and stream
if (avformat_open_input(fmt_ctx, file_path, NULL, NULL) < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
return -1;
}
@maxammann
maxammann / audio.c
Created March 22, 2015 15:48
libao and libsndfile: PCM playback (.wav, .aiff, .ogg)
#include <ao/ao.h>
#include <sndfile.h>
#include <signal.h>
#define BUFFER_SIZE 8192
int cancel_playback;
void on_cancel_playback(int sig) {
if (sig != SIGINT) {
@Xyene
Xyene / ReflectionHelper.java
Created November 23, 2012 12:54
ReflectionHelper
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class ReflectionHelper {
public static <T> FieldContainer<T> field(String name) {
return new FieldContainer<T>(name);
}
// Written by Nick Gammon
// February 2011
/**
* Send arbitrary number of bits at whatever clock rate (tested at 500 KHZ and 500 HZ).
* This script will capture the SPI bytes, when a '\n' is recieved it will then output
* the captured byte stream via the serial.
*/
#include <SPI.h>