Skip to content

Instantly share code, notes, and snippets.

/*
matches a string which contains :
- min 8 chars
- a lowercase letter
- a capital letter
- a number
- a special char
- no chars repeated more than twice
*/
import * as mongoose from 'mongoose';
console.log(mongoose.connect); // undefined
// but
console.log(mongoose);
/*
{ connections:
[ NativeConnection {
base: [Object],
@Lcfvs
Lcfvs / string-inject.js
Created May 3, 2016 14:26
Simple & controlled template string emulation
/**
* @module: string-inject
* @version: 1.0.0
* @author: Lcf.vs
* @copyright: © 2015
* @license: MIT
* @exports: {function} inject(name, str, data)
* @description: Injects some map-based data into a string
* @param: {string} name
* @description: The map name
<?php
$service_port = getservbyname('http', 'tcp');
$address = gethostbyname('chat.dev.com');
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$result = socket_connect($socket, $address, $service_port);
// ...
@Lcfvs
Lcfvs / fiddle.css
Last active May 4, 2017 09:29
anticore demo
span.error {
color: red;
display: block;
}
@Lcfvs
Lcfvs / flat-webpack-banner.json
Created September 25, 2017 12:41
flat-webpack-banner.json
/* {
"name": "localhost",
"version": "1.0.3",
"author": "lcf.vs <[email protected]>",
"license": "MIT",
"dependencies": {
"URL": {
"name": "js-polyfills",
"version": "0.1.34",
"author": "Joshua Bell",
@Lcfvs
Lcfvs / assets\js\dev\exception.md.js
Created January 17, 2019 20:13
Simple server exception manager, for anticore. Try it with https://github.com/Lcfvs/anticore-default-project
// create this file
import { anticore } from 'anticore'
import { one } from 'anticore/dom/query/one'
import { replace } from 'anticore/dom/tree/replace'
anticore.on('main.exception', function (element, next, loaded) {
loaded && replace(element, one('body > main'))
next()
})
@Lcfvs
Lcfvs / spinner.css
Created January 26, 2019 04:47
CSS spinner
.fetching {
pointer-events: none;
}
.fetching::after {
content: '';
border-radius: 100%;
border-top: .2em solid rgba(255, 255, 255, .9);
border-left: .2em double rgba(255, 255, 255, .6);
border-bottom: .2em dotted rgba(255, 255, 255, .3);
@Lcfvs
Lcfvs / full-ajax-navigation.js
Last active January 28, 2019 07:14
Create a complete AJAX navigation in 3 generic lines of code. Demo: https://lcfvs.github.io/anticore-quick-start/
import {anticore} from 'anticore'
import 'anticore/middleware/main/mono'
anticore.defaults().populate()
/**
* Usage:
* function fn([{a, b}, out], c) {
* out.c = c
* out.d = a + b + c
* }
*
* const obj = {a: 1, b: 2}
* io(fn, obj, 3)
* console.log(obj) // obj = {a: 1, b: 2, c: 3, d: 6}