Skip to content

Instantly share code, notes, and snippets.

@fragno
fragno / agent loop
Created March 10, 2025 05:41 — forked from jlia0/agent loop
Manus tools and prompts
You are Manus, an AI agent created by the Manus team.
You excel at the following tasks:
1. Information gathering, fact-checking, and documentation
2. Data processing, analysis, and visualization
3. Writing multi-chapter articles and in-depth research reports
4. Creating websites, applications, and tools
5. Using programming to solve various problems beyond development
6. Various tasks that can be accomplished using computers and the internet
const pipe = (...funcs) => v => {
return funcs.reduce((res, func) => {
return func(res);
}, v);
};
pipe(add)(5) // 10
// https://medium.com/better-programming/functional-programming-and-the-pipe-function-in-javascript-c92833052057
@fragno
fragno / gist:f97fec18f541f2ed06340d7e56ab1622
Created May 29, 2019 09:44
call child function from parent
For example you can use Refs to Components approach like so:
/* Child.js */
import React from 'react'
import withStyles from 'isomorphic-style-loader/lib/withStyles'
import s from './Child.css'
class Child extends React.Component {
componentDidMount() {
this.props.onRef(this)
@fragno
fragno / hd.js
Created December 24, 2018 07:18
高清方案
'use strict';
/**
* @param {Number} [baseFontSize = 100] - 基础fontSize, 默认100px;
* @param {Number} [fontscale = 1] - 有的业务希望能放大一定比例的字体;
*/
const win = window;
export default win.flex = (baseFontSize, fontscale) => {
const _baseFontSize = baseFontSize || 100;
const _fontscale = fontscale || 1;
@fragno
fragno / gist:575448cc2f7807f4aa4e41b577942dab
Created November 7, 2018 09:02
category weak property
@interface TNWeakWrapper : NSObject
@property (nonatomic, weak) id obj;
@end
@implementation TNWeakWrapper
@end
- (void)setLogModel:(TNViewLogModel *)logModel {
TNWeakWrapper *wrapper = nil;
if (logModel) {
@fragno
fragno / gist:589c4ba40d8d5293489da72b3287688e
Created November 7, 2018 09:02
category weak property
@interface TNWeakWrapper : NSObject
@property (nonatomic, weak) id obj;
@end
@implementation TNWeakWrapper
@end
- (void)setLogModel:(TNViewLogModel *)logModel {
TNWeakWrapper *wrapper = nil;
if (logModel) {
Method original = class_getInstanceMethod(self, @selector(loadSource:onProgress:));
Method replacement = class_getInstanceMethod(self, @selector(loadSourceTinySDK:onProgress:));
if (class_addMethod(self, @selector(loadSource:onProgress:), method_getImplementation(replacement), method_getTypeEncoding(replacement))) {
class_replaceMethod(self, @selector(loadSourceTinySDK:onProgress:), method_getImplementation(original), method_getTypeEncoding(original));
} else {
const char *origType = method_getTypeEncoding(original);
const char *newType = method_getTypeEncoding(replacement);
IMP origIMP = class_replaceMethod(self, @selector(loadSource:onProgress:), method_getImplementation(replacement), newType);
if (origIMP)
+ (void)load {
Method original = class_getClassMethod([self class], @selector(bizPackageModel:));
Method dev = class_getClassMethod([self class], @selector(devBizPackageModel:));
const char *originalType = method_getTypeEncoding(original);
const char *devType = method_getTypeEncoding(dev);
Class metaClass = objc_getMetaClass(class_getName(self));
if (class_addMethod(metaClass, @selector(bizPackageModel:), method_getImplementation(dev), devType)) {
class_replaceMethod(metaClass, @selector(devbizPackageModel:), method_getImplementation(original), originalType);
} else {
@fragno
fragno / gist:2791a00e23edee80bac962769b34ad9b
Last active June 13, 2017 14:27
MAIN_CALL && MAINA_CALL
#define MAIN_CALL(block) \
{ \
if ([NSThread isMainThread]) \
{ \
block(); \
return; \
} \
dispatch_async(dispatch_get_main_queue(), block); \
} \
}
@fragno
fragno / ios_memory_related.c
Last active June 13, 2017 14:28
获取本机可用内存和已用内存