Skip to content

Instantly share code, notes, and snippets.

@kotarou3
kotarou3 / find-top-level-packages.py
Last active December 19, 2023 16:41
Find top-level packages of the dependency graph for debian packages
#!/usr/bin/python3
import argparse, sys
import apt
import networkx as nx
parser = argparse.ArgumentParser(
description = "Find top-level packages of the dependency graph"
)
parser.add_argument(
#!/usr/bin/nodejs
"use strict";
require("prfun/smash");
const co = require("co");
const execFile = Promise.guard(
require("os").cpus().length + 1,
(cmd, args) => require("mz/child_process").execFile(cmd, args, {maxBuffer: 100 * 1024 * 1024})
);
const fs = require("mz/fs");
@kotarou3
kotarou3 / examine-middlewares.js
Created February 3, 2016 07:39
Scripts to help with examining middlewares
function examineMiddlewares(middlewares) {
"use strict";
let results = [];
for (let middleware of middlewares) {
let script = %FunctionGetScript(middleware);
let position = %FunctionGetScriptSourcePosition(middleware);
let line = script.source.slice(0, position).split("\n").length - 1;
let source = %FunctionGetSourceCode(middleware);
@kotarou3
kotarou3 / timetable-formatter.js
Last active July 20, 2016 19:26
Format UNSW timetable for conversion to PDF
let printoutHeight = 18; // In centimetres
function xpath(node, path) {
let elems = document.evaluate(path, node, null, XPathResult.ANY_TYPE, null);
let elem;
let result = [];
while (elem = elems.iterateNext())
result.push(elem);
return result;
#include <nmmintrin.h>
#include <stdint.h>
#include <stdio.h>
int main() {
for (uint64_t i = 0; i < 0x100000000ULL; ++i)
if (_mm_crc32_u32(0, i) == i)
printf("%08x\n", (uint32_t)i);
return 0;
}
<!DOCTYPE html>
<section>
<input type="file" id="input" />
<input type="number" id="maxWidth" /> &times; <input type="number" id="maxHeight" />
<button onclick="convert()">Convert</button>
</section>
<section><pre id="output"></pre></section>
<section><img id="outputImage"></pre></section>
<script type="application/javascript">
function convert() {
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <string.h>
int main() {
int listenfd = socket(AF_INET, SOCK_STREAM, 0);
setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 }, sizeof(int));
struct sockaddr_in servaddr;
@kotarou3
kotarou3 / perf.c
Created September 1, 2015 10:38
Scripted performance counting for side channel attacks
#define _GNU_SOURCE
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <linux/perf_event.h>
#include <sched.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <unistd.h>
/**
* Room Avatar Commands
**/
function fakeUnrecognized() {
var fullCmd = this.namespaces.concat(this.cmd).join(' ');
if (this.cmdToken === '!') {
return this.errorReply("The command '" + this.cmdToken + fullCmd + "' was unrecognized.");
}
return this.errorReply("The command '" + this.cmdToken + fullCmd + "' was unrecognized. To send a message starting with '" + this.cmdToken + fullCmd + "', type '" + this.cmdToken.repeat(2) + fullCmd + "'.");
}

ARM compared with AVR

Disclaimer

This document will be based on the ARMv8-A architecture, mainly focusing on AArch64, and comparing it to ATmega2560's megaAVR architecture.
Thus "ARM" will be used to mean "ARMv8-A AArch64" and "AVR" as "megaAVR".

Microarchitectural details for ARM are taken from the Cortex-A57.

Overview

Focusing on the differences between ARM and AVR, ARM has: