Skip to content

Instantly share code, notes, and snippets.

Avatar
✍️
Preparing my next talk

Vincent vincentdesmares

✍️
Preparing my next talk
View GitHub Profile
View php-type-hinting.php
<?php
class UserService {
public function createUser(string $name, User $parent = null, $isAdmin) : User
{
$user = new User($name);
...
return $user
}
}
@vincentdesmares
vincentdesmares / sequelize-demo.js
Created Sep 11, 2017
A very simple example of how Sequelize works.
View sequelize-demo.js
const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'username', 'password');
const User = sequelize.define('user', {
username: Sequelize.STRING,
birthday: Sequelize.DATE
});
sequelize.sync()
.then(() => User.create({
@vincentdesmares
vincentdesmares / package-json-scripts-only.json
Created Sep 11, 2017
An example of commands stored in a package.json
View package-json-scripts-only.json
{
"name": "my project name",
"...": "...",
"scripts": {
"release": "standard-version",
"db-reset": "rm -rf data/main.db && sequelize db:migrate && sequelize db:seed:all",
"db-migrate": "sequelize db:migrate",
"dev": "pm2 delete all; pm2 startOrReload ecosystem.config.js && pm2 start react-scripts --name web -- start",
"start": "pm2 startOrReload ecosystem.config.js",
"build": "react-scripts build",
View epilogue-minimal.js
const Sequelize = require('sequelize'),
epilogue = require('epilogue'),
express = require('express'),
bodyParser = require('body-parser');
// Define your models with Sequelize
// This is equivalent to defining Doctrine entities
let database = new Sequelize('database', 'root', 'password');
let User = database.define('User', {
username: Sequelize.STRING
@vincentdesmares
vincentdesmares / app.js
Last active Sep 12, 2017
NODE Express Hello World
View app.js
const express = require('express')
const app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})
View install-flow.sh
yarn add --save-dev flow-bin
node_modules/.bin/flow init
View pm2.sh
yarn add pm2@latest
pm2 start app.js
View nvm-install-node.sh
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
nvm install node
nvm use v6.9.1
View webgl-10.js
function drawScene() {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
requestAnimationFrame(drawScene);
}