Skip to content

Instantly share code, notes, and snippets.

View du5rte's full-sized avatar
🏠
Working from home

Duarte Monteiro du5rte

🏠
Working from home
View GitHub Profile
@jrtaylor-com
jrtaylor-com / youtubeDurationToSeconds
Created May 1, 2015 21:57
Parse Youtube v3 API Duration to seconds with Javascript
function youtubeDurationToSeconds(duration) {
var hours = 0;
var minutes = 0;
var seconds = 0;
// Remove PT from string ref: https://developers.google.com/youtube/v3/docs/videos#contentDetails.duration
duration = duration.replace('PT','');
// If the string contains hours parse it and remove it from our duration string
if (duration.indexOf('H') > -1) {
@branneman
branneman / salt-hash-password.js
Last active March 30, 2022 15:56
Node.js: Create salted hashed password
const crypto = require('crypto')
const { promisify } = require('util')
const pbkdf2 = promisify(crypto.pbkdf2)
module.exports = { createHashPasswordFn, isPasswordCorrect }
/**
* @typedef {Object} HashPassword
* @property {String} hash
* @property {String} salt
const Button = forwardRef<CoralButton, ButtonProps>((props, ref) => {
const { children, onClick, title, ...coralButtonProps } = props;
const buttonRef = useRef<CoralButton>(null);
useLayoutEffect(() => {
if (ref) {
if (isFunction(ref)) {
ref(buttonRef.current);
} else {
@svnlto
svnlto / index.js
Created June 4, 2015 07:46
FileReader Promise Helper
const readFile = (file) => {
let reader = new global.FileReader();
return new Promise((resolve, reject) => {
reader.onload = (event) => {
file.data = event.target. result;
resolve(file);
};
reader.onerror = () => {
@MrOrz
MrOrz / README.md
Last active July 22, 2018 15:36
Cross-device BrowserSync with webpack demo
@laem
laem / HoverDecorator.jsx
Last active May 8, 2017 10:45
React Hover Component Decorator
import React, {Component} from 'react'
export default DecoratedComponent =>
class extends Component {
state = {
hover: false,
}
toggleHover = () =>
this.setState({hover: !this.state.hover})
render() {