Skip to content

Instantly share code, notes, and snippets.

View faimin's full-sized avatar
👻
learning

Zero.D.Saber faimin

👻
learning
View GitHub Profile
@faimin
faimin / alacrittty.toml
Created January 1, 2024 13:42
alacrittty.toml
# config path: '~/.config/alacritty/alacritty.toml'
live_config_reload = true
[colors]
draw_bold_text_with_bright_colors = true
[colors.bright]
black = "#625e4c"
blue = "#9d65ff"
@faimin
faimin / wezterm.lua
Created January 1, 2024 13:38
wezterm.lua
-- config path: '~/.config/wezterm/wezterm.lua'
local wezterm = require('wezterm')
local config = {
color_scheme = 'Shades of Purple (base16)',
font_size = 18,
font = wezterm.font_with_fallback({
{ family = 'FiraCode Nerd Font', weight = 'Medium' },
{ family = 'PingFang', weight = 'Regular' },
@faimin
faimin / blockHook.m
Last active February 22, 2021 12:31 — forked from Skifary/main.m
修改block的实现,先打印参数,再输出原有实现
#import <Foundation/Foundation.h>
#import "ffi.h"
NSMutableArray *g_allocations;
ffi_cif g_cif;
ffi_closure *g_closure;
void *g_replacement_invoke;
void *g_origin_invoke;
@faimin
faimin / zd_defer
Last active July 19, 2018 03:51
出作用域时执行block,类似于swift中的defer和EXTScope中的onExit
//MARK:- 超出作用域后执行
//defer(swift延迟调用关键字)宏 (http://blog.sunnyxx.com/2014/09/15/objc-attribute-cleanup/ )
/// 出了作用域时执行block,类似于swift中的defer和EXTScope中的onExit
///
/// Example:
/// zd_defer {
/// /// 所谓作用域结束,包括大括号结束、return、goto、break、exception等各种情况
/// NSLog(@"当前作用域结束,马上要出作用域了");
/// };
///
@faimin
faimin / UIViewController.m
Created July 21, 2017 06:28 — forked from emarashliev/UIViewController.m
Custom animation for modal dismiss
- (void)dismiss
{
[CATransaction begin];
CATransition *transition = [CATransition animation];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromTop;
transition.duration = 0.25f;
transition.fillMode = kCAFillModeForwards;
transition.removedOnCompletion = YES;
@faimin
faimin / UIButton+ZDUtility
Created June 22, 2017 02:26
permutation image and title postion for button
typedef NS_ENUM(NSUInteger, ZDImagePosition) {
ZDImagePosition_Left = 0,
ZDImagePosition_Right,
ZDImagePosition_Top,
ZDImagePosition_Bottom
};
@implementation UIButton (ZDUtility)
- (void)zd_imagePosition:(ZDImagePosition)postion spacing:(CGFloat)spacing {
@faimin
faimin / NSTimer+ZDUtility
Last active May 17, 2017 10:33
resolve loop references in NSTimer
@interface NSTimer (ZDUtility)
+ (NSTimer *)zd_scheduledTimerWithTimeInterval:(NSTimeInterval)seconds
block:(void (^)(NSTimer *timer))block
repeats:(BOOL)repeats;
+ (NSTimer *)zd_timerWithTimeInterval:(NSTimeInterval)seconds
block:(void (^)(NSTimer *timer))block
repeats:(BOOL)repeats;
@implementation NSObject (ZDWeakAssociate)
- (void)zd_setWeakAssociateValue:(id)value forKey:(void *)key {
__weak id weakValue = value;
objc_setAssociatedObject(self, key, ^{
return weakValue;
}, OBJC_ASSOCIATION_COPY);
}
- (id)zd_getWeakAssociateValueForKey:(void *)key {
@faimin
faimin / UIView+ZDTouchExtendInsets
Created May 16, 2017 03:05
extend view's touch area
static const void *TouchExtendInsetKey = &TouchExtendInsetKey;
static 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);
@faimin
faimin / UIView+ZDShake
Created May 16, 2017 02:58
a UIView category for shaking
- (void)zd_shake:(CGFloat)range {
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.y"];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
animation.duration = 0.5;
animation.values = @[@(-range), @(range), @(-range/2), @(range/2), @(-range/5), @(range/5), @(0)];
animation.repeatCount = CGFLOAT_MAX;
[self.layer addAnimation:animation forKey:@"shake"];
}