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 url_param(url) { | |
var _url = url || window.location.href; | |
var array = _url.match(/\w+=\w+/g); | |
var result = {}; | |
var tmp = []; | |
for (var i = 0; i < array.length; i++) { | |
tmp = array[i].split("="); | |
result[tmp[0]] = tmp[1]; | |
} |
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
/** | |
* - check symlink in depencency and devDepency | |
* - if found, generate rn-cli-config.js | |
* - react-native start with rn-cli-config | |
*/ | |
const packageJson = require('./package.json'); | |
const fs = require('fs'); | |
const exec = require('child_process').execSync; | |
const RN_CLI_CONFIG_NAME = `rn-cli-config-with-links.js`; |
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
//= require vendor/slick.js | |
//= require vendor/photoswipe.js | |
//= require vendor/photoswipe-ui-default.js | |
function SlickZoom(options) { | |
options = options || {}; | |
if (!(options.selector && options.item)) { | |
return console.error('selector and item required'); | |
} |
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 foo(): null; | |
function foo(a: number): string; | |
function foo(a?) { | |
if (typeof a === 'number') { | |
return '123'; | |
} else { | |
return null; | |
} | |
} |
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
/** | |
* | |
* Util function to create type safe state management store with useContext and useReducer. | |
* The mechanism is described by https://kentcdodds.com/blog/how-to-use-react-context-effectively/ | |
* | |
*/ | |
import React, { useReducer, createContext, useContext } from 'react'; | |
export type ContextProviderProps = { children: React.ReactNode }; |
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 notNullOrUndefined<T>(x: T | null | undefined): x is T { | |
return x !== null && x !== undefined; | |
} | |
const arr = [1, 2, null, undefined]; // (number | null | undefined)[] | |
const arrFiltered = arr.filter(notNullOrUndefined); // number[] |
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 sampleArray(arr, num) { | |
if (arr.length <= num) { | |
return arr; | |
} else { | |
const every = Math.floor(arr.length / num); | |
const sampleIndex = Array(num) | |
.fill(0) | |
.map((_, i) => i * every); | |
// keep last element |
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
FROM node:10-alpine | |
# Installs Python 3 | |
RUN apk add --no-cache python3 && \ | |
python3 -m ensurepip && \ | |
rm -r /usr/lib/python*/ensurepip && \ | |
pip3 install --upgrade pip setuptools && \ | |
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \ | |
if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \ | |
rm -r /root/.cache |
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 express = require('express'); | |
const path = require('path'); | |
const fs = require('fs'); | |
const proxy = require('http-proxy-middleware'); | |
const app = express(); | |
const proxyConfig = require('./proxy-remote.conf.json'); | |
const port = 4200; | |
const ngBuildPath = path.join(__dirname, 'dist/projectAbc'); | |
const ngBuildIndex = fs |
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 express = require('express'); | |
const path = require('path'); | |
const fs = require('fs'); | |
const proxy = require('http-proxy-middleware'); | |
const app = express(); | |
const proxyConfig = require('./proxy-remote.conf.json'); | |
const port = 4200; | |
const ngBuildPath = path.join(__dirname, 'dist/projectAbc'); | |
const ngBuildIndex = fs |
NewerOlder