Skip to content

Instantly share code, notes, and snippets.

View xigh's full-sized avatar

Philippe Anel xigh

View GitHub Profile
@xigh
xigh / pq.js
Last active May 29, 2020 12:07
Promise based Asynchronous Queue
export class PromiseQ {
constructor() {
this._queue = [];
}
async append(callback, param) {
const self = this;
const process = () => {
if (self._queue.length == 0) {
return;
#include <immintrin.h>
#include <inttypes.h>
#include <stdio.h>
char *sprint_m256(__m256 v)
{
static char tmp[256];
float f[8];
_mm256_store_ps(f, v);
#include <immintrin.h>
#include <inttypes.h>
#include <stdio.h>
char * sprint_m256(__m256 v) {
static char tmp[256];
snprintf(tmp, sizeof tmp, "[%8.2f, %8.2f, %8.2f, %8.2f, %8.2f, %8.2f, %8.2f, %8.2f]",
v[7], v[6], v[5], v[4], v[3], v[2], v[1], v[0]);
return tmp;
}
@xigh
xigh / uart-tx.v
Last active March 8, 2020 17:38
tinyfpga fpga uart tx hello world verilog
module top(
input CLK,
output USBPU,
output PIN_24,
);
assign USBPU = 0; // disable USB
wire clk115200hz;
dclk0 d0(.clk16mhz(CLK), .clk115200hz(clk115200hz));
@xigh
xigh / gcc-arm-test.c
Created January 19, 2020 10:30
I probably did something wrong ...
// -Wall -O2 -nostdlib -nostartfiles -ffreestanding -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mhard-float
void foobar()
{
uint8 buf[11] = { 0 };
for (int i = 0; i < sizeof(buf); i++)
{
uint8 x = buf[i];
uint32 a = (uint32) &buf[i];
uart_putx(a);
@xigh
xigh / tables.go
Created June 19, 2019 18:04
dump #sql tables in #golang
package main
import (
"database/sql"
"flag"
"fmt"
"log"
_ "github.com/go-sql-driver/mysql"
)
package main
import (
"database/sql"
"flag"
"fmt"
"log"
"time"
// Yes ... this is required !!!
@xigh
xigh / extractgc.sh
Created February 5, 2019 08:12
Extracting LLVM bitcode from ELF files generated with -fembed-bitcode.
#!/bin/sh
if [ "*$1" == "*" ]; then
echo "usage: extract.sh src dst"
fi
if [ "*$2" == "*" ]; then
echo "usage: extract.sh src dst"
fi
@xigh
xigh / description.txt
Last active January 23, 2019 18:06
Retrieve openoffice documents from formatted harddrive
1- calls mmap on the disk device
2- looks for zip headers
3- retrieves the begining of the zip file
4- check if it contains a mimetype file with the expected mimetype
5- save the result to a file
@xigh
xigh / pyth.c
Created December 24, 2018 08:19
Pythagorian Triples, the old way
#include <stdio.h>
int main()
{
int c = 1, n = 0;
while (n < 10)
{
int c2 = c * c;
for (int a = 1; a < c; a++)
{