Skip to content

Instantly share code, notes, and snippets.

@solkar
solkar / jekyll-cheat-sheet.md
Last active December 20, 2015 01:19
Jekyll cheat sheet

Define an array in yaml header

foobar_array:
 - name: Mary Smith
   age: 27
 - {name: John Smith, age: 33}

Create new page

$ rake page name="about.md"

@solkar
solkar / DamageInfo.js
Created August 11, 2013 09:16
Class to exchange damage info
public class DamageInfo {
var damage : int;
var code : String;
function DamageInfo (d : int, s : String) {
damage = d;
code = s;
}
}
@solkar
solkar / seed.m
Last active December 22, 2015 07:08
Seed random number generator
srandom(time(NULL));
@solkar
solkar / singleton.cpp
Created January 27, 2014 16:12
cocos2d-x C++ singleton
#include "GameManager.h"
using namespace cocos2d;
static GameManager *_sharedGameManager = NULL;
GameManager* GameManager::getInstance()
{
if (! _sharedGameManager)
{
@solkar
solkar / gist:8663683
Created January 28, 2014 07:49
Convert m4a to mp3 in OSX
ffmpeg -i input.mp4 output.mp3
@solkar
solkar / NSMutableArray+Shuffling.h
Created February 4, 2014 06:50
shuffle NSMutableArray category
@interface NSMutableArray (Shuffling)
- (void)shuffle;
@end
#!/bin/bash
f=$(pwd)
sips --resampleWidth 512 "${f}/${1}" --out "${f}/iTunesArtwork"
sips --resampleWidth 1024 "${f}/${1}" --out "${f}/iTunesArtwork@2x"
sips --resampleWidth 57 "${f}/${1}" --out "${f}/Icon.png"
sips --resampleWidth 114 "${f}/${1}" --out "${f}/Icon@2x.png"
sips --resampleWidth 29 "${f}/${1}" --out "${f}/Icon-Small.png"
sips --resampleWidth 58 "${f}/${1}" --out "${f}/Icon-Small@2x.png"
sips --resampleWidth 50 "${f}/${1}" --out "${f}/Icon-Small-50.png"
@solkar
solkar / EventHandler.cpp
Created April 18, 2014 07:20
C++ callbacks
#include <functional>
class EventHandler
{
public:
void addHandler(std::function<void(int)> callback)
{
fCallback = callback
}
void performCallback()
@solkar
solkar / gist:11084097
Created April 19, 2014 13:14
Filter and remove objects from a std::vector
// filter collidable tiles
std::vector<Point> toRemove;
for (size_t q = 0; q < freeTileCandidates.size(); ++q)
{
Point testTile = freeTileCandidates[q];
if( this->tileIsCollidable( testTile ) )
toRemove.push_back(testTile);
}
// erase filtered tiles
for (size_t q = 0; q < toRemove.size(); ++q)
@solkar
solkar / gist:7110b2f29d64c1547d12
Last active December 10, 2019 19:06 — forked from alternegro/gist:3007373
XCode shortcuts

Xcode Shortcuts

Running

⌘R Run
⌘U Unit Test
⌘I Instruments Profile
⇧⌘B Analyze

Navigation