Skip to content

Instantly share code, notes, and snippets.

View tuefekci's full-sized avatar

Giacomo Tüfekci tuefekci

View GitHub Profile
(function() {
window.frame = require("nw.gui").Window.get();
window.frame.isFocused = true;
var windowFocusHandler = function() {
window.frame.isFocused = true;
}
, windowBlurHandler = function() {
window.frame.isFocused = false;
<?php
date_default_timezone_set('UTC');
$file = "timelog/timelog_".date("Y_m_d").".csv";
$args = $argv;
$now = date("Y-m-d H:i:s");
if(file_exists($file)) {
$content = file_get_contents($file);
@tuefekci
tuefekci / nginx.conf
Created November 19, 2015 11:54 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@tuefekci
tuefekci / level2.js
Created January 13, 2016 22:36
elevetor level2.js
{
init: function(elevators, floors) {
var elevator = elevators[0]; // Let's use the first elevator
floors.forEach(function(floor) {
function addFloorToDestinationQueue(floor) {
if(elevator.destinationQueue.indexOf(floor) === -1) {
elevator.destinationQueue.push(floor);
}
@tuefekci
tuefekci / level3.js
Created January 13, 2016 22:42
elevator level3.js
{
init: function(elevators, floors) {
var elevator = elevators[0]; // Let's use the first elevator
floors.forEach(function(floor) {
function addFloorToDestinationQueue(floor) {
if(elevator.destinationQueue.indexOf(floor) === -1) {
elevator.destinationQueue.push(floor);
}
@tuefekci
tuefekci / level4.js
Created January 13, 2016 23:04
elevator level4.js
{
init: function(elevators, floors) {
console.log(elevators);
// # Elevators
elevators.forEach(function(elevator) {
elevator.on("stopped_at_floor", function(floorNum) {
if(elevator.destinationQueue.indexOf(floorNum) !== -1) {
elevator.destinationQueue.splice(elevator.destinationQueue.indexOf(floorNum), 1);
}
});
@tuefekci
tuefekci / level5.js
Created January 13, 2016 23:06
elevator level5.js - same like level 4
{
init: function(elevators, floors) {
console.log(elevators);
// # Elevators
elevators.forEach(function(elevator) {
elevator.on("stopped_at_floor", function(floorNum) {
if(elevator.destinationQueue.indexOf(floorNum) !== -1) {
elevator.destinationQueue.splice(elevator.destinationQueue.indexOf(floorNum), 1);
}
});
@tuefekci
tuefekci / level6.js
Created January 13, 2016 23:07
elevator level6.js - still same like level4
{
init: function(elevators, floors) {
console.log(elevators);
// # Elevators
elevators.forEach(function(elevator) {
elevator.on("stopped_at_floor", function(floorNum) {
if(elevator.destinationQueue.indexOf(floorNum) !== -1) {
elevator.destinationQueue.splice(elevator.destinationQueue.indexOf(floorNum), 1);
}
});
@tuefekci
tuefekci / level7.js
Created January 13, 2016 23:09
elevator level7.js - still like level4 probably last time it works without optimazations
{
init: function(elevators, floors) {
console.log(elevators);
// # Elevators
elevators.forEach(function(elevator) {
elevator.on("stopped_at_floor", function(floorNum) {
if(elevator.destinationQueue.indexOf(floorNum) !== -1) {
elevator.destinationQueue.splice(elevator.destinationQueue.indexOf(floorNum), 1);
}
});
@tuefekci
tuefekci / level8.js
Created January 13, 2016 23:10
elevator level8.js - still like level4
{
init: function(elevators, floors) {
console.log(elevators);
// # Elevators
elevators.forEach(function(elevator) {
elevator.on("stopped_at_floor", function(floorNum) {
if(elevator.destinationQueue.indexOf(floorNum) !== -1) {
elevator.destinationQueue.splice(elevator.destinationQueue.indexOf(floorNum), 1);
}
});