Skip to content

Instantly share code, notes, and snippets.

@tinc2k
tinc2k / mouse.py
Created January 19, 2025 13:50 — forked from NanoPi/mouse.py
FreePIE joystick mouse script
# https://github.com/AndersMalmgren/FreePIE/wiki/Sign
def sign(val): #Returns -1 for negatives, 0 for zero and 1 for positives
return (1 * (val > 0)) + (-1 * (val < 0))
# https://github.com/AndersMalmgren/FreePIE/wiki/ScaledDeadzone
# (modified)
def ScaledDeadzone(val, mini, maxi, dz): #Paremeters are Value, Minimum, Maximum and Deadzone Size.
scaled = filters.mapRange(val,mini,maxi, -1.0,1.0)
output = 0.0
if abs(scaled) > dz:
@tinc2k
tinc2k / foobar2000-dsd-sacd.md
Created January 12, 2025 01:01 — forked from milnak/foobar2000-dsd-sacd.md
Foobar 2000 DSD and SACD support: Guide to setting up Foobar2000 player for hi-res audio (DSF, DFF, SACD, ISO)

Foobar2000 DSD and SACD support

I've successfully followed these steps to get DSD (.dsf filetype) and SACD (.iso filetype) playing at high bit rate using foobar2000 on my S.M.S.L M500 DAC.

This has been adapted from "SECTION II" of this page, thanks to "sirblew" for the tip!

Introduction

DSD stands for Direct Stream Digital and it is a high-definition lossless audio format with a twist. PCM signal solutions (like FLAC, TTA or APE) measure a set of bits multiple times per second to capture the audio data, hence the 16/24-bit parameter. On the other hand, DSD uses only one bit but samples it 2.8 million times a second to capture the audio signal.

@tinc2k
tinc2k / hls.sh
Created November 8, 2024 20:09 — forked from stenuto/hls.sh
HLS ffmpeg script
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 /path/to/input.mp4 [ /path/to/output_directory ]"
exit 1
}
# Check if at least one argument (input file) is provided
if [ $# -lt 1 ]; then
@tinc2k
tinc2k / svg_sprites.md
Created January 25, 2023 10:55 — forked from darsain/svg_sprites.md
How to use SVG sprites in img[src] and css backgrounds

To make this work in CSS:

background: url('images.svg#chart');

or img:

<img src="images.svg#chart">
@tinc2k
tinc2k / cohort.sql
Created November 12, 2022 21:52 — forked from bassemawhoob/cohort.sql
Revenue Retention Cohort Analysis - Postgres
-- Based on: https://medium.com/quick-code/how-to-write-sql-to-calculate-user-cohort-retention-a1b3b57c7a2f
-- Uses DATE_PART instead of DATE_DIFF as it is not supported by Postgres
-- (branch_id, scheduled_for, total_cents)
WITH activities AS (
SELECT branch_id, scheduled_for, total_cents
FROM orders
WHERE orders.status = 'complete'
),
-- (branch_id, cohort_month): cohort month is the first order date
with
dau as (
-- This part of the query can be pretty much anything.
-- The only requirement is that it have three columns:
-- dt, user_id, inc_amt
-- Where dt is a date and user_id is some unique identifier for a user.
-- Each dt-user_id pair should be unique in this table.
-- inc_amt represents the amount of value that this user created on dt.
-- The most common case is
-- inc_amt = incremental revenue from the user on dt
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@tinc2k
tinc2k / json_postgres.js
Created April 28, 2016 08:42 — forked from lucdew/json_postgres.js
Example of json document storage in postgresql and querying (with knex.js)
var connectionString = 'postgres://localhost:5432/postgres';
var Promise=require('bluebird');
var knex = require('knex')({
client: 'pg',
connection: {
user: 'postgres',
database: 'postgres',
port: 5432,
@tinc2k
tinc2k / about_those_lava_lamps.md
Created December 21, 2015 18:20 — forked from marick/about_those_lava_lamps.md
About Those Lava Lamps

Around 2006-2007, it was a bit of a fashion to hook lava lamps up to the build server. Normally, the green lava lamp would be on, but if the build failed, it would turn off and the red lava lamp would turn on.

By coincidence, I've actually met, about that time, (probably) the first person to hook up a lava lamp to a build server. It was Alberto Savoia, who'd founded a testing tools company (that did some very interesting things around generative testing that have basically never been noticed). Alberto had noticed that people did not react with any urgency when the build broke. They'd check in broken code and go off to something else, only reacting to the breakage they'd caused when some other programmer pulled the change and had problems.

@tinc2k
tinc2k / gist:fa4f21c7a5d3e05aaa62
Created December 20, 2015 10:04 — forked from chrissimpkins/gist:5bf5686bae86b8129bee
Atom Editor Cheat Sheet (Sweetmeat)

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on Mac OSX.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key