Skip to content

Instantly share code, notes, and snippets.

@roxlu
roxlu / H264_Decoder.cpp
Created March 3, 2014 16:57
LibAV parser and decoder example with openGL (YUV420 -> RGB shader).
#include "H264_Decoder.h"
H264_Decoder::H264_Decoder(h264_decoder_callback frameCallback, void* user)
:codec(NULL)
,codec_context(NULL)
,parser(NULL)
,fp(NULL)
,frame(0)
,cb_frame(frameCallback)
,cb_user(user)
@roxlu
roxlu / main.cpp
Created November 2, 2012 09:46
OpenSSL + LibUV: client https
#include <iostream>
#include <libgen.h>
#include <openssl/ssl.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <uv.h>
#include <vector>
#include <iterator>
#include <algorithm>
@leafac
leafac / notes.md
Created August 25, 2021 13:22
Notes on Timezones in Node.js & SQLite Applications
  • SQLite’s datetime functions are all UTC, but they don’t explicitly include the timezone information
  • In JavaScript (browsers & Node.js) datetimes without explicit timezone information are interpreted as local time
  • In servers (for example, DigitalOcean & GitHub Actions machines) the timezone is usually set to UTC
  • In development, the timezone is set to the user’s timezone
  • We can change the timezone for the Node.js process in macOS/Linux with the TZ=UTC environment variable
  • On Windows, the only solution is to temporarily change the OS timezone
  • This sounds too heavy-handed and storing datetimes without an explicit timezone seems like a bad idea, anyway
  • So the best solution that works everywhere is to avoid using SQLite datetime functions for generating values that will be stored in the database (it’s still fine to use them for queries)
  • To be exact, I’m talking about SQLite’s CURRENT_TIMESTAMP, datetime() and so forth
  • The correct way of doing it is using the more generic SQLite datetime function
@roxlu
roxlu / install_cygwin_sshd.txt
Last active November 27, 2023 22:20
Installing CYGWIN + SSHD for remote access through SSH on windows
Installing CYGWIN with SSH
1) Download cygwin setup.exe from http://www.cygwin.com
- Execute setup.exe
- Install from internet
- Root directory: `c:\cygwin` + all users
- Local package directory: use default value
- Select a mirror to download files from
- Select these packages:
- editors > xemacs 21.4.22-1
- net > openssh 6.1-p

API Design: Builder APIs (October-2020)

Some time has past (three years!) since I last wrote about API specifically about coroutines style APIs so I thought why not write another one about a different API type I encounter relatively often. The builder API.

Now first let me take a step back and put this into 20,000 feet view on where builder APIs are located in the grant scheme. In general everything in computing is separated into input, processing and finally output. In its most basic form I am currently typing on my keyboard. All pressed keys are processed from the OS up to the browser I am writing this in and finally rendered and displayed on the screen as output. Of course this example is very user centric

@roxlu
roxlu / Image.cpp
Created July 9, 2012 17:48
stbi image loading, super clean png/jpg/psd/hdr loading.
#include <roxlu/experimental/Image.h>
namespace roxlu {
Image::Image()
:width(0)
,height(0)
,pixels(NULL)
{
}
@roxlu
roxlu / CMakeLists.txt
Created May 30, 2013 14:32
CMake: how to copy a Framework on Mac to the install directory (${roxlu_app_install_dir}) and change the @executable_path so that your application can link with it
# EXPERIMENTAL: Copy frameworks from extern/lib/mac/frameworks, to the install dir and set the @executable paths
# frameworks from the extern/lib/mac/frameworks dir
# ----------------------------------------------------------------------------
foreach(framework_name in ${roxlu_frameworks})
set(framework_dir ${roxlu_base_dir}/extern/lib/mac/frameworks/${framework_name}.framework)
if(IS_DIRECTORY ${framework_dir})
set(framework_dest_dir ${roxlu_app_install_dir}/lib/)
set(framework_file ${framework_dest_dir}${framework_name}.framework/${framework_name})
get_filename_component(framework_file ${framework_file} ABSOLUTE)
@roxlu
roxlu / YUV420PGrabber.cpp
Created July 2, 2013 08:36
OpenGL RGB > YUV420P shader/class (doesn't do much more. implementation/usage is up to you)
#include <assert.h>
#include <roxlu/core/Utils.h>
#include <roxlu/core/Log.h>
#include "YUV420PGrabber.h"
YUV420PGrabber::YUV420PGrabber()
:y_prog(0)
,y_vert(0)
,y_frag(0)
,uv_prog(0)
@roxlu
roxlu / openframeworks_fbo_test.cpp
Created June 26, 2012 08:50
Raw FBO, openFrameworks
#include "testApp.h"
#include "Error.h"
//--------------------------------------------------------------
void testApp::setup(){
ofEnableNormalizedTexCoords();
ofDisableArbTex();
int w = ofGetWidth();
int h = ofGetHeight();
@roxlu
roxlu / X264Encoder.cpp
Created June 26, 2013 21:01
X264 encoder example
#include <roxlu/core/Log.h>
#include <roxlu/core/Utils.h>
#include <video/X264Encoder.h>
X264Encoder::X264Encoder()
:in_width(0)
,in_height(0)
,in_pixel_format(AV_PIX_FMT_NONE)
,out_width(0)
,out_height(0)