Skip to content

Instantly share code, notes, and snippets.

@justinmc
justinmc / gist:9149719
Last active October 15, 2018 18:05
Sample Gulpfile
var gulp = require('gulp');
var clean = require('gulp-clean');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var bases = {
app: 'app/',
@LeCoupa
LeCoupa / nodejs-cheatsheet.js
Last active July 10, 2025 04:46
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@MichalZalecki
MichalZalecki / style.js
Created October 24, 2015 00:01
Script transpiling CSS with cssnext
const cssnext = require("cssnext");
const fs = require("fs");
const watch = require("node-watch");
const program = require("commander");
program
.version("0.0.1")
.option("-s, --source [path]", "Source file")
.option("-d, --destination [path]", "Destination file")
.option("-w, --watch [path]", "Watch directory")
@iksi
iksi / npm-boilerplate-package.json
Last active May 24, 2016 09:46
npm boilerplate package for web projects
{
"name": "<project>",
"private": true,
"scripts": {
"css": "postcss --use postcss-import --use postcss-modular-scale-plus --use postcss-custom-properties --use postcss-custom-media --use css-mqpacker --css-mqpacker.sort --use postcss-calc --use autoprefixer --autoprefixer.browsers 'last 2 versions' --use cssnano --cssnano.safe",
"build:css": "npm run css -- --output assets/css/full.min.css assets/css/src/index.css",
"watch:css": "npm run css -- --watch --output assets/css/full.min.css assets/css/src/index.css",
"js": "uglifyjs --no-mangle --quotes=1",
"build:js": "npm run js -- --compress drop_console=true --output assets/js/full.min.js assets/js/src/lib/*.js assets/js/src/*.js",
"watch:js": "watch 'npm run js -- --compress --output assets/js/full.min.js assets/js/src/lib/*.js assets/js/src/*.js' assets/js/src",
@iuliaL
iuliaL / server.js
Created January 14, 2016 09:30
node http.createServer
// node server instead of xampp ;
var http = require('http');
var fs = require('fs');
http.createServer(function (request, response) {
var filePath = '.' + request.url;
console.log(request.url);
fs.readFile(filePath, function(error, content) {
response.writeHead(200);
@jorangreef
jorangreef / crash.js
Last active January 28, 2016 18:09
Reproduces a crash in Node.js on Windows 7 and Windows 10 when using a recursive fs.watch
var path = require('path');
var fs = require('fs');
// Be careful of adding in console.log statements as these can
// influence the outcome of the script on Windows and cause it to pass.
process.on('uncaughtException', function(error) {
console.log('error: ' + error);
});