Skip to content

Instantly share code, notes, and snippets.

View perymimon's full-sized avatar

pery mimon perymimon

  • israel
View GitHub Profile

Talkspace Full-stack candidate exercise

Guidelines: The following exercise questions should take 1-2 hours, Put your answers after each question - try to give some short explanation for your

Candidate Name: Pery Date: 12/02/2020

@perymimon
perymimon / example.js
Last active October 28, 2023 21:20
flat Object
inport {flatObject} from './example.js'
const obj = {aaa:{bbb:{c:1,d:7}}, bb:{vv:2}}
console.log(flatObject(obj)}
// aaa.bbb.c: 1
// aaa.bbb.d: 7
// aaa.bbb: {c: 1, d: 7}
// aaa: {bbb: {…}}
// bb.vv: 2
@perymimon
perymimon / Dispenser.js
Created November 6, 2019 08:12
dispenser too bring async data
function Dispenser(filter, sort, requestSize = 25, pageSize) {
let pages = 0;
let rowCount = 0;
let contentsPool = [];
let items = [];
Dispenser.rowCounts = _ => rowCount;
Dispenser.getItem = id => items.find(item => item.dbId == id);
return async function dispenses() {
@perymimon
perymimon / http-server.md
Created April 28, 2019 07:39
collection of usfull commands

diable catch

$ npm run build && http-server -c-1 minus 1

//https://stackoverflow.com/questions/55431060/inherit-like-from-two-or-more-build-in-objects-in-js-map-eventtarget/55443368#
function CreateMix(...classes) {
return function Mixed(){
const instances =[this, ... classes.map(cls => new cls(...arguments))]
const weakbind = (proxy,fn,obj) => new Proxy(fn, {
apply(fn, thisArg, props){
return fn.apply(proxy === thisArg? obj:thisArg ,props);
}})
@perymimon
perymimon / googleApiNodeAuth.js
Last active December 26, 2018 19:54
Auth google/any oauth2 by node cnsole only
const fs = require('fs');
const readline = require('readline');
const {google} = require('googleapis');
// If modifying these scopes, delete token.json.
const SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly'];
// The file token.json stores the user's access and refresh tokens, and is
// created automatically when the authorization flow completes for the first
// time.
const TOKEN_PATH = 'token.json';
@perymimon
perymimon / example.js
Last active March 15, 2019 12:54
tiny code to convert array of objects to headers and rows. For easy print to console. or create to html table
var data = [{a:1, b:2},{c:3,b:2},{d:4,a:1}];
objectsToTableRows(data);
/* return ...
{
headers:(4) ["a", "b", "c", "d"],
rows:Array(3)
0:(2) [1, 2]
1:(3) [undefined × 1, 2, 3]
2:(4) [1, undefined × 2, 4]
@perymimon
perymimon / addToBookma.js
Last active March 15, 2019 12:57
work in Firefox, IE, Opera . not work on IE when protocol is 'javascript'
function addToBookmark(title,href){
if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(title,href,'');
} else if(window.external && ('AddFavorite' in window.external)) { // IE Favorite
window.external.AddFavorite(href, title);
} else if(window.opera && window.print) { // Opera Hotlist
this.title = title;
return true;
} else { // webkit - safari/chrome
alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.');
@perymimon
perymimon / copy.js
Last active March 15, 2019 12:59
copy text to clipbord
function copyText(){
var code = document.querySelector('pre').innerText;
var select = document.querySelector('#clipboard');
select.value = code;
select.select();
try {
document.execCommand('copy');
alert('Text copied to clipboard!');
} catch (err) {
@perymimon
perymimon / loadScript.js
Last active March 15, 2019 13:12
inject script to current document for using in `javascript:` protocol
function loaderScript(scriptUrl){
return new Promise(function (res, rej) {
let script = document.createElement('script');
script.src = scriptUrl;
script.type = 'text/javascript';
script.onError = rej;
script.async = true;
script.onload = res;
script.addEventListener('error',rej);
script.addEventListener('load',res);