Skip to content

Instantly share code, notes, and snippets.

View kbinani's full-sized avatar

kbinani kbinani

View GitHub Profile
macro(setup_source_groups SourceFileList ProjectRootDir)
get_filename_component(ProjectRootDir "${ProjectRootDir}" ABSOLUTE)
string(REPLACE "\\" "/" ProjectRootDir "${ProjectRootDir}")
string(FIND "${ProjectRootDir}" ".." contains_dotdot)
if ("${contains_dotdot}" GREATER -1)
message(FATAL_ERROR " ProjectRootDir must not contains '..'. Use 'get_filename_component(<VAR> <FileName> DIRECTORY)' to get parent directory.")
endif()
foreach(source_file_path ${SourceFileList})
macro(add_msvc_precompiled_header PrecompiledHeader PrecompiledSource SourcesVar)
if(MSVC)
get_filename_component(PrecompiledBasename ${PrecompiledHeader} NAME_WE)
set(PrecompiledBinary "$(IntDir)/${PrecompiledBasename}.pch")
set(Sources ${${SourcesVar}})
set_source_files_properties(${PrecompiledSource}
PROPERTIES COMPILE_FLAGS "/Yc\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\""
OBJECT_OUTPUTS "${PrecompiledBinary}")
set_source_files_properties(${Sources}
@kbinani
kbinani / modify_wavesurfer.sh
Created September 21, 2016 05:51
WaveSurfer on macOS Sierra workaround
cd WaveSurfer.app
rm -rf ./Contents/Frameworks/Tk.framework ./Contents/Frameworks/Tcl.framework
cp -R /System/Library/Frameworks/Tk.framework ./Contents/Frameworks/
cp -R /System/Library/Frameworks/Tcl.framework ./Contents/Frameworks/
lipo -extract i386 /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Wish.app/Contents/MacOS/Wish -output Contents/MacOS/Wish
static void mouseBezierPath(Point<int> p0, Point<int> p1, Point<int> p2, Point<int> p3)
{
double const length = p1.getDistanceFrom(p0) + p2.getDistanceFrom(p1) + p3.getDistanceFrom(p2);
double const kMouseSpeed = 2000; // pixel/second
double const kInterval = 0.0001; // second
int const numDiv = std::max(1, static_cast<int>(length / kMouseSpeed / kInterval));
for (int i = 0; i <= numDiv; ++i) {
double const t = i / double(numDiv);
Point<int> p = (((-p0 + (p1 - p2) * 3 + p3) * t + (p0 - p1 * 2 + p2) * 3) * t + (p1 - p0) * 3) * t + p0;
Desktop::setMousePosition(p);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
function command {
echo "$@"
"$@"
if [ $? -ne 0 ]; then
echo "Error: command \"$@\" failed" >&2
exit 1
fi
}
M_LLVM_VERSION=3.6.2
wget "http://llvm.org/releases/${M_LLVM_VERSION}/llvm-${M_LLVM_VERSION}.src.tar.xz"
tar Jxf llvm-${M_LLVM_VERSION}.src.tar.xz
M_PWD=$(pwd)
(
cd llvm-${M_LLVM_VERSION}.src/tools
wget "http://llvm.org/releases/${M_LLVM_VERSION}/cfe-${M_LLVM_VERSION}.src.tar.xz"
tar Jxf cfe-${M_LLVM_VERSION}.src.tar.xz
mv cfe-${M_LLVM_VERSION}.src clang
cd ../
#!/bin/bash
platform='Macintosh; '
os_cpu=$(sw_vers 2>/dev/null | grep ProductVersion | sed 's/^ProductVersion:.\(.*\)/\1/g' | tr . _)
TMP=$(mktemp -t tmp)
trap "rm $TMP" EXIT
curl https://chromium.googlesource.com/chromium/src/+/master/content/webkit_version.h.in 2>/dev/null | sed 's:</[^>]*>: :g' | sed 's:<[^>]*>: :g' > "$TMP"
WEBKIT_VERSION_MAJOR=$(cat "$TMP" | sed 's:^.*WEBKIT_VERSION_MAJOR[ ]*\([0-9]*\).*$:\1:g')
#!/bin/bash
which greadlink >/dev/null 2>&1 && which icc >/dev/null 2>&1 && (cd "$(dirname "$(greadlink -f "$(which icc)")")/../.."; pwd)
@kbinani
kbinani / unpackIEEE754Binary32.glsl
Last active August 29, 2015 14:21
Unpack IEEE754 binary32, from "int[4]" to "float"
float unpackIEEE754Binary32(int bytes[4]) {
/**
bytes[0][0]: sign {1 if minus}
bytes[0][1:7]: exponent(0:6)
bytes[1][0]: exponent(7)
bytes[1][1:7]: fraction(0:6)
bytes[2][0:7]: fraction(7:14)
bytes[3][0:7]: fraction(15:22)
*/