Skip to content

Instantly share code, notes, and snippets.

Florent Cailhol ooflorent

Block or report user

Report or block ooflorent

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View webgl.js
// ClearBufferMask
export const DEPTH_BUFFER_BIT = 0x00000100
export const STENCIL_BUFFER_BIT = 0x00000400
export const COLOR_BUFFER_BIT = 0x00004000
// BeginMode
export const POINTS = 0x0000
export const LINES = 0x0001
export const LINE_LOOP = 0x0002
export const LINE_STRIP = 0x0003
View build.sh
#!/bin/bash
set -e
# Clean previous build
rm -rf dist
mkdir dist
# Compile the game
$(yarn bin)/rollup -c \
-i src/index.js \
View example.js
let rng = createNumberGenerator(
createSeedFromString("Hello friends!") // 2053374269
);
// Generate a boolean with 30% success
console.log(generateBoolean(rng, 0.3)); // false
console.log(generateBoolean(rng, 0.3)); // true
// Generate a D6
console.log(generateNumber(rng, 1, 6)); // 3
@ooflorent
ooflorent / canvas.js
Last active Jun 23, 2018
Canvas helpers & noise generator
View canvas.js
/**
* @param {number} width
* @param {number} height
* @param {!CanvasPattern} pattern
* @constructor
*/
function Texture(width, height, pattern) {
this.width = width
this.height = height
this.pattern = pattern
View gist:70c4a99b6c8b2be73b5f472da834355d
+ Sliver Queen
+ Elspeth, Knight-Errant
+ Elspeth, Sun's Champion
+ Jace Beleren
+ Jace, the Mind Sculptor
+ Tamiyo, the Moon Sage
+ Jace, Unraveler of Secrets (Teferi, Temporal Archmage)
+ Liliana Vess
+ Ob Nixilis Reignited
View makr_events.js
const eventBus = new EventEmitter()
function someSystem() {
for (const entity of em.query(Timer)) {
const {delay} = entity.get(Timer)
if (delay <= 0) {
// Remove `Timer` component…
entity.remove(Timer)
// …then dispatch an event
eventBus.emit("componentRemoved", {entity})
View configureStore.js
import { applyMiddleware, compose, createStore } from "redux"
import { reduxReactIntl } from "redux-react-intl"
import thunk from "redux-thunk"
import rootReducer from "./reducers"
const createStoreFactory = compose(
applyMiddleware(thunk),
reduxReactRouter({ routes, createHistory })
)
@ooflorent
ooflorent / flux.js
Created Apr 16, 2015
Dummy Flux implementation
View flux.js
export const actions = {
doSomeStuff() {
return fetch('/api/stuff').then(
(res) => (stores.stuffList = res),
(err) => Promise.reject(err)
)
}
}
export const stores = {
@ooflorent
ooflorent / webpack.config.js
Last active Aug 28, 2017
Simplify extension management in webpack
View webpack.config.js
const ext = (...suffix) => new RegExp(`\\.(?:${ suffix.join('|') })(?:[?#].*)?$`)
const loaders = [
// Traditional cases
{ test: ext('css'), loaders: ['style', 'css'] }, // single
{ test: ext('js', 'jsx', 'es6'), loaders: ['babel'] }, // multiple
// Complex case: Font-Awesome adds query strings and/or hashs to files
{ test: ext('otf', 'eot', 'svg', 'ttf', 'woff', 'woff2'), loaders: ['file?name=[name].[ext]'] },
]
View .eslintrc
---
parser: babel-eslint
ecmaFeatures:
modules: true
env:
es6: true
browser: true
node: true
You can’t perform that action at this time.