Skip to content

Instantly share code, notes, and snippets.

View ilkinulas's full-sized avatar

İlkin Balkanay ilkinulas

View GitHub Profile
@ilkinulas
ilkinulas / SlotScreen.as
Created January 26, 2013 18:38
Dedigin gibi sabit bir noktaya gore tum kutularin y koordinatlarini guncelleyince oldu :)
private function onEnterFrame(event:EnterFrameEvent):void {
const distance : Number = event.passedTime * velocity;
const reelHeight : Number = boxSize * boxes.length;
//0 ile reel height arasinda gidip geliyor...
totalDistance = (totalDistance + distance ) % reelHeight;
for (var i:int = 0; i<boxes.length; i++) {
boxes[i].y = (boxStartY + totalDistance + (i * boxSize) ) % reelHeight;
}
private function onEnterFrame(event:EnterFrameEvent):void {
const moveBy:Number = event.passedTime * velocity;
const numBoxes:int = boxes.length;
var box:Quad;
for (var i:int = 0; i < numBoxes; i++) {
box = boxes[i];
if (box.y >= boxEndY) {
var topBox:Quad = boxes[(i + 1) % numBoxes];
box.y = topBox.y - boxSize;
}
@ilkinulas
ilkinulas / gist:7261695
Created November 1, 2013 06:44
Thread.run() vs Thread.start()
Runnable runnable = new Runnable() {
public void run() {
// do something...
}
};
Thread thread = new Thread(runnable);
// 1. Thread run metodunu cagirirsan runnable current thread (thread.run()'i cagiran) icinde calisir.
// Bazen Unit test yazarken run metodunu cagiriyoruz. bu sayede Runnable icindeki islemler senkron yapilmis oluyor.
// run() metodundan cikildiginda run metodu icindeki islemlerin yapildigindan eminiz.
@ilkinulas
ilkinulas / ginrummy.yaml
Created February 2, 2016 14:24
GinRummy log patterns
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: GinRummyLog
scopeName: gin.log
fileTypes: [ginlog]
uuid: 786ded00-92e4-4105-a21a-fd030af63c5a
patterns:
- name: text.command
match: \"command\":[0-9]{4}
@ilkinulas
ilkinulas / colors.xml
Created February 7, 2016 06:15
Sublime color theme for gin rummy logs.
<!-- GinRummy -->
<dict>
<key>scope</key>
<string>gin.log text.command</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#F7860A</string>
<key>fontStyle</key>
<string>bold</string>
@ilkinulas
ilkinulas / GameLogic.cs
Last active February 20, 2016 12:04
NUnit test example
public class GameLogicTest {
[TestFixtureSetUp]
public void Init() {
//Init runs once before running test cases.
}
[TestFixtureTearDown]
public void CleanUp() {
//CleanUp runs once after all test cases are finished.
}
import sys
import re
import datetime
REGEX = "([0-9]{8} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3})(.*)";
shiftSeconds = int(sys.argv[2])
startTime = sys.argv[3]
startShifting = False
with open(sys.argv[1]) as fp:
package codekata.observer;
public interface CountDownObserver {
void onStart();
void onCountDown(long elapsed, long remaining);
void onFinish();
}
package codekata.observer;
public class CountDownTimerView implements CountDownObserver {
@Override
public void onStart() {
//play count down start animation
}
@Override
public void onCountDown(long elapsed, long remaining) {
package codekata.observer;
import java.util.LinkedList;
import java.util.List;
public class CountDownTimer {
private static long ONE_SECOND = 1000L;
private long countDownMillis;
private long elapsedTimeSinceLastTick;
private long totalElapsedTime;