Skip to content

Instantly share code, notes, and snippets.

@cxw42
cxw42 / apply-file
Last active April 13, 2020 18:32
Keyboard.io Model01 Colormap file
#!/bin/bash
# Modified from Model01-sketch/tools/colormap/apply by Gergely Nagy
# (algernon),
# https://github.com/algernon/Model01-sketch/blob/master/tools/colormap/apply ,
# licensed GPL3.
here="$(cd "$(dirname "$0")" &>/dev/null ; pwd)"
if [[ $# -ne 1 ]]; then
echo "Usage: $0 <colormap filename>"
@cxw42
cxw42 / W.pm
Last active June 22, 2019 18:33
Investigating ${^WARNING_BITS} in Perl 5.26.2
package W;
#use Data::Dumper;
use strict;
use 5.014;
sub import {
say "Compile time: ", unpack('b*', ${^WARNING_BITS});
# ${^WARNING_BITS} is only available at compile time per
# https://www.perlmonks.org/?node_id=611472
}
@cxw42
cxw42 / cpanfile-from-Makefile-PL
Created May 29, 2019 13:59
Creating a cpanfile from dependency information in Makefile.PL
#!perl
# Make a cpanfile from the dependencies in Makefile.PL.
# Modified from https://github.com/miyagawa/cpanfile/blob/master/README.md
# by miyagawa
use CPAN::Meta;
use Module::CPANfile;
die "Could not run Makefile.PL"
unless system($^X, 'Makefile.PL') == 0;
@cxw42
cxw42 / cd-to-git-root.sh
Created May 24, 2019 19:59
cd to the root of a git repo, even from .git or from submodules (bash)
# Edit as noted below, then source this from your .bashrc, or paste it in there. Then
# cdgr
# will move you to the root of the current git repo (if any).
# If you are in a submodule, it will move you to the top of the containing repo.
# Edits:
# - If you are not on Cygwin, remove line 16
# - If you are on Cygwin, change YOUR_USERNAME on line 16 to ... your username ;) .
# This is to map from /cygdrive paths back to Cygwin-native paths.
@cxw42
cxw42 / mathlib.lua
Last active May 31, 2018 02:04 — forked from xeoncross/mathlib.lua
Moved the exports into the `mathlib` package
-- mathlib.lua
--[[
Maths extension library for use in Corona SDK by Matthew Webster.
All work derived from referenced sources.
twitter: @horacebury
blog: http://springboardpillow.blogspot.co.uk/2012/04/sample-code.html
code exchange: http://code.coronalabs.com/search/node/HoraceBury
github: https://gist.github.com/HoraceBury
@cxw42
cxw42 / test_3_45.t
Created April 3, 2018 17:11
Testing XML::Twig on Cygwin 64-bit
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use XML::Twig;
use Test::More tests => 16;
is( XML::Twig->new( keep_encoding => 1)->parse( q{<d a='"foo'/>})->sprint, q{<d a="&quot;foo"/>}, "quote in att with keep_encoding");