Skip to content

Instantly share code, notes, and snippets.

@plugnburn
plugnburn / olc.js
Last active Oct 27, 2020
TinyOLC - smallest Open Location Code implementation in JS
View olc.js
/**
* TinyOLC - Open Location Code for smallest applications
* Differences from Google's open-source JS implementation:
* - less than 600 bytes minified (as opposed to over 4.5 KB from Google)
* - only 2 methods exposed - encode (lat, lng => str) and decode (str => [lat, lng])
* - only floating point degrees accepted as encoding input (positive as N and E, negative as S and W)
* - no short code resolution
* - no area encoding, only points with 11-digit resolution
* - assuming the block lower left corner only when decoding a low-res code
* - no validation checks
@plugnburn
plugnburn / usbio.js
Last active Jun 20, 2020
USBIO.js: a convenient wrapper class for WebUSB interaction (for further mobile toolkits)
View usbio.js
//USB I/O class for WebUSB
//(c) Luxferre 2020-present
class USBIO {
//Possible devFilter fields: classCode, subclassCode, protocolCode, vendorId, productId, serialNumber (not recommended)
constructor(devFilter = {}) {
this.requestDeviceObject = {filters:(devFilter ? [devFilter] : [])}
this.devFilter = devFilter
@plugnburn
plugnburn / mtphreak-6572.lua
Created Jun 16, 2020
MTPhreak-6572: sKai-specific MP0B_001 file modifier
View mtphreak-6572.lua
-- MTPhreak IMEI changer and randomizer for MediaTek NVRAM
-- This version is adapted specifically for the Sigma sKai and other MT6572 based phones
-- Usage: lua mtphreak-6572.lua NVRAMfile [imei1 [imei2]]
-- If no IMEIs are passed, they are randomized (with respect to Luhn checksum)
function parseImei(imeistr) -- imei string to 12-byte table
local imeiTbl = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
for i = 1, 15 do
local digit = tonumber(imeistr:sub(i,i))
@plugnburn
plugnburn / mtk-bootseq.py
Created Jun 15, 2020
MTK Bootseq: enter alternative boot modes in MediaTek-based smartphones
View mtk-bootseq.py
#!/usr/bin/env python3
# Simple script to enter the necessary boot mode in the MT6572-based (etc) phones
# Depends on pyserial, otherwise fully cross-platform
# Usage: python3 mtk-bootseq.py [MODECMD] [port]
# e.g. python3 mtk-bootseq.py FASTBOOT /dev/tty.usbmodem14200
# and then connect the cable and repeatedly short-press the power on key
# Supported commands depend on the device and its preloader. Here's the list for Sigma S3500 sKai:
@plugnburn
plugnburn / analyzer.xml
Created May 19, 2020
Nokia 8110 4G partitioning
View analyzer.xml
<?xml version="1.0"?>
<configuration>
<!-- Primary GPT header: -->
<!-- MD5: 2bdfbe2dca1cff16f2208cad324ee36f -->
<!-- Signature: EFI PART -->
<!-- Revision: 65536 -->
<!-- Header Size: 92 -->
<!-- CRC32 of header: 4F152EE (VALID) => Real: 4F152EE -->
<!-- Current LBA: 0x00000001 -->
<!-- Backup LBA: 0x00747FFF -->
@plugnburn
plugnburn / theme_descriptor.xml
Created Feb 13, 2020
Example NTH theme descriptor file for Nokia 8800 Classic and Special Edition - public tutorial
View theme_descriptor.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE theme PUBLIC "-//NOKIA//DTD THEME 1.1//EN" "theme.dtd">
<!--
This is an example theme_descriptor.xml for Nokia 8800 Classic/Special (not Sirocco or Arte)
that can be used freely as a complete reference template to create other themes
Compilation: cd theme_dir && zip -9 ../MyExampleTheme.nth ./*
Note: all resource files MUST be present in the archive's root, no subdirectories!
-->
<theme name="MyExampleTheme" version="1.1">
<!-- (all icons and wallpapers hereafter can be of JPEG, PNG, BMP or GIF format, including animations) -->
@plugnburn
plugnburn / ytdl.js
Last active Feb 13, 2020
Handmade YouT00be downloader because I don't trust any other
View ytdl.js
/**
* Yet another YouT00be downloader (requiring no third-party NodeJS modules)
* Usage: node ytdl.js [video id]
*
* @license Unlicense
*/
const vID = process.argv[2]
const qs = require('querystring')
const https = require('https')
@plugnburn
plugnburn / Novocarina.scad
Last active Oct 13, 2019
Novocarina: 3D-printable customizable English pendant style ocarina
View Novocarina.scad
This file has been truncated, but you can view the full file.
/**
* Novocarina: a fully 3D-printable ocarina with a side pendant loop and customizable inside bottom branding
* Optimized PLA settings: 20% infill, 0.3mm layer height, 10mm brim
*
* Key: C
*
* It has some differences from a standard 4-hole English pendant system ocarina:
* due to the nature of 3D printing in PLA, some tones actually have different keying
* (don't believe your musical tuners since they can't pick up any overtones,
@plugnburn
plugnburn / stl2scad.js
Last active Oct 11, 2019
STL2SCAD.js - Optimizing decompiler of a binary STL into the OpenSCAD source
View stl2scad.js
/**
* Optimizing decompiler of a binary STL into the OpenSCAD polyhedron module
* @license Unlicense
*
* @param {ArrayBuffer} stl STL file contents (binary flavor)
* @param {string} optional custom name for OpenSCAD object (if none passed then 'object{NumTriangles}' will be used)
* @returns {string} ready OpenSCAD script
*/
function STL2SCAD(stl, optModName = null) {
var totalTriangles = new Uint32Array(stl.slice(80, 84))[0], //triangle amount is LE uint at byte 80
@plugnburn
plugnburn / libwallace.js
Last active Sep 25, 2020
LibWallace: toolbox library for Qualcomm-based phones running KaiOS
View libwallace.js
/**
* LibWallace: toolbox library for Qualcomm-based and MTK-based phones running KaiOS
*
* Full support: KaiOS 2.5+ Nokias (Nokia 8110 4G, Nokia 2720 Flip, Nokia 800 Tough)
* Partial support: CAT B35, KaiOS 1.0 devices (Alcatel OT-4044O), MTK devices (Sigma S3500 sKai)
*
* Needs "certified" level in the app manifest.
* Requires additional manifest permissions:
*
* "power" - enable power management and privileged factory reset;
You can’t perform that action at this time.