Skip to content

Instantly share code, notes, and snippets.

View ppraksa's full-sized avatar
👋
code in dandy style

Pawel ppraksa

👋
code in dandy style
  • DandyCode
  • Poland
View GitHub Profile
@ppraksa
ppraksa / constans.js
Created July 22, 2019 12:30
simple const implementation
function Constans(arg, value) {
return Object.defineProperty(this, arg, {
value: value,
writable: false
});
}
Constans('test', 2);
test; //2
function makeIterator(arr) {
var index = 0;
return {
next : function() {
return index < arr.length ? {
value: arr[index++],
done: false
} : {
value: arr[index],
done: true
<!DOCTYPE html>
<html lang="5">
<head>
<meta charset="UTF-8">
<title>Pierwszy komponent w React.js</title>
<script src="https://unpkg.com/react/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone/babel.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css">
</head>
<!DOCTYPE html>
<html lang="5">
<head>
<meta charset="UTF-8">
<title>Pierwszy komponent w React.js</title>
<script src="https://unpkg.com/react/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone/babel.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css">
</head>
Array.prototype.map2 = function(fn) {
this.forEach(function(e) {
fn.call(this,e);
});
}
@ppraksa
ppraksa / destruction.js
Created March 31, 2017 12:15
destruction.js
var R = {};
R.component = function() { console.log('hello') };
var A = { component } = R;
@ppraksa
ppraksa / parasite.js
Last active March 31, 2017 10:02
Like a parasite
Object.prototype.parasiteCopy = function(obj, args) {
if(typeof obj.constructor === 'function') {
obj.apply(this, args);
}
}
var Plant = function(colour,roots) {
this.colour = colour;
this.roots = roots
}
@ppraksa
ppraksa / mixin.js
Created March 31, 2017 09:43
Typical mixin in js
Object.prototype.mixin = function(obj) {
if(typeof obj === 'object') {
for(let i in obj) {
String(i) in this ? `${i} - property exist` : this[i] = obj[i];
}
}
}
var Vehicle = { works: true, tank: 100, hasWheels: true }
@ppraksa
ppraksa / distro.js
Created March 24, 2017 15:47
Example of entries - gulp disto
/**
* distro.
* @module distro.
* @version 1.0.0
*
* @author ppraksa
* @copyright (c) 2017 ppraksa.
*/
const distro = {},
@ppraksa
ppraksa / argumentsareint.js
Created March 24, 2017 15:44
Simple test wit cb
function test(...args) {
try {
var cb = args.pop();
(cb.constructor.name === 'Function') ? null : new Error('isnt fn');
let a = args,
tmp = 0,
it = a[Symbol.iterator]();
do {
tmp = it.next();
if(tmp.value != undefined) {