This is a guide to configure React Native to be built for native and web platforms with Typescript, Vite.js and Storybook support for modelling components.
/** | |
* Format a date like YYYY-MM-DD. | |
* | |
* @param {string} template | |
* @param {Date=} [date] | |
* @return {string} | |
* @license MIT | |
*/ | |
function formatDate(template, date) { | |
var specs = 'YYYY:MM:DD:HH:mm:ss'.split(':'); |
#!/bin/sh | |
timezone="Europe/Zurich" | |
# List of valid timezones: wikipedia.org/wiki/List_of_tz_database_time_zones | |
script="${0##*/}" | |
rootdir=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd) | |
logfile="$script.log" | |
log="$rootdir/$logfile" | |
now=$(TZ=":$timezone" date) | |
# Uncomment 'mailto=' (remove #) to enable emailing the log upon completion | |
#mailto="your@email.com" |
Unless you are using Safari on OSX, most browsers will have some kind of free plugin that you can use to export the browser's history. So that's probably the easiest way. The harder way, which seems to be what Safari wants is a bit more hacky but it will also work for other browsers. Turns out that most of them, including Safari, have their history saved in some kind of sqlite database file somewhere in your home directory.
The OSX Finder cheats a little bit and doesn't show us all the files that actually exist on our drive. It tries to protect us from ourselves by hiding some system and application-specific files. You can work around this by either using the terminal (my preferred method) or by using the Cmd+Shft+G in Finder.
Once you locate the file containing the browser's history, copy it to make a backup just in case we screw up.
verify = (idcard) -> | |
factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] | |
mask = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2] | |
idcard[idcard.length - 1] is mask[((x * factor[i] for x, i in idcard[0...idcard.length - 1]).reduce (x, y) -> x + y) % mask.length].toString() | |
const resolved = Promise.resolve(); | |
class Deferred { | |
constructor() { | |
const p = new Promise((resolve, reject) => { | |
this.resolve = resolve; | |
this.reject = reject; | |
}); | |
this.then = p.then.bind(p); |
// usage | |
// debounceHOC('input', { onChange: 300, onMouseOver: 1e3}) | |
import _ from 'lodash'; | |
import React, {PureComponent} from 'react'; | |
import {findDOMNode} from 'react-dom'; | |
function debounceHOC(Comp, events = {}) { | |
class debounceEventsComponent extends PureComponent { | |
constructor(props) { |
// No need to sub class Array if what you need is just an extended | |
// array. Example below illustrates the way to extend Array. | |
function SubArray() { | |
return Object.defineProperties(Array.prototype.slice.call(arguments), SubArrayDescriptor) | |
} | |
SubArray.prototype = Array.prototype | |
var SubArrayDescriptor = | |
{ constructor: { value: SubArray } | |
, last: { value: function last() { |
testImgUrl = '//img.alicdn.com/tps/i4/TB1PVZoOpXXXXcKXXXXSutbFXXX.jpg' | |
rgbToHex = (r, g, b) -> | |
hex = (i) -> | |
h = i.toString 16 | |
h = '0' + h if h.length < 2 | |
h | |
['#', hex(r), hex(g), hex(b)].join('') | |
getOnePixelHex = (context, x, y, w = 1, h = 1) -> |