Skip to content

Instantly share code, notes, and snippets.

@mzaks
mzaks / PetrinetDsl.xtext
Created July 15, 2011 21:02
Xtext Petri Net definition
grammar de.bomzhi.petrinet.PetrinetDsl with org.eclipse.xtext.common.Terminals
generate petrinetDsl "http://www.bomzhi.de/petrinet/PetrinetDsl"
PetriNet:
(resources+=Resource)+
(places+=Place)+
(transactions+=Transaction)+
;
@mzaks
mzaks / tic_tac_toe.petrinet
Created July 15, 2011 21:04
tic tac toe definition
resource Cross
resource Zerro
place Start {
Cross: 1/..
Zerro: 0/..
}
place _1X1 {
Cross: 0/1
@mzaks
mzaks / MakeFilesWritable.java
Created October 24, 2011 07:24
Small program to make files writable recursivly
import java.io.File;
public class MakeFilesWritable {
/**
* @param args
*/
public static void main(String[] args) {
File root = new File("C:\\foo");
@mzaks
mzaks / CCAnimate+AsymetricalStart.m
Created October 17, 2012 14:56
CCAnimate+AsymetricalStart
//
// CCAnimate+AsymetricalStart.m
// CocosAnimatioPrototype
//
// Created by Maxim Zaks on 17.10.12.
// Copyright (c) 2012 Maxim Zaks. All rights reserved.
//
#import "CCAnimate+AsymetricalStart.h"
#import "CCAnimation.h"
enum ComponentId{
case Velocity
case Position
case Size
func describe()->NSString{
return "\(self.hashValue)"
}
}
@mzaks
mzaks / OMDeferred+FailWithResult.m
Created June 18, 2014 12:15
OMDeffered fail with result category
@implementation OMDeferred (FailWithResult)
-(void)fail:(NSError *)error withResult:(id)result{
NSAssert(error, @"Error object should not be nil");
NSAssert(error.domain, @"Error object should have a domain");
if(result){
NSMutableDictionary *newUserInfo = [NSMutableDictionary dictionaryWithDictionary:error.userInfo];
newUserInfo[ERROR_RESULT_KEY] = result;
error = [NSError errorWithDomain:error.domain code:error.code userInfo:newUserInfo.copy];
}
using Entitas;
public class PositionComponent : IComponent {
public int x, y;
public PositionComponent(int x, int y)
{
this.x = x;
this.y = y;
//
// AVLTree.swift
// AVLTree
//
// Swift port of immutable AVLTree I implemented with Stephan Partzsch
//
// Original ObjC implementation: https://github.com/StephanPartzsch/AVLTree
//
// Copyright (c) 2014 Maxim Zaks. All rights reserved.
//
@mzaks
mzaks / RectTransformTools.cs
Last active June 21, 2023 05:25
Adjust RectTransform Anchors for Unity UI
using UnityEngine;
using UnityEditor;
public class RectTransformTools {
[MenuItem("GameObject/Adjust RectTransform Anchors %l")]
static void Adjust()
{
foreach(GameObject gameObject in Selection.gameObjects){
adjustRectTransform(gameObject);
import Foundation
public typealias Action = ()->Void
/**
Bounced action takes interval and action to return another action, which limits the rate at which provided action can be fired.
It is like a bouncer at a discotheque. He will act on your questions only after you shut up for 'interval' of time.
This technique is important if you have action wich should fire on update, however the updates coming in to frequently sometimes.