Skip to content

Instantly share code, notes, and snippets.

View AaronFlower's full-sized avatar
💭
I may be slow to respond.

AaronFlower

💭
I may be slow to respond.
View GitHub Profile
@AaronFlower
AaronFlower / webpack-config-optimize.js
Created December 11, 2017 15:05
webpack-config-optimize
const path = require('path')
const webpack = require('webpack')
const htmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: {
app: './src/main.js',
moduleA: './src/moduleA.js',
moduleB: './src/moduleB.js',
moduleC: './src/moduleC.js'
@AaronFlower
AaronFlower / createResource.js
Last active December 15, 2017 15:37
axios create restful resource api
/**
* create Restful API Resource with axios
*/
function createResource (http, path, actions) {
let resource = {
get: id => http.get(`${path}/${id}`),
save: data => http.post(path, data),
query: params => http.get(path, {params}),
update: data => http.put(path, data),
delete: id => http.delete(path, {id})
@AaronFlower
AaronFlower / location-search.js
Created December 19, 2017 08:38
window location search params
var queryItems = {}
window.location.search.replace(/[?&]([^=]+)=([^=&]+)/g, function (_, key, value) {
queryItems[key] = value
})
console.log(queryItems)
@AaronFlower
AaronFlower / left-right-arr.js
Created December 22, 2017 17:48
left-mid-right array
/* [left], mid [right] */
function leftMidRight () {
this.currentDim = this.dimsMap.get(val)
this.leftArr = []
this.rightArr = []
for (let i = val - 1; i >= val - this.halfSize; --i) {
if (i >= 0) {
this.leftArr.unshift(i)
} else {
@AaronFlower
AaronFlower / GitHub-Forking.md
Created December 25, 2017 09:42 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@AaronFlower
AaronFlower / load-style-file
Created January 12, 2018 01:16
javascript load css file
let link = document.createElement('link')
link.href = '/css/filename.css'
link.type = 'text/css'
link.rel = 'stylesheet'
link.media = 'screen,print'
document.getElementsByTagName( "head" )[0].appendChild( link )
@AaronFlower
AaronFlower / observable.js
Last active February 1, 2018 07:08
A observable function use Proxy and Reflect
function observable (obj, onchange) {
return new Proxy(obj, {
set (target, key, value) {
Reflect.set(target, key, value)
onchange(key, value)
},
delete (target, key, value) {
Reflect.delete(key)
onchange(key, undefined)
@AaronFlower
AaronFlower / customEvent.js
Created February 1, 2018 11:05
fix window.CustomEvent
/**
* CustomEvent polyfill
* https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
*/
(function () {
try {
// a : While a window.CustomEvent object exists, it cannot be called as a constructor.
// b : There is no window.CustomEvent object
new window.CustomEvent('T');
} catch (e) {
@AaronFlower
AaronFlower / CMakeLists.txt
Created February 24, 2018 13:28
CMakeLists.txt Simple Demo
# VERSION CMake 最低版本需求
cmake_minimum_required (VERSION 3.10)
# 项目信息
project (Demo01)
# 指定生成目标
add_executable(power main.c)
<?php
class Singleton
{
protected static $instance = null;
protected function __construct()
{
# Thou shalt not construct that which is unconstructable!
}
protected function __clone()
{