Skip to content

Instantly share code, notes, and snippets.

View cambiata's full-sized avatar

Jonas Nyström cambiata

View GitHub Profile
@cambiata
cambiata / View_Model
Created October 15, 2011 08:07
Simplistic Kohana3 View_Model attempt
<?php
/**
*
* Simplistic View_Model attempt for Kohana 3
* @author Cambiata
*/
class View_Model {
public function render($viewfile=FALSE)
{
@dpeek
dpeek / VerEx.hx
Last active May 3, 2019 19:38
VerbalExpressions for Haxe
class VerEx
{
public static function main()
{
var test = new VerEx()
.startOfLine()
.then("http")
.maybe("s")
.then("://")
.maybe("www.")
import haxe.macro.Expr;
class FTW
{
public static function build()
{
return haxe.macro.Context.getBuildFields().map(transformField);
}
static function transformField(field:Field)
@Markavian
Markavian / gist:39f858306cde040e5775
Created October 7, 2014 18:39
Finally... a .htaccess file that routes correctly on my localhost and the server?
DirectoryIndex site/php/routes/index.php?path=index
<IfModule mod_rewrite.c>
Require all granted
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mkv25.net$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ site/php/routes/index.php?path=$1 [NC,L,QSA]
@yohhoy
yohhoy / aac_parser.py
Last active May 22, 2022 21:43
Parse AAC/ADTS header
#!/usr/bin/env python3
import sys
import struct
if len(sys.argv) < 2:
print("Usage: aac_parer.py <target.aac>")
exit()
aacfile = open(sys.argv[1], 'rb')
frame_no = 1
@nadako
nadako / Main.hx
Created June 24, 2015 19:36
Haxe + SDL = native love \o/
class Main {
static function main() {
Sdl.init(Sdl.INIT_EVERYTHING);
var win = Sdl.createWindow("Hello", 100, 100, 800, 600, Sdl.WINDOW_OPENGL);
var ren = Sdl.createRenderer(win, -1, Sdl.RENDERER_ACCELERATED);
var bmp = Sdl.loadBMP("test.bmp");
var tex = Sdl.createTextureFromSurface(ren, bmp);
Sdl.freeSurface(bmp);
for (i in 0...3) {
@francescoagati
francescoagati / Main.hx
Created June 14, 2016 19:09
haxe nested structInit
@:structInit
class A {
var x:Int;
var y:Int;
}
@:structInit
class B {
var a:A;
var k:Int;
@RealyUniqueName
RealyUniqueName / KeyValueIterator.hx
Last active October 14, 2016 10:35
Key-value map iterator
class KeyValueIterator<K,V> {
var map:Map<K,V>;
var keys:Iterator<K>;
static public inline function pairs<K,V>(map:Map<K,V>) return new KeyValueIterator(map);
public inline function new(map:Map<K,V>) {
this.map = map;
this.keys = map.keys();
}
import haxe.ds.Either;
class Main {
static function main() {
trace("HI");
var t : WildMap = ["a" => 1, "b"=> 2];
var f = function(x : Map<Int,String>){
trace(x);
for (k in x.keys()){
trace(k);
}
@kmcnellis
kmcnellis / firebaseImportUsersMD5.js
Created September 15, 2017 20:03
How to import users in Firebase using MD5 Hashing
var crypto = require('crypto');
var fs = require('fs');
var exec = require('child_process').exec;
var uploadCommand = "firebase auth:import users.json --hash-algo=MD5 --rounds=0";
var stringToBase64 = function(plaintext){
return new Buffer(plaintext).toString('base64');
}
var users = [