Skip to content

Instantly share code, notes, and snippets.

@joshuabaker
joshuabaker / languages.json
Last active December 2, 2025 16:19
List of languages with ISO 639-1 Alpha-2 codes in JSON.
[
{
"code": "aa",
"name": "Afar",
"native": "Afar"
},
{
"code": "ab",
"name": "Abkhazian",
"native": "Аҧсуа"
@mattdesl
mattdesl / rings.js
Created October 2, 2019 16:16
canvas-sketch + canvas-sketch-util = penplot lines
const canvasSketch = require('canvas-sketch');
const { renderPaths, createPath, pathsToPolylines } = require('canvas-sketch-util/penplot');
const { clipPolylinesToBox } = require('canvas-sketch-util/geometry');
const Random = require('canvas-sketch-util/random');
const settings = {
dimensions: [ 12, 12 ],
orientation: 'landscape',
pixelsPerInch: 300,
scaleToView: true,
@mattdesl
mattdesl / about.md
Last active April 2, 2019 15:22
beat sync MP4 with canvas-sketch

MP4 from frame sequence + audio file

See the resulting 2K video on Vimeo

Let's say you export a sequence of PNGs from canvas-sketch animation into a tmp/ folder. If you have an audio file, you can use the below FFMPEG command to mix the frames and audio into a high quality MP4 file that can be uploaded to Twitter, Vimeo, etc.

Beat-Sync Generative Art

Let's say your canvas-sketch program isn't an animation, but instead exports hundreds of variations on a generative algorithm. You want to mash them all together to create a video that feels somewhat in sync with the music.

@hitautodestruct
hitautodestruct / reset.md
Created July 17, 2018 12:58
Reset root password on scaleway.com
@drhayes
drhayes / camera.lua
Created March 9, 2018 15:37
LÖVE camera shake
self.noiseFactor = self.noiseFactor + dt
-- self.trauma = math.min(1, self.trauma) - dt * config.camera.traumaFactor
self.trauma = math.max(0, self.trauma - dt * config.camera.traumaFactor)
if self.cameraTarget then
self.x = self.x + (self.cameraTarget.pos.x - self.x) * dt * self.slideFactor
self.y = self.y + (self.cameraTarget.pos.y - self.y) * dt * self.slideFactor
end
-- Shake based on trauma
local shake = self.trauma ^ 2
local maxOffset, maxAngle = config.camera.shake.maxOffset, config.camera.shake.maxAngle
@rynaldos-zz
rynaldos-zz / wc_no-atc-per=product-cat.php
Last active September 20, 2021 23:53
[WooCommerce] Hide "add to cart" button on certain product categories
add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );
function remove_add_to_cart_buttons() {
// replace a_category and another_category with the slugs of the categories you'd like to have the button removed from
if( is_product_category( array( 'a_category', 'another_category'))) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
}
// Did this help? Donate me some BTC: 1BEsm8VMkYhSFJ92cvUYwxCtsfsB2rBfiG
using System;
using System.Runtime.InteropServices;
// ReSharper disable SuspiciousTypeConversion.Global
// ReSharper disable InconsistentNaming
namespace VideoPlayerController
{
/// <summary>
/// Controls audio using the Windows CoreAudio API
/// from: http://stackoverflow.com/questions/14306048/controling-volume-mixer
@john2x
john2x / 00_destructuring.md
Last active November 21, 2025 02:39
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@nolanlum
nolanlum / PaydaySaveParser.py
Created January 8, 2014 03:55
Save parsing/modification library for Payday 2: The Heist. Saves and loads directly from the steam cloud file in the payday userdata folder. After making modifications via the dict structure, supports saving back into flatfile form that the client loads and will validate.
# coding=utf-8
import hashlib
import sys
from binascii import b2a_hex
from collections import OrderedDict, namedtuple
from struct import pack, unpack_from
SizedInt = namedtuple('SizedInt', ['size', 'value'])
size_to_c_name = {1: 'byte', 2: 'short', 4: 'int'}
SizedInt.__str__ = lambda self: "%s(%s)" % (size_to_c_name[self.size], self.value)