Skip to content

Instantly share code, notes, and snippets.

View syoyo's full-sized avatar
💗
ray tracing

Syoyo Fujita syoyo

💗
ray tracing
View GitHub Profile
@syoyo
syoyo / gist:9acc46554723db14d3a5
Created December 21, 2015 11:44
clang/LLVM for Android ARM64 corss compile script
#!/bin/bash
rm -rf CMake*
export NDK=/home/syoyo/local/android-ndk-r10e
export SYSROOT=$NDK/platforms/android-21/arch-arm64
export CC="$NDK/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc"
export CXX="$NDK/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-g++"
#include <iostream>
#include <string>
static int _ReadUTF8(char const *&cp, std::string *errMsg)
{
// Return a byte with the high `n` bits set, rest clear.
auto highBits = [](int n) {
return static_cast<unsigned char>(((1 << n) - 1) << (8 - n));
};
@syoyo
syoyo / traffic-control.sh
Created July 29, 2022 11:59 — forked from ole1986/traffic-control.sh
Traffic control script for incoming and outgoing packages using TC (on a specific ip address)
#!/bin/bash
VERSION="1.0.2"
# Interface connect to out lan
INTERFACE="eth0"
# Interface virtual for incomming traffic
VIRTUAL="ifb0"
# set the direction (1 = outgoing only, 2 = incoming only 3 = both)
DIRECTION=3
# Speed
#include <stdio.h>
#include <gmmintrin.h>
// x4 ~ x0 must have either value 0 or 1.
#define MM256_SHUFFLE(x3, x2, x1, x0) \
((x3 << 3) | (x2 << 2) | (x1 << 1) | (x0))
void
test()
{
@syoyo
syoyo / gist:2e80c2027278e7cde2107bdb2747d472
Created September 25, 2020 10:07
OptiX 7.1 illegal memory access issue
// Issue
// * Allocate and provice insufficient data size(e.g. vertex data) fo GAS input.
// * Call `optixAccelBuild` with "correct" buffer size(e.g. `buildInput.triangleArray.numVertices`)
// * Build GAS against invalid data but no error report at this time
// * Some memory object causes 'illegal memory access' error when freeing(also happens in CUDA driver API)
// How to reprocible
//
// OptiX 7.1 optixHair SDK sample
// Uncomment following in Util.h
@syoyo
syoyo / gist:8e980a1c04f4253894d32da25d68bad4
Created July 5, 2020 12:30
_mm_min_ps implementation in ARM NEON
#include <arm_neon.h>
#include <cstdio>
#include <limits>
#include <cassert>
#include <cmath>
#include <cstdint>
bool check_snan(float f)
{
bool is_nan = std::isnan(f);
@syoyo
syoyo / gist:62c0ec0183e91bff668624eba91f76f4
Created July 5, 2020 12:30
_mm_min_ps implementation in ARM NEON
#include <arm_neon.h>
#include <cstdio>
#include <limits>
#include <cassert>
#include <cmath>
#include <cstdint>
bool check_snan(float f)
{
bool is_nan = std::isnan(f);
@syoyo
syoyo / gist:831c4b1926aa88c0da9221211723da2d
Created December 17, 2018 13:12
C++ implementaion of "A simple method to construct isotropic quasirandom blue noise point sequences"
//
// C++ implementaion of "A simple method to construct isotropic quasirandom blue
// noise point sequences"
//
// http://extremelearning.com.au/a-simple-method-to-construct-isotropic-quasirandom-blue-noise-point-sequences/
//
// Assume 0 <= x
static double myfmod(double x) { return x - std::floor(x); }
@syoyo
syoyo / gist:527bd92bd08759b3a165
Created November 17, 2015 06:13
draw image using DataURI
socket.on("render_data", function(data) {
console.log("render_data");
var canvas = document.getElementById('mycanvas');
var ctx = canvas.getContext('2d');
var canvasWidth = canvas.width;
var canvasHeight = canvas.height;
var img = new Image();
img.onload = function() { ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); };
@syoyo
syoyo / gist:e29580d6f952d30e8042
Last active December 2, 2017 20:56
GCE instance explicit termination
gcloud compute instances create ${GCE_MASTER_INSTANCE_NAME} ...
# wait instance boot up
# fixme: there should be much better way
sleep 30
# shutdown after 60 min
# must add -f flag(background execution)
gcloud compute ssh ${GCE_MASTER_INSTANCE_NAME} --zone ${GCE_ZONE} --ssh-flag="-f" --command="sudo /sbin/shutdown -h -P +60"