Skip to content

Instantly share code, notes, and snippets.

@Hamzali
Hamzali / form.jsx
Last active January 4, 2018 12:20
React JSON Form
import React, { Component } from "react";
import PropTypes from "prop-types";
import styled from "styled-components";
import { INPUT_TYPES } from "../../constants";
import { isEmpty } from "../../utils";
import Input from "./input";
import Button from "./button";
@Hamzali
Hamzali / anonvsref.js
Created March 31, 2018 10:25
Anonymous function vs Object reference Performance
const NS_PER_SEC = 1e9;
const elapsedTimeMs = diff => (((diff[0] * NS_PER_SEC) + diff[1]) / 1e6);
const testCount = 1000;
const calcResults = (t, heapMem) => console.log("Average Elapsed Time:", (total / testCount).toFixed(2), "ms", "\nHeap Used Memory:", (heapMem / 1e6).toFixed(2), "MB");
let mem = process.memoryUsage();
// anon function :(
const obj = {};
@Hamzali
Hamzali / deepCloneObject.js
Last active March 31, 2018 10:53
Object Deep Clone, It might hurt! Beware
// Create a big object in this and test the methods and see the results.
// I could not find a good way to deep clone an object.
const o = {
};
// declarative version with Object assign
// Never use this on big objects!
const deepCloneV1 = o => Object.assign({}, o, Object
.keys(o)
@Hamzali
Hamzali / iterations.js
Created March 31, 2018 11:08
Node Iteration methods
const NS_PER_SEC = 1e9;
const elapsedTimeMs = diff => (((diff[0] * NS_PER_SEC) + diff[1]) / 1e6);
const arr = [];
const arrLen = 10000;
let i = 0;
console.log("Iteration count: " + arrLen);
let startTime = process.hrtime();
while(i < arrLen) {
@Hamzali
Hamzali / safeobj.js
Last active June 8, 2018 13:37
Node - SafeObject
class SafeObject {
constructor(mainObject) {
this.mainObject = mainObject;
this.configs = {
get: SafeObject.get.bind(this)
}
}
static get (target, prop) {
if (prop in target) {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
/**
* Calculates test related statistics for given jira project.
*/
export const testWorkflowStats = async (
projectCode: string
): Promise<TestWorkFlowStatsResult> => {
const project = await readProjectById(projectCode);
const [stories, uiTests] = await Promise.all([
readAllStories(projectCode),
readAllUiTests(projectCode),
/**
* Calculates test related statistics for given jira project.
*/
export const testWorkflowStats = async (
projectCode: string
): Promise<TestWorkFlowStatsResult> => {
const project = await readProjectById(projectCode);
const [stories, uiTests] = await Promise.all([
readAllStories(projectCode),
readAllUiTests(projectCode),
/**
* Calculates test related statistics for given jira project.
*/
export const testWorkflowStats = async (
projectCode: string
): Promise<TestWorkFlowStatsResult> => {
const project = await readProjectById(projectCode);
const [stories, uiTests] = await Promise.all([
readAllStories(projectCode),
readAllUiTests(projectCode),