Skip to content

Instantly share code, notes, and snippets.

View orenmizr's full-sized avatar
🎯
Focusing

Oren Mizrahi orenmizr

🎯
Focusing
View GitHub Profile
@orenmizr
orenmizr / config-ff.md
Last active February 19, 2024 10:50
psudu

getConfig

import { useState, useRef, useEffect, useCallback } from 'react';
interface CountdownOptions {
onComplete: () => void;
onTick?: () => void;
interval: number | null;
}
export function useCountdown(endTime: number, options: CountdownOptions) {
const [count, setCount] = useState<number | null>(null);
const intervalIdRef = useRef<number | null>(null);
@orenmizr
orenmizr / useStateCallback
Created April 30, 2021 18:56
useStateCallback.js
import { useState, useEffect, useRef, useCallback } from 'react';
export default (initialState) => {
const [state, setState] = useState(initialState);
const cbRef = useRef(null);
const setStateCallback = useCallback((state, cb) => {
cbRef.current = cb;
setState(state);
}, []);
@orenmizr
orenmizr / packages.json
Created August 1, 2020 20:09
initial state
{
packageName: 'babel-eslint',
versionNumber: '^6.26.3',
dependencies: [
{
packageName: 'babel-core',
versionNumber: '^8.2.6',
dependencies: [
{
packageName: 'babel-bla',
@orenmizr
orenmizr / closureOptions.txt
Created July 23, 2017 20:26
closure options
Basic Usage:
--compilation_level (-O) VAL : Specifies the compilation level to
use. Options: WHITESPACE_ONLY,
SIMPLE, ADVANCED (default: SIMPLE)
--env [BROWSER | CUSTOM] : Determines the set of builtin externs
to load. Options: BROWSER, CUSTOM.
Defaults to BROWSER. (default:
BROWSER)
--externs VAL : The file containing JavaScript
externs. You may specify multiple
@orenmizr
orenmizr / starter.js
Last active March 12, 2017 06:46
package starter
{
"name": "primer",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"ampersand-app": "^2.0.0",
"ampersand-model": "^8.0.0",
"ampersand-state": "^5.0.2",
"ampersand-view": "^10.0.1",
@orenmizr
orenmizr / api.js
Created January 7, 2017 02:36
retrieveValue
'use strict';
var CONSTS = require("./components/consts");
var _ = require("./components/utils");
var method = "GET";
var baseUrl;
var initialize = function(){
baseUrl = buildEntrypoint(CONSTS.API.version,CONSTS.API.publisher.id);
};
@orenmizr
orenmizr / utils.js
Created January 7, 2017 01:27
extend
// merge two objects to one merged object;
var extend = function(defaults, options) {
var extended = {};
copyObj(extended, defaults);
copyObj(extended, options);
// var prop;
// for (prop in defaults) {
// if (Object.prototype.hasOwnProperty.call(defaults, prop)) {
// extended[prop] = defaults[prop];
// }
function buildQueryStrings(){
var queries = [];
var keys = Array.prototype.slice.call(arguments);
var val;
keys.forEach(function(key){
val = retreiveValue(key, config);
queries.push(key + "=" + val);
});
// queries.push(key + "=" + (config[key] ? config[key] : config[subkeys[0]][subkeys[1]])) ;
return "?" + queries.join("&");
@orenmizr
orenmizr / QA.js
Created December 12, 2016 13:02
vowelCounter
function getCount(str) {
var vowelsCount = 0;
strArr = str.split('');
strArr.forEach(vowelCounter);
return vowelsCount;
// helper
function vowelCounter(letter) {
var vowels = ['a','e','i','o','u'];