Skip to content

Instantly share code, notes, and snippets.

View mactive's full-sized avatar
🎯
Focusing

mactive mactive

🎯
Focusing
View GitHub Profile
/**
* 获取品类树 并 做key-value 映射
*/
getCascaderTree: function(){
var self = this;
// 递归 key-value 映射
var recursion = function(children){
if(children && children.length > 0){
return children.map((item)=>{
return {
@mactive
mactive / topview.js
Last active July 11, 2019 02:21
rn-topview
/**
* mactive@gmail.com
* 2017-05-08
*/
'use strict';
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
function Car(name){
// this.name = name;
if(this instanceof Car){
console.log('has been newed');
this.name = name;
}else{
console.log('need newed');
return new Car(name);
}
@mactive
mactive / retail.user.js
Last active January 18, 2017 10:02
零售页面注入脚本
// ==UserScript==
// @name 零售页面注入脚本
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://m.retail.st.sankuai.com/*
// @run-at document-start
// @grant none
// ==/UserScript==
@mactive
mactive / protortpe.js
Created December 26, 2016 06:25
prototype chain
function Animal(age) {
if (age) { this.age = age; }
// 这个name 不会影响 Dog 或者V, 只会影响new Animal的人
this.name= "One Animal"
}
Animal.prototype.age = 1;
Animal.prototype.name= "One Animal"; // 优先级 P3
@mactive
mactive / webpack.config.js
Created November 15, 2016 02:23
webpack config
/**
* React Static Boilerplate
* https://github.com/koistya/react-static-boilerplate
* Copyright (c) Konstantin Tarkus (@koistya) | MIT license
*/
import path from 'path';
import webpack from 'webpack';
import merge from 'lodash.merge';
@mactive
mactive / APerfactDelegate.h
Last active September 21, 2016 00:44
Protocol and Class
//
// APerfactDelegate.h
// ReactiveCocoaPractice
//
// Created by mengqian on 20/9/2016.
// Copyright © 2016 thinktube. All rights reserved.
//
#ifndef APerfactDelegate_h
#define APerfactDelegate_h
-(void)makeMaskWithFrame:(CGRect)frame
{
// Create a mask layer and the frame to determine what will be visible in the view.
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
// CGContextFillEllipseInRect();
CGRect maskRect = CGRectMake(0, 0, frame.size.width, frame.size.height);
// Create a path with the rectangle in it.
CGPathRef path = CGPathCreateWithEllipseInRect(maskRect, NULL);
@mactive
mactive / RCTPerformanceLogger.h
Created July 24, 2016 04:15
RN如何统计JS下载,加载,已经原生组件mapping所需要的时间的
//开始
RCTPerformanceLoggerStart(RCTPLNativeModuleInit);
// 结束
RCTPerformanceLoggerEnd(RCTPLNativeModuleInit);
// 手动设置
RCTPerformanceLoggerSet(RCTPLNativeModuleMainThreadUsesCount, modulesOnMainThreadCount);
typedef NS_ENUM(NSUInteger, RCTPLTag) {
RCTPLScriptDownload = 0,
@mactive
mactive / RCTBatchedBridge.m
Last active July 24, 2016 07:41
ReactNative 异步+同步加载js 并执行
dispatch_queue_t bridgeQueue = dispatch_queue_create("com.facebook.react.RCTBridgeQueue", DISPATCH_QUEUE_CONCURRENT);
dispatch_group_t initModulesAndLoadSource = dispatch_group_create();
// Asynchronously load source code
dispatch_group_enter(initModulesAndLoadSource);
__weak RCTBatchedBridge *weakSelf = self;
__block NSData *sourceCode;
[self loadSource:^(NSError *error, NSData *source) {
if (error) {