Skip to content

Instantly share code, notes, and snippets.

View hakant's full-sized avatar

Hakan Tuncer hakant

View GitHub Profile
@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} }`);
/** AdminRepository.ts **/
"use strict";
import * as _ from 'underscore';
import * as nconf from 'nconf';
const businessRules = nconf.get("BusinessRules");
let admins = businessRules.Administrators;
interface IAdminRepository {
IsUserAdmin(username : string) : boolean;
}
"use strict";
import * as _ from 'underscore';
import * as nconf from 'nconf';
const businessRules = nconf.get("BusinessRules");
let admins = businessRules.Administrators;
export default class AdminRepository implements IAdminRepository {
"use strict;"
import * as express from 'express';
export interface RouteConfigurator {
configure(path:string, app: express.Application);
}
"use strict";
import * as express from 'express';
const router = express.Router();
import { RouteConfigurator } from './RouteConfigurator'
class IndexRouteConfigurator implements RouteConfigurator {
public configure(path: string, app: express.Application) {
import { CommandHandler } from "../infrastructure/command-handler"
import container from "../infrastructure/command-handler-container";
class TestHandler implements CommandHandler<TestRequest, TestResponse> {
Handle(request: TestRequest): TestResponse {
var result = new TestResponse();
result.message = `Hello ${request.name}!`;
"use strict";
import { AsyncCommandHandler } from "../application/command-handler"
import container from "../application/command-handler-container";
import * as nconf from 'nconf';
import * as AWS from 'aws-sdk';
import * as Bluebird from 'bluebird';
import * as _ from 'underscore';
router.get('/', catchAsyncErrors(async function (req, res, next) {
var request = new GetIdeasRequest();
request.user = req.user;
var response = await application.ExecuteAsync<GetIdeasRequest, GetIdeasResponse>(request);
res.json(response.ideas);
}));
import executor from "../infrastructure/command-executor";
import {TestRequest, TestResponse} from "../handlers/test-handler";
let request = new TestRequest();
request.name = "Hakan";
let response = executor.Execute<TestRequest, TestResponse>(request);
console.log(response.message); // Prints 'Hello Hakan'