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 Feb 1, 2022
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 / 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 / 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 Dec 4, 2022
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;
@plugnburn
plugnburn / frakturize.js
Created Aug 22, 2019
Frakturize: a small ES6 one-liner to generate Fraktur Unicode strings from a normal Latin
View frakturize.js
frakturize=s=>s.split('').map((c,i,h)=>/[a-zA-Z]/.test(c)?String.fromCodePoint((i=c.charCodeAt(0))>90?119997+i:((h='CHIRZ'.indexOf(c))>-1?8460+[33,0,5,16,28][h]:120003+i)):c).join('')
// Example: frakturize('ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz') => '𝔄𝔅ℭ𝔇𝔈𝔉𝔊ℌℑ𝔍𝔎𝔏𝔐𝔑𝔒𝔓𝔔ℜ𝔖𝔗𝔘𝔙𝔚𝔛𝔜ℨ 𝔞𝔟𝔠𝔡𝔢𝔣𝔤𝔥𝔦𝔧𝔨𝔩𝔪𝔫𝔬𝔭𝔮𝔯𝔰𝔱𝔲𝔳𝔴𝔵𝔶𝔷'
@plugnburn
plugnburn / unlockgen.py
Created Mar 28, 2019
Huawei modem unlock/flash code generator for algos v1/v2/v201 (Python 2 version)
View unlockgen.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import hashlib
import argparse
import binascii
import struct
def encrypt_v1(imei, key):