Skip to content

Instantly share code, notes, and snippets.

View KittenYang's full-sized avatar
🚀
Rush

Qitao Yang KittenYang

🚀
Rush
View GitHub Profile
@KittenYang
KittenYang / SD2ContentView.swift
Created December 5, 2022 04:26 — forked from ynagatomo/SD2ContentView.swift
An iOS app that generates images using Stable-Diffusion-v2 CoreML models.
//
// ContentView.swift
// coremlsd2test
//
// Created by Yasuhito Nagatomo on 2022/12/03.
//
// A sample code using Apple/ml-stable-diffusion library.
// Preparation:
// 1. convert the PyTorch Stable-Diffusion v2 model to coreml models using Apple's tools.
// 2. import the coreml models into the iOS project.
@KittenYang
KittenYang / Sample_test.sol
Created May 16, 2022 18:13
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract EtherWallet {
address payable public owner;
constructor() {
owner = payable(msg.sender);
}
@KittenYang
KittenYang / learn_Ballot.sol
Created May 9, 2022 07:54
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/// @title 委托投票项目
///为每个选项提供简称, 然后作为合约的创造者——即主席,将给予每个独立的地址以投票权。
///地址后面的人可以选择自己投票,或者委托给他们信任的人来投票。
///在投票时间结束时,winningProposal() 将返回获得最多投票的提案。
contract Ballot {
struct Voter {
Verify Github on Galaxy. gid:YFmrbo9B4qaWDaTBSerJUN
@KittenYang
KittenYang / NSObject+ObjectDealloc
Created September 27, 2016 16:37
监控指定对象是否正常释放
#import <objc/runtime.h>
void Swizzle(Class c, SEL orig, SEL new) {
Method origMethod = class_getInstanceMethod(c, orig);
Method newMethod = class_getInstanceMethod(c, new);
if (class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))){
class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
} else {
method_exchangeImplementations(origMethod, newMethod);
}
@KittenYang
KittenYang / UIView+ExtendTouchRect.m
Created April 8, 2016 02:41
一行代码实现点击区域的扩大
void Swizzle(Class c, SEL orig, SEL new) {
Method origMethod = class_getInstanceMethod(c, orig);
Method newMethod = class_getInstanceMethod(c, new);
if (class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))){
class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
} else {
method_exchangeImplementations(origMethod, newMethod);
}
}
@KittenYang
KittenYang / UIGestureRecognizer+Block.m
Last active June 16, 2019 01:46
使用 Block 创建 UIGestureRecognizer
static const int target_key;
@implementation UIGestureRecognizer (Block)
+(instancetype)nvm_gestureRecognizerWithActionBlock:(NVMGestureBlock)block {
return [[self alloc]initWithActionBlock:block];
}
- (instancetype)initWithActionBlock:(NVMGestureBlock)block {
self = [self init];
[self addActionBlock:block];