Skip to content

Instantly share code, notes, and snippets.

View hakant's full-sized avatar

Hakan Tuncer hakant

View GitHub Profile
@hakant
hakant / main.js
Last active April 3, 2016 14:36
Hackathon Planner - main.js
import 'bootstrap';
import {AuthService} from './infrastructure/auth-service';
import {inject} from 'aurelia-framework';
import 'fetch';
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-validation');
import {Router} from "aurelia-router";
import {inject} from 'aurelia-framework';
import {AuthService} from './infrastructure/auth-service';
@inject(Router, AuthService)
export class NavBar {
constructor(router, auth) {
this.router = router;
this.auth = auth;
}
import {computedFrom} from 'aurelia-framework';
import {Container} from 'aurelia-dependency-injection';
import {ensure} from 'aurelia-validation';
import {Validation} from 'aurelia-validation';
export class Project {
@ensure(function(it) { it.isNotEmpty().hasLengthBetween(3, 100) })
_title = null;
@ensure(function(it) { it.isNotEmpty().hasLengthBetween(5, 300) })
Save() {
let me = this;
this.project.validation.validate()
.then(() => {
$("#new-card").modal('hide');
me.state.addOrUpdateProject(me.project);
me.router.navigateToRoute('overview');
}).catch(error => {
import {inject} from 'aurelia-framework';
import {computedFrom} from 'aurelia-framework';
import {ApplicationState} from './infrastructure/application-state';
@inject(ApplicationState)
export class Overview {
_projects = [];
constructor(state) {
state.getProjects()
<template>
<require from="./idea-card"></require>
<section>
<div class="card-columns">
<idea-card project.bind="project" repeat.for="project of projects" />
</div>
</section>
</template>
import {inject} from "aurelia-framework";
import {_} from 'lodash';
import {Tooltips} from '../data/tooltips'
@inject(Tooltips)
export class TooltipService {
_storageToken = "HackathonPlanner_Tooltips";
_tooltips = [];
_tooltipState = [
export class Tooltips {
data = [{
type: "Overview",
tips: [{
select: ".navbar",
title: "Welcome to Hackathon Planner!",
content: "These tips are designed to help you get up and running in seconds and then they'll get out of the way. Click or tap on a tooltip to move forward.",
placement: "bottom"
}, {
select: "button",
import {Aurelia} from 'aurelia-framework';
import {inject} from 'aurelia-framework';
import {HttpClient} from 'aurelia-http-client';
@inject(Aurelia, HttpClient)
export class AuthService {
// As soon as the AuthService is created, we query local storage to
// see if the login information has been stored. If so, we immediately
// load it into the session object on the AuthService.
constructor(Aurelia, HttpClient) {
@hakant
hakant / pseudo-buzz-node.js
Last active September 6, 2016 18:54
pseudo node.js code that reads inputs from playstation buzz controllers
var HID = require('node-hid');
var bitwise = require('bitwise');
var socket = require('socket.io-client')('https://frill-crafter.hyperdev.space');
device.on("data", function(data) {
// Interpret data buffer and figure out which buttons on which controllers are being pressed
// ... Visit https://github.com/hakant/NfieldQuizGame to see the actual code
// Then emit the following message to the socket.io server running on hyperdev (for each controller)
socket.emit('button-clicked', `{ "ControllerId": ${controllerId}, "ButtonId": ${buttonId} }`);