Skip to content

Instantly share code, notes, and snippets.

@wuyongrui
wuyongrui / compress_image.sh
Created March 4, 2021 08:29
compress image by pngquant
#! /bin/Bash
pngfile=".png"
jpgfile=".jpg"
ignorefile='__ic' #ignore compress
rootpath='src/assets'
read_dir(){
for file in `ls -a $1`
do
@wuyongrui
wuyongrui / similarity_images.py
Last active March 4, 2021 08:27
find directory similarity images
import pytesseract
from pytesseract import *
from PIL import Image,ImageEnhance,ImageFilter
import os
import fnmatch
import re,time
import urllib, random
import time
# or use imagehash lib
@wuyongrui
wuyongrui / PendingLayout.h
Last active April 9, 2018 09:06
通过layout的方式实现首行首列浮效果
//
// PendingLayout.h
// Brightec
//
// Created by JOSE MARTINEZ on 03/09/2014.
// Copyright (c) 2014 Brightec. All rights reserved.
//
#import <UIKit/UIKit.h>
@wuyongrui
wuyongrui / Swift Generics use - 1
Last active November 13, 2016 14:47
Swift泛型的理解使用1
//
// ViewController.swift
// ObjectMappingDemo
//
// Created by wuyongrui on 2016/11/13.
// Copyright © 2016年 wuyr. All rights reserved.
//
import UIKit
@wuyongrui
wuyongrui / OpenGLView.m
Created April 20, 2016 01:53
OpenGL ES绘制底图+点击添加小图块
//
// OpenGLView.m
#import "OpenGLView.h"
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#import <QuartzCore/QuartzCore.h>
#import "Utils+OpenGL.h"
@wuyongrui
wuyongrui / renderSepiaEffectIntoAsset.swift
Created March 22, 2016 10:02
renderSepiaEffectIntoAsset
// https://osxentwicklerforum.de/index.php/Thread/24626-AVFoundation-CALayer/
-(void)renderSepiaEffectIntoAsset:(AVAsset*)asset withOnCompletion:(void(^)(NSURL* fileURL))aBlock{
CALayer* sepiaLayer = [CALayer layer];
sepiaLayer.frame = CGRectMake(20, 20, 320,480);
CIFilter *myFilter = [CIFilter filterWithName:@"CISepiaTone"];
[myFilter setDefaults];
[myFilter setValue:[NSNumber numberWithFloat:0.8f] forKey:@"inputIntensity"];
@wuyongrui
wuyongrui / server.py
Created March 19, 2016 12:59
the server to build ChatClient.
# run server: $ sudo python server.py. sudo is neccessary
from twisted.internet import reactor
from twisted.internet.protocol import Factory, Protocol
class IphoneChat(Protocol):
def connectionMade(self):
self.factory.clients.append(self)
print "a client connected,clients are:",self.factory.clients
@wuyongrui
wuyongrui / UIView+FrameAdjust.swift
Created March 17, 2016 01:55
UIView+FrameAdjust
//
// UIView+FrameAdjust.swift
//
import Foundation
import UIKit
public extension UIView {
// use left
@wuyongrui
wuyongrui / UIViewController+Extension.swift
Created March 16, 2016 08:10
UIViewController Category to setup tabbarItem
public extension UIViewController {
public func setTabbarItem(title title:String,imageName:String!,selectedImageName:String!) {
self.tabBarItem.title = title
if imageName != nil {
self.tabBarItem.image = UIImage(named:imageName)
}
if selectedImageName != nil {
// self.tabBarItem.selectedImage = UIImage(named:selectedImageName)
@wuyongrui
wuyongrui / AAPLCameraViewController.h
Created March 13, 2016 04:27
Apple AVCam sample project
@import UIKit;
@interface AAPLCameraViewController : UIViewController
@end