Skip to content

Instantly share code, notes, and snippets.

@pladaria
pladaria / riffwave.js
Created December 7, 2016 16:17
RIFFWAVE
/*
* RIFFWAVE.js v0.03 - Audio encoder for HTML5 <audio> elements.
* Copyleft 2011 by Pedro Ladaria <pedro.ladaria at Gmail dot com>
*
* Public Domain
*
* Changelog:
*
* 0.01 - First release
* 0.02 - New faster base64 encoding
@adamreisnz
adamreisnz / package.json
Last active January 19, 2024 13:01
Simple pure npm scripts build process
{
"name": "project-name",
"description": "Template for static sites",
"version": "1.0.0",
"homepage": "http://www.project-name.com",
"author": {
"name": "Adam Reis",
"url": "http://adam.reis.nz"
},
"license": "UNLICENSED",
@magician11
magician11 / encrypt-secret-key.js
Last active July 7, 2017 01:22
How to encrypt a secret key from tweetnacl using scrypt.
const scrypt = require('scrypt-async');
const nacl = require('tweetnacl');
nacl.util = require('tweetnacl-util');
// utility functions
// -----------------
function printStage(stage) {
console.log(stage);
console.log('-'.repeat(stage.length));
}
# create a tinycorelinux fs with custom .tcz packages
# prerequisites: apt-get install squashfs-tools, npm i nugget -g
# dl release + packages (add your packages here)
nugget http://tinycorelinux.net/6.x/x86_64/release/CorePure64-6.3.iso http://tinycorelinux.net/6.x/x86_64/tcz/{pkg-config,make,gcc,gcc_base-dev,gcc_libs-dev,gcc_libs,glibc_base-dev,linux-3.16.2_api_headers,fuse}.tcz -c
# to support compiling addons
unsquashfs -f pkg-config.tcz
unsquashfs -f make.tcz
unsquashfs -f gcc.tcz
@petertodd
petertodd / gist:8e87c782bdf342ef18fb
Last active December 13, 2020 05:33
What the CoinWallet.eu tx-flood stress-test means for you and how to deal with it
@0xabad1dea
0xabad1dea / banned.h
Last active December 27, 2015 19:46
banning macros
/* include this file AFTER your standard includes */
/* clang -Weverything -Wno-unused-macros */
/* SIGNED ARITHMETIC IS THE ENEMY. (use "signed" for main, etc.) */
#define int BANNED
/* THESE OTHER THINGS ARE ALSO THE ENEMY. */
#ifdef strcpy
#undef strcpy
#endif
#define strcpy BANNED
@marcellodesales
marcellodesales / formatted.sh
Last active November 14, 2023 19:22
One-liner REST server using netcat - nc
rm -f out
mkfifo out
trap "rm -f out" EXIT
while true
do
cat out | nc -w1 -l 1500 > >( # parse the netcat output, to build the answer redirected to the pipe "out".
export REQUEST=
while read line
do
line=$(echo "$line" | tr -d '[\r\n]')
@devi
devi / chacha20.js
Last active July 6, 2016 22:06
chacha20.js
/* chacha20 - 256 bits */
// Written in 2014 by Devi Mandiri. Public domain.
//
// Implementation derived from chacha-ref.c version 20080118
// See for details: http://cr.yp.to/chacha/chacha-20080128.pdf
var Chacha20KeySize = 32;
var Chacha20NonceSize = 8;
@fredley
fredley / Holiday
Created March 13, 2014 10:23
Holiday Pebble App
#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
PBL_APP_INFO(MY_UUID, "Holiday", "Tom Medley", 1, 1 /* App version */, RESOURCE_ID_IMAGE_MENU_ICON, APP_INFO_WATCH_FACE);
Window window;
TextLayer text_time_layer;
@lsauer
lsauer / parseInt.py
Last active April 3, 2022 09:11
Python: JavaScript like parseInt function in one line
#lsauer.com, 2013
#Note: -)for convenience the function uses the re-module, but can be rewritten to fit into a lambda expression
# -)choose any other, more-expressive return type such as NumPy's `nan` over None if you like
#demonstrative-version:
def parseInt(sin):
import re
return int(''.join([c for c in re.split(r'[,.]',str(sin))[0] if c.isdigit()])) if re.match(r'\d+', str(sin), re.M) and not callable(sin) else None
#via a simple regex: