Skip to content

Instantly share code, notes, and snippets.

View gibbok's full-sized avatar

Simone Poggiali gibbok

View GitHub Profile
@gibbok
gibbok / gibbok-pattern-oloo-pseudo-polymorphism.js
Last active December 6, 2016 07:09
GibboK - Pattern OLOO and pseudo-polymorphism
/*
Behavior delegation examples
OLOO (Objects Linking to Other Objects) pattern idea from Kyle Sypson
Example at: Delegating Widget Objects
https://github.com/getify/You-Dont-Know-JS/blob/master/this%20%26%20object%20prototypes/ch6.md
*/
// good example
var base = {
a : 3,
init: function(b, c) {
@gibbok
gibbok / gibbok-pattern-oloo-serialization-deserialization.js
Last active December 6, 2016 07:09
GibboK - Pattern OLOO applied to object serialization and deserialization
(function (window) {
// example of OLOO pattern applied to object se serialization and deserialization
var dataApi = '{"id":0,"top":10,"left":20,"width":100,"height":150}';
var state = JSON.parse(dataApi);
var base = {
init: function (data) {
var _data = data; // private
// defined on object itself not on its protoype
Object.defineProperty(this, 'id', {
get: function () {
@gibbok
gibbok / gibbok-values-remap-utility.html
Last active January 4, 2017 13:11
GibboK - Values remap utility
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script>
(function () {
/*
Values remap utility.
Use case: Assigning custom values to a range slider.
@gibbok
gibbok / gibbok-fp-compose-fns.js
Created March 14, 2017 07:24
GibboK - FP - Example of function composition in vanilla JavaScript
const compose = (f, ...fs) => x =>
f === undefined ? x : compose(...fs)(f(x))
const add = x => y => x + y
const mult = x => y => x * y
const main = compose(add(3), mult(4), add(5), mult(6))
console.log(main(2))
@gibbok
gibbok / gibbok-snippet-so-dojo.js
Last active June 13, 2017 12:06
GibboK - Snippet - SO -dojo
/*
Stack Overflow Dojo snippet to be included with copy/paste in answers.
*/
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
require([
'dojo/domReady!'
@gibbok
gibbok / app.tsx
Created June 5, 2020 08:21
@actyx/industrial-ui/example
import React from 'react';
import './App.css';
import { TableData } from '@actyx/industrial-ui'
function App() {
type Item = Readonly<{
id: string;
description: string;
value: string;
}>;