Skip to content

Instantly share code, notes, and snippets.

View blackmiaool's full-sized avatar
🏠
Working from home

blackmiaool blackmiaool

🏠
Working from home
View GitHub Profile
@blackmiaool
blackmiaool / index.js
Last active December 4, 2017 07:35
preventBodyScrolling
$.fn.snapshot = function (property) {
const snapshot = this.attr(property);
return () => {
this.attr(property, snapshot);
};
};
export function preventBodyScrolling($wrap) {
const $body = $("body");
const cbArr = [];
@blackmiaool
blackmiaool / index.js
Created August 27, 2017 06:18
react children traverser
function traverse(node, hierarchy) {
const className = node.props && node.props.style;//array
if (className) {
className.forEach((name, i) => {
if (typeof name === 'string') {
const styleObject = {};
if (style[name]) {
style[name].forEach((obj) => {
Object.assign(styleObject, obj.style);
});
@blackmiaool
blackmiaool / index.js
Last active September 19, 2017 13:02
hyper plugin
'use strict';
const hashbow = require('hashbow');
exports.getTabProps = function (uid, parentProps, props) {
const ret = {};
Object.assign(ret, props, {
dabColor: hashbow(props.text)
});
ret.text = ret.text.replace(/blackmiaool@blackmiaool-OptiPlex-9020:/, "")
@blackmiaool
blackmiaool / index.js
Last active September 15, 2017 06:33
selector for vue
class VueTag {
constructor(data) {
Object.assign(this, data);
this.originalData = data;
}
setContent(content) {
this.originalData.content = content;
this.content = content;
}
text(content) {
@blackmiaool
blackmiaool / readme.md
Last active August 21, 2017 02:12
UESTC群员统计

GitHub Entry

Page Entry

How to add your info?

Comment your info to this gist as JSON, and the page would load the newest data automatically.

@blackmiaool
blackmiaool / index.es6
Last active July 19, 2017 09:57
toggle class
function toggleClass(allClass,className){
let got=false;
allClass=allClass.replace(new RegExp(`(\\s|^)(${className})(\\s|$)`),function(full,pre,target,after){
got=true;
//center
if(pre&&after){
return " ";
}else{
return ""
}
@blackmiaool
blackmiaool / index.jsx
Last active July 7, 2017 09:53
sync react native component height
usage:
static propTypes = {
SyncHeight: PropTypes.any,
}
static defaultProps = {
SyncHeight: View
}
render(){
return (<SyncHeight name="product" style={styles.productImage}>
<Touchable type="opacity" onPress={this.handlePress} activeOpacity={0.8}>
@blackmiaool
blackmiaool / index.js
Created July 4, 2017 08:50
get param
function getParam(url, name, defaultValue) {
const reg = new RegExp(`[?&]${name}=([\\s\\S]+?)(&|$)`);
const match = url.match(reg);
if (match) {
return match[1].trim();
} else {
return defaultValue;
}
}
@blackmiaool
blackmiaool / extension.js
Last active July 1, 2017 07:01
Fix vscode-eslint
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
const path = require("path");
const fs = require("fs");
@blackmiaool
blackmiaool / client.js
Last active June 24, 2017 08:06
black.socket
class Socket {
init(ws) {
this.ws = ws;
if (this.isClient) {
ws.addEventListener('open', () => {
});
}
ws.addEventListener("message", (message) => {
if (!message.data || message.data.match(/^\d+$/)) {