Skip to content

Instantly share code, notes, and snippets.

@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

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) = {
@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)
@zmts
zmts / aboutNodeJsArchitecture.md
Last active March 9, 2024 20:33
A little bit about Node.js API Architecture

A little bit about Node.js API Architecture (Архитектура/паттерны организации кода Node.js приложений)

node.js

TL;DR

code: https://github.com/zmts/supra-api-nodejs

Предисловие

Одной из болезней Node.js комьюнити это отсутствие каких либо крупных фреймворков, действительно крупных уровня Symphony/Django/RoR/Spring. Что является причиной все ещё достаточно юного возраста данной технологии. И каждый кузнец кует как умеет ну или как в интернетах посоветовали. Собственно это моя попытка выковать некий свой подход к построению Node.js приложений.

@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));
@jayphelps
jayphelps / package.json
Last active March 20, 2024 09:41
TypeScript output es2015, esm (ES Modules), CJS, UMD, UMD + Min + Gzip. Assumes you install typescript (tsc), rollup, uglifyjs either globally or included as devDependencies
{
"scripts": {
"build": "npm run build:es2015 && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min",
"build:es2015": "tsc --module es2015 --target es2015 --outDir dist/es2015",
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm",
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs",
"build:umd": "rollup dist/esm/index.js --format umd --name YourLibrary --sourceMap --output dist/umd/yourlibrary.js",
"build:umd:min": "cd dist/umd && uglifyjs --compress --mangle --source-map --screw-ie8 --comments --o yourlibrary.min.js -- yourlibrary.js && gzip yourlibrary.min.js -c > yourlibrary.min.js.gz",
}
}
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' } })
@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.
//////////////////////////////////
// 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();