Skip to content

Instantly share code, notes, and snippets.

View alex-zige's full-sized avatar
🤞
Focusing

Alex Z. Li alex-zige

🤞
Focusing
View GitHub Profile
@alex-zige
alex-zige / gist:5795358
Last active June 8, 2023 07:49
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
@alex-zige
alex-zige / gist:523f8f0a8534eebff731
Last active May 23, 2023 09:45
Custom Search Bar in Nav
@alex-zige
alex-zige / gist:9103810
Created February 19, 2014 23:29
Curl post json file to api url endpoints for API testing
curl -H "Content-Type: application/json" --data @your-json-file-name.json http://localhost:XXXX/api-end-point
@alex-zige
alex-zige / IT职业分享.md
Created May 20, 2019 05:52
IT职业分享

新西兰IT就业分享

Intro - Alex

介绍

agenda

IT职业发展和规划 - Feilong

@alex-zige
alex-zige / gist:8177726
Created December 30, 2013 04:16
custom background image for IOS UIRefreshControl
-(void)preparePulltoRefresh{
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.tintColor = [UIColor whiteColor];
[refreshControl addTarget:self action:@selector(reloadMeetings) forControlEvents:UIControlEventValueChanged];
//creating view for extending background color
CGRect frame = self.tableView.bounds;
frame.origin.y = -frame.size.height;
UIView *refreshBackgroundView = [[UIView alloc]initWithFrame:frame];
refreshBackgroundView.backgroundColor = UIColorFromRGB(0xXXXXXX);
@import 'helpers/Utils.js';
@import 'libraries/View.js';
var onRun = function(context) {
utils.init(context);
dialog.showSuccessExportMessage();
var app = [NSApplication sharedApplication];
[app displayDialog:"Anything selected <img src='http://www.thinkandbuild.it/wp-includes/images/smilies/icon_sad.gif'/> " withTitle:"Exportabler"];
@alex-zige
alex-zige / gist:8411571
Created January 14, 2014 01:39
Keychain Security Value Data is return CFDataRef, to cast as NSString you have to parse it!
NSData *passData = [keychain objectForKey:(id)kSecValueData];
NSString *pass = [[NSString alloc] initWithBytes:[passData bytes] length:[passData length] encoding:NSUTF8StringEncoding];
@alex-zige
alex-zige / gist:8294060
Created January 7, 2014 03:04
Shell script for one-command bootstrap rails 4 project with ruby 2.0.0. [4.0.2] latest version. Please put the code into your ~/.bash_profile and call bootstrap_rails4 in terminal inside your target folder
function set_ruby2_with_gemset(){
local result=${PWD##*/}
local result=${result// /_}
local result=$(echo $result | tr '[A-Z]' '[a-z]')
echo "prepare ruby 2.0 with gemset "$result
rvm --create ruby-2.0.0-p247@$result
}
function use_ruby2_with_gemset(){
local result=${PWD##*/}
@alex-zige
alex-zige / gist:8293850
Created January 7, 2014 02:37
A quick shell script for setting up gemset with ruby2. auto-mapping gemset name to be lowercase and underscore version of your current folder name.
function set_ruby2_with_gemset(){
local result=${PWD##*/}
local result=${result// /_}
local result=$(echo $result | tr '[A-Z]' '[a-z]')
echo "prepare ruby 2.0 with gemset "$result
rvm --create ruby-2.0.0-p247@$result
}
function use_ruby2_with_gemset(){
@alex-zige
alex-zige / gist:8216563
Last active January 1, 2016 23:29
Rails standard time to object-c NSdate or vice versa
//Rails time to NSdate
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZ"];
NSDate *date = [df dateFromString:@"2013-04-07T21:19:14Z"];
//NSDate to String
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MM/dd/yyyy HH:mm a"];