Skip to content

Instantly share code, notes, and snippets.

View eugenserbanescu's full-sized avatar

Eugen Serbanescu eugenserbanescu

View GitHub Profile
@eugenserbanescu
eugenserbanescu / gist:097691e58ce0d5978a1cea971896f6e0
Created March 15, 2017 09:29
largest product of 4 numbers horizontally, vertically or diagonally
let colLarge = [
[1,1,1,1,1,4],
[1,1,1,1,1,4],
[1,1,1,1,1,4],
[1,1,1,1,1,4],
[1,1,1,1,1,1],
[1,1,1,1,1,1]
]
let rowLarge = [
function getUndefinedKeys(checkObject, keys) {
return keys.filter(key => {
let splitKey = key.split('.');
let currentObj = checkObject;
let currentIndex = 0;
while(!isKeyUndefined(currentObj, splitKey[currentIndex]) && currentIndex < splitKey.length) {
currentObj = currentObj[splitKey[currentIndex]];
currentIndex++;
}
return currentIndex <= splitKey.length - 1;
function setTimeout(callback, timeout) {
let startTime = Date.now();
function loop(){
if (Date.now() >= startTime + timeout) {
callback();
} else {
loop();
}
}
}
<html>
<form>
<select name="app">
<option value="app1">App 1</option>
<option value="amazingAppMuchWow">App 2</option>
</select>
<input name="serial" placeholder="Serial goes here" type="text" />
<button type="submit">Gimme an url!</button>
<div class="pair">
<input type="text" placeholder="key"/>
@eugenserbanescu
eugenserbanescu / gist:a7d4fe25454a9e6d6e58b9a6180c716b
Last active February 8, 2018 10:11
Draggable panel in react (initial take)
import React, { Component } from "react";
class Panel extends Component {
state = {
width: 200,
dragging: false,
offset: 0
};
dragStart = e => {
this.setState({ dragging: true });
const Row = props => {
const {issueId, issueLink, qaName, number, voteCount} = props;
return (
<tr>
<td>${number}</td>
<td>${voteCount}</td>
<td>${issueId}</td>
<td>${qaName}</td>
<td>
<a href=${issueLink} target="_blank">${issueLink}</a>
const SAMPLE_DATA = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
function divideInto(data, chunkSize) {
// make the container arrays
const containers = [];
for (let i = 0; i < chunkSize; i++) {
containers[i] = [];
}
// push bits of data into each of the arrays;
data.forEach((item, index) => {
// I wated to take a look at way to structure data that we've used on the RCE and other apps
// basically it looks like this:
const flatList = {
byId: {
1: {
id: 1,
someProp: true,
text: 'A sample text',
},
function compare(a,b) {
return a == b;
}
function compareStrict(a,b) {
return a === b;
}
let a = {a:1}
@eugenserbanescu
eugenserbanescu / fibonacci.js
Last active April 3, 2019 17:02
First stab at Fibonacci
const fibonacci = (limit, list=[1, 1]) => {
const currentIndex = list.length - 1
const newNumber = list[currentIndex - 1] + list[currentIndex]
if( newNumber >= limit) {
return list
} else {
return fibonacci(limit, list.concat([newNumber]), currentIndex + 1)
}
}