Skip to content

Instantly share code, notes, and snippets.

Erko Bridee erkobridee

Block or report user

Report or block erkobridee

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@erkobridee
erkobridee / google_chrome_notepad.md
Created Nov 8, 2019
Notepad (paste in Chrome's addressbar)
View google_chrome_notepad.md

past the following string into the google chrome address bar:

data:text/html,<html contenteditable>
@erkobridee
erkobridee / git_repo_backup.sh
Last active Jun 21, 2019
useful way to backup a whole repository from on remote to another remote server on an Unix base system
View git_repo_backup.sh
# define a full backup of a git repository from one remote server to another one
origin="https://remote-source/repository.git";
target="https://remote-target/repository.git";
workDir="temp-directory";
mkdir $workDir
@erkobridee
erkobridee / multiline_regexp_sample.js
Created Apr 30, 2019
example of how to write a multiline RegExp and keep under row max length lint rules
View multiline_regexp_sample.js
const DEVICES_REGEXP = new RegExp([
/Android|webOS/,
/|iPhone|iPad|iPod/,
/|BB10|BlackBerry/,
/|IEMobile|Opera Mini/,
/|Mobile|mobile/
].map(function(r) {return r.source}).join(''), 'i');
// output: /Android|webOS|iPhone|iPad|iPod|BB10|BlackBerry|IEMobile|Opera Mini|Mobile|mobile/i
@erkobridee
erkobridee / isElementVisible.js
Last active May 6, 2019
a way to detect if a given element is on the visible area of the page
View isElementVisible.js
function isElementVisible(el, fullVisible) {
// efp - element from point
function efp(x, y) {
return window.document.elementFromPoint(x, y);
}
function getVWidth() {
return window.innerWidth || window.document.documentElement.clientWidth;
}
@erkobridee
erkobridee / useWait.ts
Created Apr 24, 2019
react hook for safe use setInterval or setTimeout
View useWait.ts
import * as React from 'react';
export type TFunction = (...args: any[]) => any;
/**
* common code to define useTimeout or useInterval hooks
*
* @param waitFunction
* @param cleanWaitFunction
*/
@erkobridee
erkobridee / AudioPlayerHelper.ts
Created Apr 19, 2019
a workaround to be able to play sounds anywhere (coded to be able to play sounds on iOS devices)
View AudioPlayerHelper.ts
// empty sound
const TEST_AUDIO_MP3 = [
'data:audio/mpeg;base64',
',/+MYxAAAAANIAUAAAASEEB/jwOFM/0MM/90b/+RhST//w4NFwOjf',
'///PZu//',
'//9lns5GFDv//l9GlUIEEIAAAgIg8Ir/JGq3/',
'+MYxDsLIj5QMYcoAP0dv9HIjUcH//yYSg+CIbkGP//',
'8w0bLVjUP///3Z0x5QCAv/yLjwtGKTEFNRTMuOTeqqqqqqqqqqqqq/',
'+MYxEkNmdJkUYc4AKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq',
'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq'
View useTimeout.ts
import * as React from 'react';
type TFunction = (...args: any[]) => any;
/**
* safe way to use window.setTimeout using a hook to handle it
*
* @param {TFunction} callback to be executed by the timeout
* @param {number} delay time to the execution
* @param {boolean} autorun flag that says if should start running right after call the hook - default true
View useInterval.ts
import * as React from 'react';
export type TFunction = (...args: any[]) => any;
/**
* safe way to use window.setInterval using a hook to handle it
*
* @param {TFunction} callback to be executed on each interval
* @param {number} delay time between the executions
* @param {boolean} autorun flag that says if should start running right after call the hook - default true
View ClickOutside.tsx
import * as React from 'react';
export interface IClickOutsideProps {
onClick: () => void;
/** element to add the click event listener, default selector is body */
parentTargetQuerySelector?: string;
}
/**
* Function Component to re-use the behavior of click outside
View useRefState.ts
import * as React from 'react';
/**
* extend the React.useState to have the state referente, so it will be possible to use its value
* inside of other callbacks
*
* @param {T} initialValue
*
* @return {[T, React.MutableRefObject<T>, React.Dispatch<React.SetStateAction<T>>]} array
*/
You can’t perform that action at this time.