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 / namegenerator.cpp
Last active August 29, 2015 14:13
Name Generator
#include <alloca.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
/* Implementation of Nolithius' name generator:
* Demo: http://www.nolithius.com/game-development/weightedletter-name-generator
* Code: https://code.google.com/p/weighted-letter-namegen
@JCash
JCash / p4init.py
Last active December 12, 2015 01:19
Python API startup
try:
from P4 import P4, P4Exception
p4 = P4()
p4.connect()
print p4.client
except P4Exception, e:
print "P4 Error", str(e)
@JCash
JCash / jc::hashtable_chaining.h
Created March 27, 2016 09:15
A small, fast, cache friendly hash table using chaining
#pragma once
/** A small hash table
*
* - The memory must be allocated by the user
* - It cannot grow
* - It asserts when putting an item into a full table
* - Supports keys with % and == operators
* - Supports values with = operator
*/
{
"shell_cmd": "./waf",
"working_dir": "$folder",
"file_regex": "\\.\\.\\/(.+?):(\\d+):(\\d+)"
}
[
{ "keys": ["alt+tab"], "command": "switch_file", "args": {"extensions": ["cpp", "cxx", "cc", "c", "hpp", "hxx", "hh", "h", "ipp", "inl", "m", "mm", "vsh", "fsh"]} },
{ "keys": ["super+shift+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"github"} },
{ "keys": ["ctrl+§"], "command": "show_panel", "args": {"panel": "console", "toggle": true} }
]
@JCash
JCash / make_gif_from_video.sh
Created July 17, 2016 10:12
A quick way to convert Defold video (.ivf) into a compressed .gif
#!/usr/bin/env bash
FPS=15
SIZEPX=320
STARTTIME=0
DURATION=0
PALETTE="/tmp/palette.png"
TMPGIF="/tmp/$2"
@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 / 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 / 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 / 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;