Skip to content

Instantly share code, notes, and snippets.

@hulefei
hulefei / installTelnet.sh
Created August 17, 2018 09:07
mac install telnet
mkdir ~/TEMP/Software
cd ~/TEMP/Software
curl https://ftp.gnu.org/gnu/inetutils/inetutils-1.9.4.tar.xz -O
tar -zxvf inetutils-1.9.4.tar.xz
cd inetutils-1.9.4
./configure --prefix=/usr/local --disable-servers --disable-hostname \
--disable-ping --disable-ping6 --disable-logger --disable-talk \
--disable-tftp --disable-whois --disable-ifconfig --disable-traceroute
make -j8
sudo make install
@hulefei
hulefei / Test.cs
Last active September 2, 2018 05:34
unity UI Event dispatch
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using System.Collections.Generic;
public class Test : MonoBehaviour,IPointerClickHandler ,IPointerDownHandler,IPointerUpHandler
{
//监听按下
@hulefei
hulefei / gist:edc6a1efd872120e499ac624d2af5aa7
Created October 20, 2017 08:37
Commit message 的格式
feat:新功能(feature)
fix:修补bug
docs:文档(documentation)
style: 格式(不影响代码运行的变动)
refactor:重构(即不是新增功能,也不是修改bug的代码变动)
test:增加测试
chore:构建过程或辅助工具的变动
============================================================
总共5种提交类型:【新增】【修改】【删除】【优化】【修复】
class MyThreadClass
{
ManualResetEvent _stopEvent;
Thread _thread;
public MyThreadClass()
{
}
public void Start()
@hulefei
hulefei / gist:4a1861ec90a7811cde8711b7a70ef26e
Created September 12, 2017 11:57
the ignore of Git for unity
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*
# Visual Studio 2015 cache directory
/.vs/
using System;
using System.Collections;
using System.Collections.Generic;
public class ObjectPool<T> where T : class {
private readonly Func<T> _objectFactory;
private readonly Queue<T> _queue = new Queue<T>();
/// <summary>
/// 对象池
@hulefei
hulefei / LeftBarButtonItemGesture.m
Created April 15, 2016 09:23
自定义navigationItem.leftBarButtonItem后,系统默认的手势滑动失效解决方案
- (void)viewDidLoad {
[super viewDidLoad];
__weak typeof (self) weakSelf = self;
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.interactivePopGestureRecognizer.delegate = weakSelf;
}
}
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
if (self.viewControllers.count < 3) {
@hulefei
hulefei / ImageScaleToSize.m
Created April 15, 2016 08:37
iOS压缩图片
- (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size{
// 设置成为当前正在使用的context
UIGraphicsBeginImageContext(size);
// 绘制改变大小的图片
[img drawInRect:CGRectMake(0, 0, size.width, size.height)];
// 从当前context中创建一个改变大小后的图片
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
// 使当前的context出堆栈
UIGraphicsEndImageContext();
// 返回新的改变大小后的图片
@hulefei
hulefei / demo.m
Last active April 6, 2016 02:33
IOS Objective-C 版本 MD5加密
import <CommonCrypto/CommonDigest.h> // md5需要引用这个文件
// md5 32位 加密
+ (NSString *) MD5:(NSString *) string {
const charchar *cStr = [string UTF8String];
unsigned char result[16];
CC_MD5(cStr, strlen(cStr), result); // This is the md5 call
//%02x 格式控制: 以十六进制输出,2为指定的输出字段的宽度.如果位数小于2,则左端补0
NSString *output = [NSString stringWithFormat:
@hulefei
hulefei / file.m
Last active April 6, 2016 11:43
uiwebview 获取图片URL
UILongPressGestureRecognizer *gs = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(p_gestureRecognizerAction:)];
gs.numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:gs];
- (void)p_gestureRecognizerAction:(UIGestureRecognizer *)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
CGPoint touchPoint = [gestureRecognizer locationInView:gestureRecognizer.view];
if(self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
NSString *imgURL = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", touchPoint.x, touchPoint.y];
_urlToSave = [self.webview stringByEvaluatingJavaScriptFromString:imgURL];