title | slug | createdAt | language | preview |
---|---|---|---|---|
React Hook prompting the user to "Add to homescreen" |
react-hook-prompting-the-user-to-add |
2018-11-29T20:35:02Z |
en |
Simple React Hook for showing the user a custom "Add to homescreen" prompt. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.fileContainer { | |
overflow: hidden; | |
position: relative; | |
} | |
.fileContainer [type=file] { | |
cursor: inherit; | |
display: block; | |
font-size: 999px; | |
filter: alpha(opacity=0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extend(base) { | |
var parts = Array.prototype.slice.call(arguments, 1); | |
parts.forEach(function (p) { | |
if (p && typeof (p) === 'object') { | |
for (var k in p) { | |
if (p.hasOwnProperty(k)) { | |
base[k] = p[k]; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* bling.js */ | |
window.$ = document.querySelectorAll.bind(document); | |
Node.prototype.on = window.on = function (name, fn) { | |
this.addEventListener(name, fn); | |
}; | |
NodeList.prototype.__proto__ = Array.prototype; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const toRGB = (() => { | |
const expand = hex => | |
hex.length < 7 ? hex.split("").reduce((a, b) => a + b + b) : hex; | |
const convert = hex => | |
hex.match(/[\d\w]{2}/g).map(val => parseInt(val, 16)); | |
return hex => { | |
const [r, g, b] = convert(expand(hex)); | |
return `rgb(${r}, ${g}, ${b})`; | |
}; | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
##Device = Desktops | |
##Screen = 1281px to higher resolution desktops | |
*/ | |
@media (min-width: 1281px) { | |
/* CSS */ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const shuffle = (arr, mixed = [], pool = arr.slice()) => { | |
const remaining = pool.length; | |
if (!remaining) return mixed; | |
const index = Math.floor(Math.random() * remaining); | |
const el = pool.splice(index, 1).pop(); | |
mixed.push(el); | |
return shuffle(arr, mixed, pool); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { Component } from 'react'; | |
export default function HOCBaseRender<Props, State, ComponentState>( | |
Comp: new() => Component<Props & State, ComponentState>) { | |
return class HOCBase extends Component<Props, State> { | |
render() { | |
return <Comp {...this.props} {...this.state}/>; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Immutable = require('immutable-ext') | |
const {Just, Nothing} = require('data.maybe') | |
const Task = require('data.task') | |
// Setup | |
const Reader = f => | |
({ | |
run: f, | |
map: g => Reader(x => g(f(x))), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const crypto = require('crypto'); | |
const ENC_KEY = "bf3c199c2470cb477d907b1e0917c17b"; // set random encryption key | |
const IV = "5183666c72eec9e4"; // set random initialisation vector | |
// ENC_KEY and IV can be generated as crypto.randomBytes(32).toString('hex'); | |
const phrase = "who let the dogs out"; | |
var encrypt = ((val) => { |
OlderNewer