Skip to content

Instantly share code, notes, and snippets.

import express from 'express'
import { createRest } from 'createrest'
import { createRestExpress } from 'createrest-express'
import { AuthController } from 'controllers'
const app = express()
const routes = createRest(r => {
r.resources('auth', AuthController, { methodNames: { create: 'login' } })
// README and npm module https://www.npmjs.com/package/date-template
/**
*@function
*@name dateTemplate
*@param {string} format - ~Y~ ~M~ ~Dw~ ~D~ ~h~ ~m~ ~s~ ~mm~
*@param {number} oldDate - milliseconds time OR Date object
*@param {function} middleware - Change the date type
*/
const dateTemplate = function( format, oldDate, middleware ){
let date = oldDate ? new Date(oldDate) : new Date();
open Webapi.Dom;
open Webapi.Canvas.Canvas2d;
open Webapi.Canvas.CanvasElement;
[@bs.set] external setWidth: (Dom.element, int) => unit = "width";
[@bs.set] external setHeight: (Dom.element, int) => unit = "height";
type point = (float, float);
type shape('s, 'a) = {
@ryanseddon
ryanseddon / curried.es5.js
Created November 6, 2013 02:46
ES5 vs ES6 function currying
function curried(fn) {
var args = Array.prototype.slice.call(arguments, 1);
return function() {
return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, 0)));
}
}
@kapranov-anton
kapranov-anton / Example.elm
Created September 6, 2019 23:03
Более осмысленный пример Fix
import Html exposing (text)
type NodeF v a
= Empty v
| Elem (List a)
nodeMap : (a -> b) -> NodeF v a -> NodeF v b
nodeMap f node =
case node of
Empty v -> Empty v
@rlefevre
rlefevre / elm-dmy-fr.md
Last active March 23, 2020 13:48
Elm using elm.dmy.fr proxies

Update: As package.elm-lang.org IP address has been changed and is not blocked anymore as far as I know, these proxies have been disabled. If you still need them, add a comment describing why.


Here is how to use the proxies:

Packages documentation

Two options:

1. Browse elm.dmy.fr instead of package.elm-lang.org

@jonathantneal
jonathantneal / README.md
Created September 19, 2012 06:34
Polyfill the EventListener interface in IE8

EventListener Polyfill

Is IE8 your new IE6? Level the playing field with polyfills.

This script polyfills addEventListener, removeEventListener, and dispatchEvent. It is less than half a kilobyte minified and gzipped.

addEventListener

addEventListener registers a single event listener on a single target.

@ahelord
ahelord / sequelize-schema-file-generator.js
Last active September 14, 2021 13:40 — forked from manuelbieh/sequelize-schema-file-generator.js
Automatically generates migration files from your sequelize models
'use strict';
//////////////////////////////////
// How to use?
// 1. Create `sequelize-schema-file-generator.js` in your app root
// 2. Make sure you've ran the `sequelize init` before (It should create `config`,`seeders`,`migrations` folders).
// 3. Update `DATABASE_DSN` below to match your connection string (works with any database adapter that Sequelize supports)
// 4. Run it with `node sequelize-schema-file-generator.js`
// 5. Review the generated migrations inside of the `migrations` folder.
//////////////////////////////////
@jtanguy
jtanguy / dependency-graph-plugin.js
Created June 6, 2018 19:20
Webpack plugin to generate the dependency graph
const path = require('path');
class DependencyGraphPlugin {
apply(compiler) {
compiler.hooks.emit.tap("DependencyGraphPlugin", (compilation) => {
let deps = [];
compilation.modules.forEach(m => {
// console.log(m)
const file = path.relative('', m.resource)
@branneman
branneman / fp-lenses.js
Last active May 17, 2023 00:56
JavaScript: Lenses (Functional Programming)
// FP Lenses
const lens = get => set => ({ get, set });
const view = lens => obj => lens.get(obj);
const set = lens => val => obj => lens.set(val)(obj);
const over = lens => fn => obj => set(lens)(fn(view(lens)(obj)))(obj);
const lensProp = key => lens(prop(key))(assoc(key));