Skip to content

Instantly share code, notes, and snippets.

@yonatanmn
yonatanmn / Striped-background-for-Sass-(scss-mixin).markdown
Last active January 25, 2017 06:35
Striped background for Sass (scss mixin)

Striped background for Sass (scss mixin)

choose color, intensity (number of stripes) and direction

A Pen by yonatanmn on CodePen.

License.

@yonatanmn
yonatanmn / Arguments Checker (api)
Last active August 29, 2015 14:22
data types and argument checker for functions, pass a string or a function to see if your arguments pass, otherwise it will throw an error. This makes javascript functions to accept static types rather than dynamic, and reduces run-time bugs
/* ***** API ***** */
/*
1.
Function.prototype.check({Checker}|[{Checker}],{*})
someFunc.check(someChecker,someData);
{checker} can be of type:
string - to check primitive data types:
@yonatanmn
yonatanmn / css sprite with sass (scss)
Last active July 17, 2017 15:14
css sprite with sass (scss)
//usage is pretty simple:
//1. create a sprite of square images (if the icon is not square, save it inside a square anyway):
// example: http://glue.readthedocs.org/en/latest/_images/famfamfam2.png
//2. define sass map with the keys specified:
$mySprite:(
url: '../images/mySprite.png',
names: ('createIcon','player','bell','notifications','icon13','icon15'...), //names of all of the icons in sprite
itemsInRow: 10, //sprite structure
@yonatanmn
yonatanmn / Sprites Mixin For Sass (scss).markdown
Created July 6, 2015 17:58
Sprites Mixin For Sass (scss)

Sprites Mixin For Sass (scss)

Really conveninet mixin for using css sprites, no need to start messing with background position.

A Pen by yonatanmn on CodePen.

License.

@yonatanmn
yonatanmn / sequence.js
Last active April 6, 2016 12:07
SEQUENCE function that will call PROMISE handlers when the promises RESOLVES in the sequence they were ordered ASAP.
var randP = (name)=>{
return new Promise((rs,rj) => {
let randTime = (Math.floor(Math.random() * 6) + 1) * 500; //500 to 3000
setTimeout(rs, randTime, name + ' ' + randTime);
});
};
var log = function(x){console.log(x)};
function thenLog(p){return p.then(log);}
var a = randP('1'); var b = randP('2'); var c = randP('3');
@yonatanmn
yonatanmn / coolEmitter.js
Last active August 23, 2016 13:05
event emitter without 'on' and 'emit'
'use strict';
function emitize(obj, eventName) {
var _subscriptions = new Set();
Object.defineProperty(obj, eventName, {
set(func) { _subscriptions.add(func); },
get() {
var emit = (...args)=>{
_subscriptions.forEach(f=>f(...args));
};
@yonatanmn
yonatanmn / Trie.js
Created April 18, 2016 16:20
Trie for autocomplete in JS
function wordToLtrsArr(w){return w.split('')}
function tail(arr){return arr.slice(1)}
function goTo(o,wp){
if(!wp.length){return o}
var firstLetter = wp[0];
var point = o[firstLetter];
@yonatanmn
yonatanmn / numbersSquareV1.js
Last active June 29, 2016 13:01
create square of numbers - look at result file
function addBeforeAfter(arr, item){
return [item].concat(arr).concat([item])
}
function createLine(counter, min){
const minNum = Math.max(counter, min);
return counter > 1 ? addBeforeAfter(createLine(counter - 1, min), minNum) : [minNum]
}
@yonatanmn
yonatanmn / 10-coins.js
Last active July 3, 2016 16:00
create combination of exactly 10 coins to achieve requested amount (available coins: 1,2,5,10)
"use strict";
function calc(s10, s5, s2, s1){
return s10*10 + s5*5 + s2*2 + s1
}
const resDict = {};
function prepareResults() {
for(let s10=0;s10<=10;s10++){
for(let s5=0;s5<=10;s5++){
for(let s2=0;s2<=10;s2++){
@yonatanmn
yonatanmn / index.html
Last active May 5, 2018 23:31
click-delete table, vanila js, gradient bg, https://codepen.io/anon/pen/yjoXyY
<div id="container">
</div>