Skip to content

Instantly share code, notes, and snippets.

View haxpor's full-sized avatar
🤓
Some of my financial tools https://www.mql5.com/en/users/haxpor/seller

Wasin Thonkaew haxpor

🤓
Some of my financial tools https://www.mql5.com/en/users/haxpor/seller
View GitHub Profile
@haxpor
haxpor / nginx.conf
Created April 6, 2019 18:34
nginx configuration used to serve rtmp working with ffmpeg
rtmp_auto_push on;
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
@haxpor
haxpor / ffmpeg.log
Created April 6, 2019 18:32
Error log of ffmpeg capting screen video then feed into rtmp target
$ ffmpeg -analyzeduration 0 -video_size 1280x1080 -framerate 25 -re -f x11grab -i :0.0 -c:v libx264 -crf 23 -flags +global_header -preset ultrafast -minrate 7200 -maxrate 8k -vsync 1 -f flv -metadata streamName=ZombieHeroLiveStream rtmp://127.0.0.1/live-video
ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine -
@haxpor
haxpor / divide_and_conquer.c
Created April 4, 2019 06:04
Using recursive function (divide and conquer) to render ruler with SDL2. Compile with `gcc divide_and_conquer.c -lSDL2`
#include <SDL2/SDL.h>
#include <stdio.h>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define RULER_HEIGHT_FACTOR 5
static const int base_line = SCREEN_HEIGHT / 2;
@haxpor
haxpor / 2d_pointers_and_others.c
Created March 22, 2019 00:37
Solution for question asked in reddit /r/c_programming
/// for https://www.reddit.com/r/C_Programming/comments/b3wnhv/need_help_with_creating_pointers_of_a_2d_array_of/?st=JTJ6V0A6&sh=4926d7ec
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (int argc, char** argv)
{
// 1. Static fixed-size array
char ss[3][4][255];
@haxpor
haxpor / header_template.md
Created March 20, 2019 16:20
Header template for blog post for wasin.io
layout title date thumbnail tags comments og_image
post
Sharing WiFi Internet from Macbook to Ethernet with Wireless Router as Access Point
2019-03-20 22:13
/assets/images/post-thumbnail/router-thumbnail.png
router
internet sharing
macos
wireless router
true
/assets/images/post-thumbnail/router-thumbnail.png
@haxpor
haxpor / splot-sphere.sh
Last active March 17, 2019 19:52
Simple script to plot sphere in 3d via parametric equations, wait until we close the gnuplot window, or hit button. Execute it with ./splot-sphere.sh. You might have to `chmod 755 splot-sphere.sh` first.
#!/usr/local/bin/gnuplot
reset
set parametric
# more smooth of 3d polygon
set isosamples 30
# not see through
# comment this line will have better performance
@haxpor
haxpor / README.md
Last active March 12, 2019 05:50
Demonstrate that we actually don't need header file especially for functions that used internally, just compile them together (technically link obj files together).

You can compile with (technically both are the same)

  1. Compile both source files at the same time
  • gcc test-objfile.c test-objfile-companion.c
  1. Compile each one individually, then output objf file to link together
  • gcc -c test-objfile.c -o test-objfile.o
  • gcc -c test-objfile-companion.c -o test-objfile-companion.o
@haxpor
haxpor / test-treetrv.c
Created March 11, 2019 11:36
Example code demonstrating tree traversal in DFS
// demonstrate tree traversal
#include <stdio.h>
#include <stdlib.h>
typedef struct node node;
struct node
{
struct node* child[2];
char id;
};
@haxpor
haxpor / pointers.c
Created March 9, 2019 19:10
Pointer sample code to demonstrate address manipulation and checking if pointers point to the same data, or are actually the same pointer.
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char** argv)
{
int* ptr = malloc(sizeof(int) * 3);
*(ptr) = 1;
*(ptr + 1) = 2;
*(ptr + 2) = 3;
@haxpor
haxpor / test-readuserdir.c
Last active March 7, 2019 17:35
Test code reading file from user's home directory. As per POSIX, it requires OS to set HOME environment variable, so it should always be there. Updated: see the full repo at https://github.com/abzico/libpng_example
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv)
{
// get home directory (it's always set as HOME required by POSIX)
const char* homedir = getenv("HOME");
char tempfile[128];