Skip to content

Instantly share code, notes, and snippets.

WanFei WanFeiChen

Block or report user

Report or block WanFeiChen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@WanFeiChen
WanFeiChen / gist:c84a9cea868cfa774cddf4a3423cf64a
Last active Nov 1, 2019
Setting associated userObject to UIView
View gist:c84a9cea868cfa774cddf4a3423cf64a
//
// UIView+SF.swift
// WechatTail
//
// Created by CHENWANFEI on 2019/9/22.
// Copyright © 2019 SwordFish. All rights reserved.
//
import UIKit
@WanFeiChen
WanFeiChen / gist:2ec98991d16e7ce6a63b3207764e618b
Created Aug 17, 2019
How to use NSMetadataQuery in command line
View gist:2ec98991d16e7ce6a63b3207764e618b
let query = NSMetadataQuery();
query.searchScopes = ["/work/books"]
query.predicate = NSPredicate(format: "kMDItemFSName like %@", "NSHipster - Cocoa & Swift.pdf")
NotificationCenter.default.addObserver(forName: NSNotification.Name.NSMetadataQueryDidFinishGathering, object: query, queue: nil) { (_) in
print("count = \(query.resultCount)")
if let items = query.results as? [NSMetadataItem]{
for item in items{
if let path = item.value(forKey: NSMetadataItemPathKey) as? String{
print(path)
}
View UIViewController+SF.swift
//
// UIViewController+SF.swift
// BowenEdu
//
// Created by CHENWANFEI on 2018/8/21.
// Copyright © 2018 swordfish. All rights reserved.
//
import UIKit
extension UIViewController{
@WanFeiChen
WanFeiChen / Test.java
Last active Jul 10, 2018
Apache Tika + Tesseract-OCR to scan Chinese text in pdf
View Test.java
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
@WanFeiChen
WanFeiChen / gist:f5cc44bf663f3722bd19097be47ccf9b
Last active Jul 24, 2019
let Android Activity's transition animation like iOS navigationController's push-pop one
View gist:f5cc44bf663f3722bd19097be47ccf9b
1.Override CommonActivity's startActivity and finish
@Override
public void startActivity(Intent intent) {
super.startActivity(intent);
overridePendingTransition(R.anim.from_right_in, R.anim.from_left_out);
}
@Override
public void finish() {
super.finish();
@WanFeiChen
WanFeiChen / gist:675de27e6ae59fd0bf20c49b87e72ed3
Last active Oct 13, 2017
Use AES/RSA encryption algorithm to make a KeyChain on Android
View gist:675de27e6ae59fd0bf20c49b87e72ed3
package com.swordfishsoft.security;
import android.content.Context;
import android.content.SharedPreferences;
import android.security.KeyPairGeneratorSpec;
import android.security.keystore.KeyProperties;
import android.util.Base64;
import android.util.Log;
import java.io.ByteArrayInputStream;
You can’t perform that action at this time.