Skip to content

Instantly share code, notes, and snippets.

@graphitemaster
graphitemaster / WORKING_AROUND_OFFSETOF_LIMITATIONS.MD
Last active March 8, 2025 07:35
Working around offsetof limitations in C++

Working around offsetof limitations in C++:

There is sometimes a situation in which one needs to get the relative offset of a structure field, common examples of this include serialization frameworks which aid to serialize objects, vertex attributes for rendering (D3D, GL.), etc.

The most common technique for getting this information is through the offsetof macro defined in stddef.h. Unfortunately using the macro in C++ comes with a new set of restrictions that prevent some (subjectively valid) uses of it.

@tullmann
tullmann / waitForX
Created November 13, 2015 19:02
wait for an X11 server to be ready (good for running under XVFB when testing chrome)
#!/bin/bash
#
# waitForX [<cmd> [<arg> ...]]
#
# Wait for X Server to be ready, then run the given command once X server
# is ready. (Or simply return if no command is provided.)
#
function LOG {
echo $(date -R): $0: $*
@wasabeef
wasabeef / GLTextureView.java
Last active September 11, 2024 09:41
GLTextureView
package jp.wasabeef.sample;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.GLDebugHelper;
import android.util.AttributeSet;
import android.util.Log;
import android.view.TextureView;
import android.view.View;
import java.io.Writer;
@zonque
zonque / sctptest.c
Last active November 20, 2024 15:30
Simple client/server test for SCTP
/*
* Compile:
*
* gcc sctptest.c -o server -lsctp -Wall
* ln -s server client
*
* Invoke:
*
* ./client
* ./server
@ygotthilf
ygotthilf / jwtRS256.sh
Last active May 12, 2025 12:07
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@voluntas
voluntas / webrtc.rst
Last active March 28, 2025 06:01
WebRTC コトハジメ
@DavydLiu
DavydLiu / Mac-Port-Forwarding-OS-X.md
Last active January 17, 2019 16:13
Mac Port forwarding on OS X Yosemite 10.10 and above

##1. Create the anchor file:

sodu vim /etc/pf.anchors/com.liuxingruo

Inside the anchor file, enter:

rdr pass on lo0 inet proto tcp from any to self port 80 -> 127.0.0.1 port 9191
rdr pass on en0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 9191
rdr pass on en1 inet proto tcp from any to any port 80 -&gt; 127.0.0.1 port 9191
@sile
sile / 0_raft.md
Last active May 27, 2024 07:53
Raft(分散合意アルゴリズム)について
@rodolfo42
rodolfo42 / Db.scala
Last active January 17, 2018 15:23
How to use transactions with finagle-mysql
package transactions
import com.twitter.finagle.exp.mysql.{Client, OK, Result}
class Db(mysqlClient: Client) {
val insertOrder = "INSERT INTO orders (ref) VALUES(?)"
val insertOrderItem = "INSERT INTO order_items (order_id, item_id) VALUES(?, ?)"
def persistOrderWithItems[T](order: Order)(whenDone: (OK, Seq[Result]) => T): Future[T] = {
@ph0b
ph0b / build.gradle
Last active February 22, 2016 07:28
build gradle with ndk build tasks that are using an alternative configuration or Application.mk for debug builds, using the new model.
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = rootProject.ext.compileSdkVersion
buildToolsVersion = rootProject.ext.buildToolsVersion
defaultConfig.with {