Skip to content

Instantly share code, notes, and snippets.

View dymx101's full-sized avatar
🎯
Focusing

Yiming Dong dymx101

🎯
Focusing
View GitHub Profile
@dymx101
dymx101 / gist:9636984
Created March 19, 2014 07:26
change for AFNetworking 1.x muitlple parameters with the same name
else if ([value isKindOfClass:[NSArray class]]) {
NSArray *array = value;
for (id nestedValue in array) {
// [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)];
// NOTICE: the following line is modified by Daniel Dong, the original code is above (commented).
[mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@", key], nestedValue)];
}
}
The Best of Brand X Music
NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) {
NSMutableArray *mutableQueryStringComponents = [NSMutableArray array];
if ([value isKindOfClass:[NSDictionary class]]) {
NSDictionary *dictionary = value;
// Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(caseInsensitiveCompare:)];
for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) {
id nestedValue = [dictionary objectForKey:nestedKey];
if (nestedValue) {
@dymx101
dymx101 / gist:fd26ac336942ed4307b7
Created August 10, 2014 09:02
Customize UITextField Clear Button Style
You'll need to create your own clear button image in this case. I would suggest taking a screenshot of the clear button and editing in photoshop.
You can take that image and create a UIButton with the image dimensions. From there you can set it as the UITextField's rightView. Like so:
================================================================
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"clear_button.png"] forState:UIControlStateNormal];
[button setFrame:CGRectMake(0.0f, 0.0f, 15.0f, 15.0f)]; // Required for iOS7
theTextField.rightView = button;
theTextField.rightViewMode = UITextFieldViewModeWhileEditing;
================================================================
@dymx101
dymx101 / gist:0d815403bacb00879baf
Created August 20, 2014 02:50
iOS Background Location Reporting
http://www.mindsizzlers.com/2011/07/ios-background-location/
http://stackoverflow.com/questions/11329992/how-to-update-location-in-background-online-in-an-ios-app
http://gageincn.dyndns.org:9080/dragon/ShareProxy?url=http://www.gagein.com/html/referral_dev2.html?t=1410436713&source=sln100&owner=9628&shareid=2256&type=linkedin
@dymx101
dymx101 / gist:e46fb261d20cba468939
Created September 19, 2014 01:41
Android imageview auto fit screen width
I had a similar problem once. I solved it by making a custom ImageView.
public class CustomImageView extends ImageView
Then override the onMeasure method of the imageview. I did something like this I believe:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
try {
Drawable drawable = getDrawable();
@dymx101
dymx101 / gist:71dbb371b1339109a5f8
Created September 24, 2014 07:20
google plus share url
https://www.gagein.com/dragon/ShareProxy?url=http://www.gagein.com/referral/?t=1411542855681&source=sgp100&owner=41440&type=google plus
https://www.gagein.com/dragon/ShareProxy?url=http://www.gagein.com/referral/?t=1411543079&source=sgp100&owner=10366&shareid=2301&type=google plus
@dymx101
dymx101 / gist:7843fce681d2f9ab79f2
Created October 22, 2014 00:41
Macbook pro A1278 blackscreen
先要排除你是否开合盖子太快了。 如果不是再确定一下是否每次都这样? 如果每次都这样,那么可能情况: 1、安全睡眠的文件出问题了。 2、可能是你的睡眠模式设置为休眠了(即每次都要点开机)。 解决办法: 1、打开 终端(Terminal),输入pmset -g; 查看如下 Active Profiles: Battery Power -1 AC Power -1* Currently in use: standbydelay 4200 standby 0 womp 1 halfdim 1 panicrestart 157680000 hibernatefile /var/vm/sleepimage sms 1 networkoversleep 0 disksleep 10 sleep 90 hibernatemode 1 ttyskeepawake 1 displaysleep 6 acwake 0 lidwake 1 hibernatefile是你的睡眠文件的全路径,确保是/var/vm/sleepimage. 如果不是,请修输入命令改为 sudo pmset -a hibernatefile /var/vm/sleepimage hibernatemode 是你的睡眠模式 0表示普通睡眠模式:内存数据不会写到hibernatefile文件,电力供应内存,一打开盖子就能马上工作。有一定的危险性,掉电内存中的数据就丢失了。 1表示休眠模式:即一合上盖子,所有数据都会写入hibernatefile文件中,并关闭电源,下次打开盖子是黑屏的,需要重新按电源键开机。 3默认方式安全睡眠模式: 一合上盖子,所有数据都会写入硬盘hibernatefile文件中,并同时不断电,电力一直供应内存,一打开盖子就可以马上工作。 算是 0和1的混合模式,即(安全睡眠) 修改为安全睡眠模式命令为: sudo pmset -a hibernatemode 3 2、重新启动,然后再尝试合盖子进入睡眠,问题应该解决了。
@dymx101
dymx101 / gist:3d685145352211333b17
Created October 27, 2014 08:42
好文分享:苹果、谷歌、脸书等公司该怎样分配股权
看到一篇不错的文章, 就转过来分享了, 话说股权、期权、投票权什么的,对安顺人来说,真的很陌生。安顺人不懂,也不想懂,每天想的都是你看他家开了一个KTV好赚钱的样子,你看那家就是卖点卷粉喽嘛,一个月都要赚好几万,我还不是可以去卖~~~
要不就是一天坐起吹牛不行动,要不就是行动了但是不够专业,废话不说,见下文吧
================================
现在创业者越来越多,也越来越年轻。对startup而言,一个好的股权安排无疑至关重要,说最重要也不为过。我在这方面虽没有直接经验,但颇看过一些书籍资料,今天总结提炼一番,供创业者们参考。