Skip to content

Instantly share code, notes, and snippets.

@Gerjo
Gerjo / dodgy_ms_appcenter_keys.mm
Created November 20, 2019 13:31
Remove dodgy MS AppCenter NSUserDefaults keys
NSUserDefaults* def = [NSUserDefaults standardUserDefaults];
for(NSString* key in @[@"pastDevicesKey", @"SessionIdHistory", @"UserIdHistory"])
{
id obj = [def objectForKey:key];
// These must be NSData.
if ([obj isKindOfClass:[NSString class]])
{
NSLog(@"Removed dodgy %@ key from NSUSerDefaults", key);
using UnityEngine;
using System.Collections;
public class LoadMain : MonoBehaviour
{
static int i = 0;
void OnEnable()
{
if(i++ == 0)
@Gerjo
Gerjo / gist:22b340bc19703a415999
Created November 8, 2015 22:58
FBSDKLoginManager creation
@interface FBLogin : NSObject
+(FBSDKLoginManager*) Instance;
@end
@implementation FBLogin
+(FBSDKLoginManager*) Instance {
static FBSDKLoginManager* instance = nil;
if(instance == nil)
@Gerjo
Gerjo / gist:7d3d9eaae71aef371410
Created June 2, 2015 14:10
Abusing static local variables?
class Renderer {
public:
void Cube(Mat44 transform, Canvas canvas) {
// bunch of OpenGL calls.
}
// Overload without a texture.
void cube(Mat44 transform) {
Parser.prototype.interpret = function(input, offset, depth, parent, linenumber) {
depth = depth || 0;
offset = offset || 0;
parent = parent || null;
var PAREN_START = '(';
var PAREN_END = ')';
var CHAIN = '.';
var COMMA = ',';
var ALIAS = '=';
var NEWLINE = '\n';
@Gerjo
Gerjo / Monte carlo
Created December 14, 2014 15:44
Monte carlo integration
console.clear();
function f(x) {
return 3 + Math.pow(x, 2);
}
var w = 2;
var h = 4;
@Gerjo
Gerjo / cubic Graph triangles
Created November 1, 2014 11:39
Code to test if a graph contains triangles. Requires N^3 time :(
console.clear();
var g = [];
// Adjacency list representation of a graph
g[0] = [1, 3];
g[1] = [0, 2];
g[2] = [1, 3, 4];
g[3] = [0, 2, 4];
g[4] = [2, 3];
@Gerjo
Gerjo / order_of_groups.js
Created October 22, 2014 16:50
Order of groups/rings/fields
console.clear();
var n = 9; // Group modulo
var out = " ";
for(var i = 0; i < n; ++i) {
out += Pad(i) + " ";
}
@Gerjo
Gerjo / gist:9cb4558ae99777015825
Created September 30, 2014 12:42
Large haar transform matrix
Final:
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
@Gerjo
Gerjo / gist:6db0803e730eeaf505c7
Created September 24, 2014 12:39
Portfolio structure
class Portfolio extends Composite {
public function __construct() {
parent::__construct();
$this->addChild(
new Storage(),
new Template("../views/head.html"),
new Menu(