Skip to content

Instantly share code, notes, and snippets.

View stelcheck's full-sized avatar

Marc Trudel stelcheck

View GitHub Profile
@stelcheck
stelcheck / render.js
Last active May 8, 2018 01:38
Sample code, redux
const framesPerSecond = 30;
const frameTimer = 1000 / framesPerSecond;
const now = () => Date.now();
let timer = null;
function render(previousDelta) {
const start = now();
move(previousDelta);
# 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 September 1, 2017 04:46
MAGE 1.3: Dynamic configuration
// 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 September 1, 2017 04:34
MAGE 1.3: convert "-" to ":"
{
"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 June 15, 2017 06:03
net: EADDRINUSE is an uncatchable error
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 June 14, 2017 04:18
Socket files in Node.js
#!/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'
#!/usr/bin/env bash
function printResult() {
echo ""
echo "=============================="
[[ ${1} == 0 ]] && echo "success" || echo "failed"
echo "=============================="
}
@stelcheck
stelcheck / GameState.ts
Created June 8, 2017 19:56
mage-parser: networked objects (concept)
// 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 June 2, 2017 07:18
require cache behaviour on throw
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 06:45
User commands in mage-validator
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