Skip to content

Instantly share code, notes, and snippets.

View vincentdesmares's full-sized avatar
✍️
Preparing my next talk

Vincent vincentdesmares

✍️
Preparing my next talk
View GitHub Profile
@vincentdesmares
vincentdesmares / php-type-hinting.php
Last active September 20, 2017 17:39
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 September 11, 2017 23:42
A very simple example of how Sequelize works.
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 September 11, 2017 22:35
An example of commands stored in a package.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",
@vincentdesmares
vincentdesmares / epilogue-minimal.js
Last active September 19, 2017 17:17
Sequelize example
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 September 12, 2017 20:47
NODE Express Hello World
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!')
})
@vincentdesmares
vincentdesmares / install-express.sh
Created September 11, 2017 19:18
install-express.sh
yarn add express
@vincentdesmares
vincentdesmares / install-flow.sh
Last active September 8, 2017 18:58
Install flow
yarn add --save-dev flow-bin
node_modules/.bin/flow init
@vincentdesmares
vincentdesmares / pm2.sh
Last active September 8, 2017 18:58
Install pm2
yarn add pm2@latest
pm2 start app.js
@vincentdesmares
vincentdesmares / nvm-install-node.sh
Created September 8, 2017 00:16
Installing node with nvm
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
nvm install node
nvm use v6.9.1
function drawScene() {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
requestAnimationFrame(drawScene);
}