Skip to content

Instantly share code, notes, and snippets.

@jow-
jow- / bug.c
Created August 14, 2024 07:56
MIPS 74kc memory corruption bug
/* Compile with:
* ./staging_dir/toolchain-mips_24kc_gcc-12.3.0_musl/bin/mips-openwrt-linux-gcc -g -fpie -fpic -o /tmp/bug /tmp/bug.c
*/
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#!/usr/bin/ucode
'use strict';
import * as fs from 'fs';
import * as sys from 'u1905.core';
import * as wlnl from 'nl80211';
import * as socket from 'socket';
import * as libuci from 'uci';
import * as struct from 'struct';
@jow-
jow- / make-tar.sh
Created February 23, 2024 09:04
Generate a .tar.gz archive with shell
#!/bin/sh
make_tar_member() {
local name=$1
local content=$2
local mode=644
local uid=1000
local gid=1000
local size=${#content}
local mtime=$(date +%s)
@jow-
jow- / make-release-index-page.sh
Last active December 13, 2023 10:37
Create download index page
#!/usr/bin/env bash
set -e
get_all_tags() {
curl -s "https://git.openwrt.org/?p=openwrt/openwrt.git;a=tags" | \
sed -rne 's#^.+<a class="list name" href="[^"]+;h=([[:xdigit:]]+)">v([0-9.rc-]+)</a>.+$#\2-\1#p' | \
sort --version-sort
}
@jow-
jow- / toh-embedding.html
Last active November 30, 2023 13:36
Quick ToH embedding mockup
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>OpenWrt Devices</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" />
<script src="./toh.js"></script>
@jow-
jow- / convert.pl
Created November 29, 2023 08:38
Perl script to convert Wiki hwdata into a big JSON dictionary
#!/usr/bin/env perl
use strict;
use JSON;
sub filter_empty {
my ($val) = @_;
return undef if $val eq '¿' || $val eq 'http://¿' || $val eq 'https://¿';
@jow-
jow- / 1. update-to-git-head.sh
Last active November 9, 2023 13:18
Update OpenWrt Git packages
#!/usr/bin/env bash
MAKEFILE=$1
COMMIT=${2:-HEAD}
TOPDIR=$3
MAKE=$(which gmake) || MAKE=$(which make)
FIND=$(which gfind) || FIND=$(which find)
[ -x "$MAKE" ] || {
@jow-
jow- / timer-test.c
Last active October 13, 2023 11:35
uloop interval timer example
#include <inttypes.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <libubox/uloop.h>
static void timer_cb(struct uloop_timer *utm)
{
@jow-
jow- / examples.js
Last active March 7, 2022 18:52
Dependency specs
"depends": {
/* fs: filesystem dependencies
* Either an array of dictionaries (each item being an ORed alternative)
* or single dictionary.
*/
"fs": [
/* Satisfied if either a non-empty directory /sys/class/ieee80211 exists... */
{ "directory": "/sys/class/ieee80211" },
/* ... or an executable file /usr/bin/whatever... */
@jow-
jow- / Publisher output
Created March 4, 2022 19:57
ucode ubus pub/sub
$ sudo ./ubus.uc
[ "<ubus.connection 0x55f34c2b28e0>", "function publish(...) { [native code] }" ]
Subscription status change! Have subscribers? yes
Got data callback: [ 2, { "foo": true } ]
Got status callback: [ 1, 3 ]
Got complete callback: [ 0, 0 ]
Got data callback: [ 2, { "foo": true } ]
Got status callback: [ 1, 3 ]
Got complete callback: [ 0, 0 ]
Got data callback: [ 2, { "foo": true } ]