Skip to content

Instantly share code, notes, and snippets.

View kexoth's full-sized avatar

Aleksandar Kex Trpeski kexoth

View GitHub Profile
@kexoth
kexoth / gist:5489623
Created April 30, 2013 15:52
Evolving
evolveWeight: function () {
var step = 0.01;
var index_to_decrease = Enemy.TypeWeight.indexOf(getBiasedRandomItem(Enemy.TypeWeight, Enemy.TypeWeight));
var min = Math.min.apply(Math, Enemy.TypeWeight);
var index_to_increase = Enemy.TypeWeight.indexOf(min);
Enemy.TypeWeight[index_to_increase] += step;
Enemy.TypeWeight[index_to_decrease] -= step;
cc.log("Weight: " + Enemy.TypeWeight);
var audioEngine = cc.AudioEngine.getInstance();
var MainLayer = cc.LayerColor.extend({
_enemies: [],
_projectiles: [],
_enemiesDestroyed: 0,
_timer: 0,
_pauseButton: null,
var appFiles = [
'./Src/resource.js',
'./Src/MainLayer.js',
'./Src/GameOver.js',
'./Src/Enemy.js',
'./Src/Projectile.js',
'./Src/BiasedRandomGenerator.js'
];
this.options.uploadPath = this.options.uploadServer + '/upload?' + toURIParams({
timestamp : this.options.timestamp,
app_id : this.options.app,
id : this.options.id,
identifier : this.options.identifier,
title : this.options.name,
url : this.options.url,
tags : this.options.tags,
screens : this.options.screens,
css : this.options.css,
@kexoth
kexoth / iStyle.js
Last active December 30, 2015 02:29
var node_io = require("node.io");
function methods(input){
var _methods = {
input:input,
run: function(url) {
this.getHtml(url, function(err, $) {
var items = [];
$('li.item').each(function (li){
@interface NSManagedObject (Serialization)
- (NSDictionary*) toDictionary;
- (void) populateFromDictionary:(NSDictionary*)dict;
+ (NSManagedObject*) createManagedObjectFromDictionary:(NSDictionary*)dict
inContext:(NSManagedObjectContext*)context;
@end
var http = require('http');
var url = require('url');
var activeState = "0";
var reqCounter = 0;
var server = http.createServer(function (req, res) {
console.log("____________________________");
console.log("URL:", decodeURIComponent(req.url));
@kexoth
kexoth / gist:9646192
Last active August 29, 2015 13:57 — forked from ericchen/gist:3081970
var crypto = require('crypto');
var AESCrypt = {};
AESCrypt.decrypt = function(cryptkey, iv, encryptdata) {
encryptdata = new Buffer(encryptdata, 'base64').toString('binary');
var decipher = crypto.createDecipheriv('aes-128-cbc', cryptkey, iv),
decoded = decipher.update(encryptdata);
@kexoth
kexoth / AESCrypt.js
Created March 20, 2014 00:04
AES 128 Encryption/Decription with CBC, PKCS7 Padding & Base64 Encoding/Decoding.
var http = require('http');
var url = require('url');
var crypto = require('crypto');
var AESCrypt = {};
AESCrypt.decrypt = function(cryptkey, iv, encryptdata) {
encryptdata = new Buffer(encryptdata, 'base64').toString('binary');
var decipher = crypto.createDecipheriv('aes-128-cbc', cryptkey, iv),
decoded = decipher.update(encryptdata, 'binary', 'utf8');
@kexoth
kexoth / CounLinesOfCode.hs
Last active August 29, 2015 14:02
Started this gist as comparison implementation between scripts for counting number of files & lines of code in projects in Swift (me) & Lua(@nikolamin). Added Python (@whoeverest) & Haskell (@bor0).
import System.Directory
import Control.Monad (filterM, mapM, liftM)
import System.FilePath ((</>))
getDirsRec :: FilePath -> IO [FilePath]
getDirsRec d = do
dirContents <- getDirectoryContents d
let dirContents' = [ d </> x | x <- dirContents, x /= ".", x /= ".." ]
dirs' <- mapM dirRec dirContents'
return (concat dirs' ++ [d])