Skip to content

Instantly share code, notes, and snippets.

Avatar

Marc Trudel stelcheck

View GitHub Profile
@stelcheck
stelcheck / render.js
Last active May 8, 2018
Sample code, redux
View render.js
const framesPerSecond = 30;
const frameTimer = 1000 / framesPerSecond;
const now = () => Date.now();
let timer = null;
function render(previousDelta) {
const start = now();
move(previousDelta);
View mattermost.rb
# rubocop:disable Style/CaseEquality
# rubocop:disable Style/MultilineTernaryOperator
# rubocop:disable Style/NestedTernaryOperator
module Fastlane
module Actions
class MattermostAction < Action
def self.is_supported?(platform)
true
end
@stelcheck
stelcheck / test-index.js
Created Sep 1, 2017
MAGE 1.3: Dynamic configuration
View test-index.js
// Pre-load your MAGE app's configuration
const config = require('mage/lib/config');
// Disable MMRP and service discovery during tests
config.set('server.serviceDiscovery', false)
config.set('server.mmrp', false)
// Load your MAGE app
const game = require('../lib');
@stelcheck
stelcheck / package.json
Created Sep 1, 2017
MAGE 1.3: convert "-" to ":"
View package.json
{
"scripts": {
"show:config": "echo 'Show the compiled MAGE configuration' && mage show:config",
"archivist:create": "echo 'Create archivist vaults' && mage archivist:create",
"archivist:migrate": "echo 'Migrate archivist vaults' && mage archivist:migrate",
"archivist:drop": "echo 'Drop the archivist vaults' && mage archivist:drop"
}
}
@stelcheck
stelcheck / index.js
Last active Jun 15, 2017
net: EADDRINUSE is an uncatchable error
View index.js
const net = require('net')
try {
net.createServer((args) => console.log(...args)).listen('hello', (error) => console.error('listen error', error))
} catch (error) {
console.error('Uncaught listen error', error)
}
@stelcheck
stelcheck / test-listen.sh
Last active Jun 14, 2017
Socket files in Node.js
View test-listen.sh
#!/usr/bin/env bash
function printResult() {
echo ""
echo "=============================="
[[ ${1} == 0 ]] && echo "success" || echo "failed"
echo "=============================="
}
# With this path, the file will be truncated to 'file.s'
View test-listen.sh
#!/usr/bin/env bash
function printResult() {
echo ""
echo "=============================="
[[ ${1} == 0 ]] && echo "success" || echo "failed"
echo "=============================="
}
@stelcheck
stelcheck / GameState.ts
Created Jun 8, 2017
mage-parser: networked objects (concept)
View GameState.ts
// module:
// createGame: create a game instance
// findGames: find all game instances across all game servers
// user commands:
// join: adds actor id to list, returns global game state
// quit: removes actor id
// makeMove: send data
import * as mage from 'mage'
import { networked, rpc, stream } from 'mage-parser'
@stelcheck
stelcheck / app.js
Created Jun 2, 2017
require cache behaviour on throw
View app.js
try {
require('./bad-require')
} catch (error) {
console.error('first error:', error.message)
}
try {
require('./bad-require')
} catch (error) {
console.error('second error:', error.message)
@stelcheck
stelcheck / usercommands-hello.ts
Created May 26, 2017
User commands in mage-validator
View usercommands-hello.ts
import * as mage from 'mage'
import { Acl } from 'mage-validator'
import { IsInt, Max, ValidateNested } from 'class-validator';
import PlayerData from '../types/PlayerData'
export default class {
@IsInt()
@Min(1)
public gemRegisterBonus: number