Skip to content

Instantly share code, notes, and snippets.

@plugn
plugn / css-custom-radio-button-ui-design.markdown
Created September 13, 2022 22:15
CSS Custom Radio Button UI Design
function template(source, scope = {}) {
return String(source).replace(/\{\{(.+?)\}\}/gm, function(match, p1) {
const param = p1.trim()
return scope[param] || ''
}).replace(/ +/mg, ' ')
}
@plugn
plugn / lodash-node-templateSettings
Last active April 16, 2021 20:32 — forked from niccai/lodash-node-templateSettings
Changing lodash/underscore template settings in Node.js to use Mustache style braces
// Client side, you typically see the template style changed to {{ }} like so...
_.templateSettings = {
interpolate : /\{\{(.+?)\}\}/gim,
evaluate: /\{\#(.+?)\#\}/gim
};
/*
However, in Node.js, this causes issues when trying to render a template.
Likely, you haven't paid too much attention to the fact that you are setting
@plugn
plugn / test-stringify-circular.js
Created October 7, 2020 12:22 — forked from estliberitas/test-stringify-circular.js
JSON.stringify() - debug TypeError: Converting circular structure to JSON
'use strict';
function replacer() {
var objects = [];
return function(key, value) {
if (typeof value === 'object' && value !== null) {
var found = objects.some(function(existing) {
return (existing === value);
});
@plugn
plugn / objectUtils.js
Last active August 3, 2021 22:52
magical comprehensions for JS Object instances
/**
* @title objectUtils.js
* @description magical comprehensions for JS Object instances
* @author Max L Dolgov, plugn@github.com
*
* Here is `var` keyword for ability to re-declare functions,
* it makes tweaking functions in browser console possible.
*
*/
@plugn
plugn / php.func.es6js.js
Last active August 3, 2021 15:11
php.func.es6.js
/**
* php.es6
* @description PHP functions implemented in JavaScript/ES6
* @author Max L Dolgov <bananafishbone@gmail.com>
*/
function count(value) { return value.length }
function chr(num) { return String.fromCharCode(num) }
function ord(str) { return String(str).charCodeAt(0) }
function trim(str) { return String(str).trim() }
function substr(str, start, length) { return String(str).substr(start, length) }
@plugn
plugn / flexbox.html
Created April 3, 2020 00:02 — forked from Munawwar/flexbox.html
HBox and VBox layout with CSS3 flexbox
<!DOCTYPE HTML>
<html>
<head>
<!-- HBox and VBox layouts have been implementated with many libraries/toolkits on
different platforms and languages (like ExtJS,QT,GTK,.NET...).
This tries to achieve the same but with CSS only.
Supported browsers: IE 10+, Safari 6.1, Latest FF, Chrome -->
<style type="text/css">
html, body {
// console.log `this`
{
console: {
log: function log()
},
scriptArgs: [],
print: function print(),
__loadScript: function __loadScript(),
os: {
O_APPEND: 8,
@plugn
plugn / fun.cpp
Created March 23, 2020 23:39 — forked from dant3/fun.cpp
Some fun with C++ 11 - fold, map, reduce, mkString for std::vector<T>
#include <iostream>
#include <sstream>
#include <functional>
#include <vector>
template <typename T, typename U>
U foldLeft(const std::vector<T>& data,
const U& initialValue,
const std::function<U(U,T)>& foldFn) {
typedef typename std::vector<T>::const_iterator Iterator;