Skip to content

Instantly share code, notes, and snippets.

View JCash's full-sized avatar
💭
Game devving 24/7

Mathias Westerdahl JCash

💭
Game devving 24/7
View GitHub Profile
@JCash
JCash / binary2header.py
Created July 10, 2019 11:25
Create C/C++ embeddable header from binary file
#! /usr/bin/env python
import sys, os
def Usage():
print "Usage: ./binary2header.py <file>"
if __name__ == '__main__':
if len(sys.argv) < 2:
Usage()
@JCash
JCash / compile_webp_encoder.sh
Created June 6, 2019 14:34
A simple way to compile the WebP encoder, since the vanilla makefiles fail on OSX
#!/usr/bin/env bash
CC=clang
CCFLAGS="-c -I./libwebp-1.0.2"
function compile {
local DIR=$1
local NAME=$2
for file in `ls $DIR/*.c`; do
echo $file
@JCash
JCash / osxcross_build.sh
Last active November 18, 2018 22:04
A modified version of osxcross/build.sh. Build with "SDK_VERSION=10.11 ./build.sh"
#!/usr/bin/env bash
#
# Build and install the cctools the SDK and macports.
#
# This script requires the OS X SDK and the Clang/LLVM compiler.
#
pushd "${0%/*}" &>/dev/null
@JCash
JCash / cctools-dlfcn.patch
Last active December 1, 2018 11:22
A patch file to use with osxcross, to avoid a compile error. Modify build.sh to apply this patch too
--- include/foreign/dlfcn_backup.h 2018-11-18 21:22:45.000000000 +0100
+++ include/foreign/dlfcn.h 2018-11-18 21:23:00.000000000 +0100
@@ -3,7 +3,7 @@
#include_next <dlfcn.h>
#include <stdio.h> /* stderr */
#ifdef __CYGWIN__
-typedef struct dl_info {
+/*typedef struct dl_info {
const char *dli_fname;
void *dli_fbase;
@JCash
JCash / scan_build_gather_report.py
Last active July 21, 2018 15:04
If you have several folders with scan_build results, you can merge them together with this script, into one big report
#! /usr/bin/env python
import os
import re
import sys
import shutil
import argparse
from collections import defaultdict
INDEX_HTML = """
@JCash
JCash / array.cpp
Last active January 16, 2018 19:31
std::vector vs jc::Array test
#include <stdio.h>
#include <stdlib.h>
#if defined(STL)
#include <vector>
int Calc(int count)
{
std::vector<int> numbers;
@JCash
JCash / touchscreen.ino
Created August 29, 2017 16:37
Arduino touch screen example using Nintendo 2DS screen
// Touch screen example for arduino using a Nintendo 2ds touch screen
// Code is mostly inspired from http://tronixstuff.com/2010/12/29/tutorial-arduino-and-the-ds-touch-screen/
// and the Adafruit touch screen library
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
@JCash
JCash / osxinstall.sh
Last active July 28, 2017 21:49
Simply my way of migrating my dev setup between computers
#!/usr/bin/env bash
WORK=~/work
EXTERNAL=$WORK/external
PROJECTS=$WORK/projects
if [ ! -e $WORK ]; then mkdir $WORK; fi
if [ "" == "`which brew`" ]
@JCash
JCash / createbinarypatch.sh
Created April 15, 2017 12:23
Create a binary patch
# Creating a binary patch with the diff between folders
#$ git diff --no-index --binary a/ b/ > diff.patch
#$ diff -Naur a/ b/ > diff.patch
git diff --no-index --binary $1 $2
@JCash
JCash / box.fp
Last active January 4, 2024 07:30
Separable box blur in GLSL
#version 410
#ifdef GL_ES
precision mediump float;
#define LOWP lowp
#else
#define LOWP
#endif
uniform sampler2D texture0;