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 / ftp_proxy.c
Last active November 17, 2024 12:06
active to passive FTP server proxy
#include <stdlib.h>//exit
#include <stdio.h>
#include <pthread.h>
#include <netdb.h> //NI_NUMERICHOST
#include <string.h>//strlen
#include <unistd.h>//read write close fork
#define ss2sa(ss) ((struct sockaddr *)(ss))
#define $(X) if((err=(X))<0)die(__LINE__,err)
#define Write(A,B) write(A,B,strlen(B))
#define Read(A,B) len=read(A,B,sizeof(B));buf[len]=0;
@yne
yne / bms_player_sdl.c
Created December 18, 2015 23:13
Easily hackable SDL based BMS player
/*
http://bm98.yaneu.com/bm98/bmsformat.html
http://fileformats.wikia.com/wiki/Be-Music_Script
http://mrqqn.net/dotclear/public/beatmaker/bms-specification.txt
http://hitkey.nekokan.dyndns.info/cmds.htm
*/
#include <malloc.h>
#include <string.h>
#include <fcntl.h>
#include <SDL/SDL.h>
@yne
yne / gluminess.c
Created December 19, 2015 00:17
Luminess in pure OpenGL
#include <windows.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/wglext.h>
#include <sys/time.h>
#define COUNT(A) (sizeof(A)/sizeof(A[0]))
#define BLOC_EXIST (1<<0)
#define BLOC_COLOR (1<<1)
@yne
yne / bin_extract.c
Created December 20, 2015 22:14
Extract from a blob using file header
#include <stdio.h>
#include <string.h>
char* headers[]={
"ID3",
"GIF89",
"‰PNG",
"OggS",
"ÿØÿà",
"BM6x",
@yne
yne / wav_play.c
Created June 9, 2016 21:04
Play argv wavs using ALSA
#include <alloca.h> /*needed (yet not included) by asoundlib in c99*/
#include <alsa/asoundlib.h>/* build with -lasound */
#include <stdint.h>
#define $(x) if ((x) < 0) { fprintf(stderr, "Error:%s", # x); return -1; }
#define MIN(A, B) ((A) < (B) ? (A) : (B))
typedef struct {
char RIFF[4];
uint32_t ChunkSize;
char WAVE[4];
char fmt[4];
@yne
yne / cli_chat.c
Last active August 18, 2024 18:10
CLI Chat Mockup for libstrophe
#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdbool.h>
#include <string.h>
#define POS(ROW,COL) printf("\033[%i;%iH", ROW, COL)
struct winsize w;
@yne
yne / json.c
Last active October 10, 2016 23:43
Smart json import/update into internal structure
#include <json-c/json.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
typedef enum{
diff_none,
diff_type,
diff_value,
diff_removed,
@yne
yne / kh_diff.c
Created February 13, 2017 23:45
khash diff example
#include <inttypes.h>
#include <stdio.h>
//#include "klist.h"
#include "khash.h"
#define kh_forall(h) for(khint_t __i=kh_begin(h);__i!=kh_end(h);++__i)if(kh_exist(h,__i))
#define kh_diff(name, old, new, on_add, on_keep, on_del)\
kh_forall(new){/*find added(exist in new, not in old) and kept(exist in both) entries */\
khiter_t __j = kh_get(name, old, kh_key(new,__i));\
if((__j==kh_end(old))||(!kh_exist(old,__j))){on_add;}else{on_keep;}\
@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 / git.io yne.install
Last active November 4, 2022 05:00
wget -O- git.io/yne.install | bash
#!/bin/bash
set -x
until sudo apt -y update && sudo apt -y upgrade ; do sleep 10; done
crontab -l | grep -q .wall || (echo '0 * * * * ID=$(curl -sL gist.githubusercontent.com/yne/729655bd0557bfde7a088e15b40b9e6d/raw/ | shuf -n 1);for t in jpg png; do curl -sfL nik.bot.nu/o$ID.$t -o "$HOME/.wall"; done') | crontab -
# MS-EDGE
REPO_EDGE='https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-dev/'
LAST_EDGE=$(wget -qO- "$REPO_EDGE" | grep -o '[.a-z_0-9-]*.deb' | tail -n1)
wget -O /tmp/edge_amd64 "$REPO_EDGE/$LAST_EDGE"
# VSCode (will add itself to apt.list)