Skip to content

Instantly share code, notes, and snippets.

View MrThanlon's full-sized avatar
🎯
Focusing

HZ1 MrThanlon

🎯
Focusing
View GitHub Profile
@MrThanlon
MrThanlon / clousure_bind.c
Created October 16, 2023 06:03
clousure_bind
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <stdint.h>
#include <sys/mman.h>
#include <errno.h>
#include <unistd.h>
void do_something(void* param) {
@MrThanlon
MrThanlon / 2to3.js
Last active September 16, 2022 06:25
2to3
const sc = document.createElement('script');
sc.src = 'https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/3.4.2/gl-matrix-min.js';
document.body.appendChild(sc);
sc.onload = () => {
const width = 512;
const height = 512;
const cvs = document.createElement('canvas');
cvs.width = width;
cvs.height = height;
document.body.appendChild(cvs);
@MrThanlon
MrThanlon / gen.sh
Created August 17, 2022 08:35
compile_commands.json for Makefile
make --always-make --dry-run \
| grep -wE 'gcc|g\+\+' \
| grep -w '\-c' \
| jq -nR '[inputs|{directory:".", command:., file: match(" [^ ]+$").string[1:]}]' \
> compile_commands.json
@MrThanlon
MrThanlon / generate-bitcoin-keys.sh
Created June 29, 2022 05:40 — forked from gadiener/generate-bitcoin-keys.sh
OpenSSL commands to create a Bitcoin private/public keys from a ECDSA keypair
#!/bin/sh
PRIVATE_KEY="ECDSA"
PUBLIC_KEY="ECDSA.pub"
BITCOIN_PRIVATE_KEY="bitcoin"
BITCOIN_PUBLIC_KEY="bitcoin.pub"
echo "Generating private key"
openssl ecparam -genkey -name secp256k1 -rand /dev/random -out $PRIVATE_KEY
@MrThanlon
MrThanlon / heap.c
Last active August 24, 2021 03:13
heap.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct {
size_t size;
size_t capacity;
void **elements;
char (*compare)(const void *, const void *);
@MrThanlon
MrThanlon / Binary_to_BCD.v
Created April 18, 2021 12:24
Binary_to_BCD.v
module Binary_to_BCD
#(parameter INPUT_WIDTH = 20,
parameter DECIMAL_DIGITS = 7)
(
input i_Clock,
input [INPUT_WIDTH-1:0] i_Binary,
input i_Start,
//
output [DECIMAL_DIGITS*4-1:0] o_BCD,
output o_DV
@MrThanlon
MrThanlon / Queue.js
Created August 9, 2020 09:43
Queue.js
export default class Queue {
constructor(size = 2000) {
this.size = size
this.buffer = new Uint8Array(this.size)
this.first = 0
this.end = 0
this.empty = true
}
/**
@MrThanlon
MrThanlon / main.c
Created July 28, 2020 09:21
stm32tx
uint8_t txBuffer[256];
uint8_t txBufferPointer = 0;
uint8_t uartReady = 1;
/**
* @brief Sends an amount of data in asynchronous mode.
* @param huart: pointer to a UART_HandleTypeDef structure that contains
* the configuration information for the specified UART module.
* @param pData: Pointer to data buffer
* @param Size: Amount of data to be sent
@MrThanlon
MrThanlon / mooc.js
Last active May 9, 2020 12:17
MOOC互评
Array.prototype.slice.call(document.getElementsByTagName('input')).filter(v=>v.type=='radio').map(v=>v.click())
Array.prototype.slice.call(document.getElementsByTagName('textarea')).map(v=>v.value = '很好')
document.getElementsByClassName('j-submitbtn')[0].click()
setTimeout(()=>{document.getElementsByClassName('j-gotonext')[0].click()}, 1000)
@MrThanlon
MrThanlon / api.js
Last active June 16, 2021 14:16
api.js
/**
* API description
*/
import request from './request.js'
const handler = {
get(target, property) {
/*
if (property in target) {