Skip to content

Instantly share code, notes, and snippets.

View yne's full-sized avatar
✔️
Not a virus

Rémy F. yne

✔️
Not a virus
View GitHub Profile
@yne
yne / upnp_port.c
Created March 12, 2017 02:18
UPNP port forwarding managment
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <ctype.h>
#include "miniwget.h"
#include "miniupnpc.h"
#include "upnpcommands.h"
@yne
yne / generic.lambda.c
Created August 12, 2018 17:33
C11 Lambda + Generic
#include <stdio.h>
#define fn(c) ({int _ c;_;})
#define list(c) sizeof(c)/sizeof(*c),c
#define map(LIST, CB) _Generic( (CB), int(*)(int, int, int*): map_arr, int(*)(int): map_val)(list(LIST), CB)
int map_val(size_t total, int *array, int (*cb)(int)) {
for(int i = 0; i < total; i++)
array[i] = cb(array[i]);
}
int map_arr(size_t total, int *array, int (*cb)(int, int, int*)) {
@yne
yne / dom.c
Created August 18, 2018 13:06
#include <stdio.h>
#include <stdint.h>
#include <termios.h>
#define LEN(ARR) ARR,sizeof(ARR)/sizeof(*ARR)
#define RGBA(R,G,B,A) ((R<<24) | (G<<16) | (B<<8) | A)
#define RGB(R,G,B) RGBA(R,G,B,255)
typedef enum{
RULE_NOP,
RULE_TEXT_COLOR,
@yne
yne / csv2vcf.js
Last active July 6, 2019 21:15
Convert csv from outlook exported contact to android compliant vcard file
csv.split('\n').slice(1).filter(e=>e).map(l=>l.split(',')).map(a=>['BEGIN:VCARD','VERSION:2.1','N:'+[a[2],a[0],a[1]].join(';'),...a.slice(11,24).map(m=>`TEL;CELL:`+m),...a.slice(8,11).map(m=>'EMAIL;HOME:'+m),'END:VCARD'].filter(l=>!l.endsWith(':')).join('\n')).join('\n\n')
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
@yne
yne / av1.c
Created August 20, 2019 18:02
av1-like decoder
#include <math.h>
#include <stdio.h>
#define e(a, d) for(a=0;a<d;a++)
int YUV[3][1 << 20], tmpyuv[2048], scratch[166], width;
int p = 0, r = 1;//reader accu
int lumaRatio = 0, satuRatio = 0;//decode default
void read8b() {
int b = getchar();
@yne
yne / mips-gen.c
Created December 30, 2019 21:38
unfinished MIPS generator for TCC
/*
* MIPS3K code generator for TCC
*
* Based on mips-gen.c by Daniel Glöckner & Thomas Preud'homme
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
@yne
yne / main.c
Created April 12, 2020 21:42
tilemap GL
//c99 main.c -o ../main -lX11 -lGL -lGLU && cd .. && ./main
#include <stdio.h>
#include <stdlib.h>
#include <X11/X.h>
#include <GL/gl.h>
#include <GL/glx.h>
GLuint texture[1];
int initGL(GLfloat width,GLfloat height){
typedef uint8_t Sprite[32*32*3];
@yne
yne / playlist.txt
Created November 2, 2020 06:49
playlist
Что такое осень ДДТ - Актриса весна
В последняя осень ДДТ - Актриса весна
Звезда по имени Солнце Kino - Звезда по имени Солнце
Дыхание Nautilus Pompilius - Крылья
Моё сердце Splean - 25 кадр
Просвистела ДДТ - Просвистела
Родина ДДТ - Актриса весна
Это всё ДДТ - Это всё
Ветер ДДТ - Это всё
Метель ДДТ - Мир номер ноль
@yne
yne / gl_ring.js
Created December 31, 2015 23:09
WebGL Rotating Rings IIDX 20 style
function Ring(n,size,width,tex,repeat,speed){
v=[],t=[];
for(var i=0;i<n;i++){
var rad=2*Math.PI*i/n;
v.push(
size*Math.cos(rad),
size*Math.sin(rad),
0,