Instantly share code, notes, and snippets.

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
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');
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"
}
}
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)
}
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 "=============================="
}
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'
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)
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