Skip to content

Instantly share code, notes, and snippets.

View honzabrecka's full-sized avatar
👋

Honza Břečka honzabrecka

👋
View GitHub Profile
/**
* ArrayUtil
* @author Jan Břečka
* @langversion 3.0
*/
/**
* Clones an array.
*/
package
{
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
/**
* RotationalRectangle
*
* @author Jan Břečka
var f:String;
var a:String = "a";
f = a || "b";
trace(f);
trace(2.53433 >> 0);
for (var i:int = 0; i < 9; i++)
trace(int(i / 3), (i / 3) >> 0);
1) /<(?!a |\/a).*?>/gi
2) /<a(.+?(href=["'](.+?)["'])?)?.*?>(.*?)<\/a>/gi
<a name="asdsad"></a>sad sa <a href="http://wdsad" name="sadasd">asd</a> <a href='sdfsdfdsf'>asdasd</a>sadsad<a>asdasd</a>
MATCH 1
1. [2-3] ` `
4. [17-17] ``
MATCH 2
1. [30-50] ` href="http://wdsad"`
stop();
var loaderListener:Object = new Object();
loaderListener.onLoadInit = function(swf:MovieClip):Void
{
//for (var p in swf) trace(swf[p]);
channel.send("as3bridge", "loaded");
};
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(loaderListener);
@honzabrecka
honzabrecka / a.php
Last active August 29, 2015 14:16
Fuck it, I'm PHP!
$a = ['item0', 'item1', 'item2', 'item3', 'item4', 'item5'];
$b = [2, 3];
print_r($a);
$t = array_flip($b);
$r = array_filter($a, function($i) use ($t) {
return !isset($t[$i]);
}, ARRAY_FILTER_USE_KEY);
@honzabrecka
honzabrecka / chunk.html
Last active August 29, 2015 14:17
chunked file upload with MD5 checksum
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
(function(factory){if(typeof exports==="object"){module.exports=factory()}else if(typeof define==="function"&&define.amd){define(factory)}else{var glob;try{glob=window}catch(e){glob=self}glob.SparkMD5=factory()}})(function(undefined){"use strict";var add32=function(a,b){return a+b&4294967295},cmn=function(q,a,b,x,s,t){a=add32(add32(a,q),add32(x,t));return add32(a<<s|a>>>32-s,b)},ff=function(a,b,c,d,x,s,t){return cmn(b&c|~b&d,a,b,x,s,t)},gg=function(a,b,c,d,x,s,t){return cmn(b&d|c&~d,a,b,x,s,t)},hh=function(a,b,c,d,x,s,t){return cmn(b^c^d,a,b,x,s,t)},ii=function(a,b,c,d,x,s,t){return cmn(c^(b|~d),a,b,x,s,t)},md5cycle=function(x,k){var a=x[0],b=x[1],c=x[2],d=x[3];a=ff(a,b,c,d,k[0],7,-680876936);d=ff(d,a,b,c,k[1],12,-389564586);c=ff(c,d,a,b,k[2],17,606105819);b=ff(b,c,d,a,k[3],22,-1044525330);a=ff(a,b,c,d,k[4],7,-176418897);d=ff(d,a,b,c,k[5],12,1200080426);c=ff(c,d,a,b,k[6],17,-1473231341);b=ff(b,c,d,a,k[7],22,-45705983
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Matrix;
var N:uint = 4;
var speed:uint = 1;
var marks:Vector.<Mark> = new Vector.<Mark>(N, true);
var vertices:Vector.<Point> = new Vector.<Point>(N, true);
var center:Point = new Point(rect.x, rect.y);
var matrix:Matrix = new Matrix();
@honzabrecka
honzabrecka / bayesian.cljs
Last active February 20, 2017 10:14
Bayesian classifier implemented in Clojure (well, it's actually in ClojureScript).
;------------------------------------------------
; bayesian
(def empty-training-set {:features {} :categories {}})
(defn train
[features category]
(reduce #(assoc-in %1 [:features %2] {category 1})
(assoc-in empty-training-set [:categories category] 1)
features))
const fs = require('fs')
const express = require('express')
const proxy = require("http-proxy").createProxyServer({"changeOrigin": true})
const index = './src/index.html'
const port = 3000
const proxyTarget = '...'
const app = express()