npm install --save-dev node-sass
- Add script to package.json:
node-sass --watch INPUTFOLDER -o OUTPUTFOLDER
- Run script, enjoy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {promisify} = require('util'); | |
const promisifyModuleFunctions = (inModule) => Object | |
.entries(inModule) | |
.reduce((outModule, [key, property]) => { | |
outModule[key] = (typeof property === 'function') | |
? promisify(property) | |
: property; | |
return outModule; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The normal async programming flow in nodeJS can get hairy, quickly: | |
function readAndParse(filename, callback){ | |
fs.readFile(filename, 'utf8', (err, data) => { | |
if(err){ | |
callback(err, null); | |
return; | |
} | |
myParser.doParsing(data, (err, result) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myObject = ['a', 'b', 'c'].reduce((obj, key) => (obj[key] = key, obj), {}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
const propTypes = { | |
firstName: PropTypes.string, | |
lastName: PropTypes.string, | |
birthDay: PropTypes.number, | |
gender: PropTypes.number, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With SASS | |
create-react-app APPNAME --scripts-version custom-react-scripts | |
# With typescript | |
create-react-app APPNAME --scripts-version=react-scripts-ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Draws a poligon - can draw anything from a triangle to a star. | |
* Source and demo: http://jsfiddle.net/tohan/8vwjn4cx/ | |
*/ | |
function drawShape(ctx, x, y, points, radius1, radius2, alpha0) { | |
//points: number of points (or number of sides for polygons) | |
//radius1: "outer" radius of the star | |
//radius2: "inner" radius of the star (if equal to radius1, a polygon is drawn) | |
//angle0: initial angle (clockwise), by default, stars and polygons are 'pointing' up | |
var i, angle, radius; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Door = function Door(){ | |
}; | |
Door.prototype = { | |
constructor: Door, | |
name: 'Door', | |
hp: 5, | |
char: '+', | |
color: 'yellow', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('lib/php/Twig/Autoloader.php'); | |
Twig_Autoloader::register(); | |
$loader = new Twig_Loader_Filesystem('lib/templates'); | |
$twig = new Twig_Environment($loader); |