Skip to content

Instantly share code, notes, and snippets.

Black Lee blacklee

Block or report user

Report or block blacklee

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
@blacklee
blacklee / aqi.lua
Created Apr 9, 2019
Hammerspoon-AQI
View aqi.lua
local url = "https://api.waqi.info/feed/@UID/?token=Demo-Token"
-- fill your UID and token
local menubar = hs.menubar.new()
function getColor(aqi)
if aqi <= 50 then
return {red = 0, blue = 0, green = 1}
end
if aqi <= 100 then
@blacklee
blacklee / SpeechVoiceFromLocaleLanguageCode.m
Created Apr 10, 2018
Get AVSpeechSynthesisVoice by [NSLocale preferredLanguages]
View SpeechVoiceFromLocaleLanguageCode.m
AVSpeechSynthesisVoice *SpeechVoiceFromLocaleLanguageCode(NSString *langCode) {
NSArray<NSString*> *langCodeParts = [[langCode stringByReplacingOccurrencesOfString:@"-" withString:@"_"] componentsSeparatedByString:@"_"];
NSArray<AVSpeechSynthesisVoice*> *availTTSVoices = [AVSpeechSynthesisVoice speechVoices];
NSMutableArray<AVSpeechSynthesisVoice*> *filteredVoices = [NSMutableArray array];
AVSpeechSynthesisVoice *selectedVoice = nil, *defaultVoice = nil;
// first round filter, uses prefix.
for (AVSpeechSynthesisVoice *voice in availTTSVoices) {
if (!defaultVoice && [voice.language isEqualToString:@"en-US"]) {
defaultVoice = voice;
}
@blacklee
blacklee / AppDelegate.m
Created Aug 30, 2016
Using this partial codes to share test data across all simulators in your Mac.
View AppDelegate.m
- (void)setupSharedDirectoryForMacTest {
#ifndef DEBUG
return;
#endif
#ifndef TARGET_IPHONE_SIMULATOR
return;
#endif
NSLog(@"--------------------------------------------------------------------------------------------------------");
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
@blacklee
blacklee / ffmpeg-to-480p.sh
Created Feb 19, 2016
ffmpeg convert video to 480p
View ffmpeg-to-480p.sh
ffmpeg -i input.mp4 -s hd480 -c:v libx264 -crf 23 -c:a aac -strict -2 output.mp4
View convert-p12-to-nopass-pem-for-apns.sh
set -e
set -x
input=$1
output=$2
input_cert=$(echo $input)-cert.p12
input_key=$(echo $input)-key.p12
input_file_not_exists=0
@blacklee
blacklee / gist:11293269
Created Apr 25, 2014
create a "fat" libary
View gist:11293269
lipo -create libdevice.a libsimulator.a -output libcombined.a
@blacklee
blacklee / gist:9045300
Created Feb 17, 2014
performselectoronmainthread and get return value
View gist:9045300
// http://stackoverflow.com/a/3346157/490794
// call
NSMutableDictionary *myDict;
[object performSelectorOnMainThread:@selector(getElements:)
withObject:&myDict waitUntilDone:YES];
// define
- (void)getElements:(NSMutableDictionary **)objects;
@blacklee
blacklee / MobClickOpenUDID+Swizzled.m
Created Jan 21, 2014
使用友盟统计分析提交时被拒的一种解决方案
View MobClickOpenUDID+Swizzled.m
#import "MobClickOpenUDID+Swizzled.h"
#import <objc/message.h>
#import <JRSwizzle.h> // Swizzle 类方法,这样可以避免类去调用某些Apple可能不允许的方法,通过审核
#import "YourDevice.h" // 你的设备相关类,用于生成自己的Device Unique ID
#import <RegExCategories.h> // 正则表达式
#import <NSString+Ruby.h> // 字符串工具类
static NSString * const kOpenUDIDKey = @"OpenUDID";
static NSString * const kOpenUDIDSlotKey = @"OpenUDID_slot";
@blacklee
blacklee / gist:8470154
Created Jan 17, 2014
git tag command
View gist:8470154
create:
git tag tagname
push to master:
git push --tags
list tags:
git tag --list
git tag -l
@blacklee
blacklee / gist:8108962
Last active Jan 1, 2016
when layoutSubviews do not work
View gist:8108962
当 layoutSubviews 里设置了 frame 但是界面不刷新时,检查一下 xib 里面是不是勾上了 use Autolayout ,把这个去掉就好
When you have set frame in layoutSubviews but it do not refresh the view, we should uncheck the [use Autolayout] in xib.
You can’t perform that action at this time.