Skip to content

Instantly share code, notes, and snippets.

@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

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 / focus.bar
Created October 6, 2016 15:09
Script to focus application (Windows 10 shows taskbar when application starts) (source: http://stackoverflow.com/questions/8266840/focus-a-batch-started-application)
:start
call :focus "Title of Window"
timeout /t 10 /nobreak > NUL
goto start
::exit /b
:focus
setlocal EnableDelayedExpansion
if ["%~1"] equ [""] (
@roxlu
roxlu / TestFboChangeBuffer.cpp
Last active September 11, 2020 15:48
Comparing the performance of different ping/pong techniques when using FBOs. One version uses two fbos and swaps between these, the other switches the draw and read buffer. See these results https://docs.google.com/spreadsheets/d/1ZyTQGkjYQajQtu8OvgRyaXJl46F4rZJStBCEK2kebgE/edit?usp=sharing for a comparison. It seems that switching read / draw b…
#include <poly/Log.h>
#include <TestFboChangeBuffer.h>
using namespace poly;
TestFboChangeBuffer::TestFboChangeBuffer()
:fbo(0)
,dx(0)
{
tex[0] = 0;
@roxlu
roxlu / fun.cpp
Last active August 29, 2015 14:19 — forked from kizzx2/fun.cpp
THIS DOES NOT WORK WITH 5.2
// fun.cpp
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
#include <iostream>
@roxlu
roxlu / compile.sh
Created December 28, 2014 18:03
Apache, PHP and MySQL build script for Mac 10.10
#!/bin/bash
d=${PWD}
sd=${d}/sources
bd=${d}/build
id=${d}/installed/
PATH_ORIG=${PATH}
CC_ORIG=${CC}
CPP_ORIG=${CPP}
@roxlu
roxlu / CMakeLists.txt
Created September 26, 2014 12:55
Work in progress, simple cross platform mutex and threading code
cmake_minimum_required(VERSION 2.8.11)
set(bd ${CMAKE_CURRENT_LIST_DIR})
set(id ${bd})
include_directories(${id})
add_executable(test_thread test_thread.cpp)
if (WIN32)
@roxlu
roxlu / opengl_wrappers.c
Last active March 18, 2018 16:05
A couple of wrappers for opengl which are handy when you want to provide some openGL features in your library. Simply embed these into your cpp file. (Note that your executable will become slightly bigger because of this.)
/*
See https://gist.github.com/roxlu/6152fccfdd0446533e1b for the latest version.
Author: roxlu
Twitter: http://www.twitter.com/roxlu
*/
/* ------------------------------------------------------------------------*/
@roxlu
roxlu / AsyncUpload.cpp
Last active April 26, 2019 09:44
Experimental code to test fast pixel transfers using PBOs.
#include <gfx/AsyncUpload.h>
namespace gfx {
AsyncUpload::AsyncUpload()
:width(0)
,height(0)
,dx(0)
,channels(0)
,n(0)
@roxlu
roxlu / test_fex_load_image.cpp
Created August 22, 2014 13:22
Examples on how to load + reuse memory using rx_load_png and rx_load_jpg
/*
test_fex_load_image
-------------------
Plain test which loads + reloads a couple of images and reallocating the
previously allocated buffer when needed. Just a tiny test to speed up
the image loading process.
*/