Skip to content

Instantly share code, notes, and snippets.

View WJWang's full-sized avatar

William Wang(Wei) WJWang

View GitHub Profile
import React, { createContext, Component } from 'react';
const ModalContext = createContext({
component: null,
props: {},
showModal: () => {},
hideModal: () => {},
});
class ModalProvider extends Component {
@WJWang
WJWang / multiple_ssh_setting.md
Created April 26, 2018 03:23 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@WJWang
WJWang / SimpleGMapVueComponent.vue
Created April 1, 2018 08:19
A fixed center marker in google map (Vue component)
<template>
<div class="map-wrapper">
<div id="map" v-bind:style="{ width: mapWidth, height: mapHeight }" />
</div>
</template>
<script>
import { marker } from '../../assets/images/';
import { GMAP_KEY } from '../../constant';
export default {
@WJWang
WJWang / GraffitiboardComponent.vue
Created April 1, 2018 08:10
simple graffiti board
<template>
<div class="graffiti-board-wrapper">
<canvas id="graffitiBoard" style="border:#000 1px solid;"></canvas>
<button type="button" name="button" @click="clear">clear</button>
<button type="button" name="button" @click="save">save</button>
</div>
</template>
<script>
export default {
@WJWang
WJWang / python_django_start.md
Last active March 17, 2018 12:13
Python / Django start

Install Python3

  • brew install python3

Install python pacakage manager

  • pip3 install pipenv

create a folder for env and intall django

  • mkdir ${django-project} && cd ${django-project}
  • pipenv --three install django
  • pipenv shell
import fs from 'fs';
import stream from 'stream';
import request from 'request';
import uuid from 'uuid/v1';
import AWS from 'aws-sdk';
// 1. Upload BLOB to S3
export const uploader = ({ blob, name }) => {
AWS.config.update({
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
p
r
i
n
c
e
s
s
@WJWang
WJWang / companies.tsv
Last active December 6, 2017 09:25
Simple Relation tsv files
id name
1 TEST
@WJWang
WJWang / index.html
Created October 31, 2017 02:40
Teamy – a package with CSS animations for a team section
<div class="page">
<div class="page__demo">
<svg width="26" height="28" style="display: none;">
<symbol id="twitter" viewBox="0 0 26 28">
<path d="M25.312 6.375c-0.688 1-1.547 1.891-2.531 2.609 0.016 0.219 0.016 0.438 0.016 0.656 0 6.672-5.078 14.359-14.359 14.359-2.859 0-5.516-0.828-7.75-2.266 0.406 0.047 0.797 0.063 1.219 0.063 2.359 0 4.531-0.797 6.266-2.156-2.219-0.047-4.078-1.5-4.719-3.5 0.313 0.047 0.625 0.078 0.953 0.078 0.453 0 0.906-0.063 1.328-0.172-2.312-0.469-4.047-2.5-4.047-4.953v-0.063c0.672 0.375 1.453 0.609 2.281 0.641-1.359-0.906-2.25-2.453-2.25-4.203 0-0.938 0.25-1.797 0.688-2.547 2.484 3.062 6.219 5.063 10.406 5.281-0.078-0.375-0.125-0.766-0.125-1.156 0-2.781 2.25-5.047 5.047-5.047 1.453 0 2.766 0.609 3.687 1.594 1.141-0.219 2.234-0.641 3.203-1.219-0.375 1.172-1.172 2.156-2.219 2.781 1.016-0.109 2-0.391 2.906-0.781z"></path>
</symbol>
<symbol id="codepen" viewBox="0 0 28 28">
<path d="M3.375 18.266l9.422 6.281v-5.609l-5.219-3.484zM2.406 16.016l3.016-2
const initPage = 1;
const lastPage = 20;
const curPage = 4;
const list = [curPage - 2, curPage - 1, curPage, curPage + 1, curPage + 2];
let result = list.filter(page => page >= initPage).filter(page => page <= lastPage);
if (lastPage > list.length) {
Array.from(new Array(5 - result.length)).forEach((item, idx) => {
if (result[result.length-1] == lastPage) {
result.unshift(result[0]-1)
} else {