This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset | |
{ | |
UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout*) self.collectionView.collectionViewLayout; | |
// CGFloat maxOffset = (kItemWidth + flowLayout.minimumInteritemSpacing) * kMaxCount; | |
NSInteger item = (targetContentOffset->x / (kItemWidth + flowLayout.minimumInteritemSpacing)); | |
NSIndexPath *targetPath = [NSIndexPath indexPathForItem:item inSection:0]; | |
UICollectionViewLayoutAttributes *attrs = [self.collectionView layoutAttributesForItemAtIndexPath:targetPath]; | |
DebugLog(@"target cell attrs: %@", attrs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath]; | |
// we are placing it above the collection view, in the VC.view, | |
// so convert the rect to that coord. region | |
CGRect cellRect = [collectionView convertRect:cell.frame toView:self.view]; | |
CGRect cellBounds = cell.bounds; | |
// get an image of the cell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- open Terminal and do stuff | |
tell application "Terminal" | |
set currentTab to do script ("python") | |
delay 1 | |
do script ("import sys") in currentTab | |
do script ("sys.path") in currentTab | |
delay 1 | |
--close front window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/** | |
Provides the default transaction block for perform a Realm transaction. | |
:param: block The block to perform the transaction. The realm is used to store the transaction. | |
*/ | |
func realmTransaction(block: (realm: RLMRealm) -> Void) { | |
let realm = RLMRealm.defaultRealm() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var options = { | |
tls: { | |
key: fs.readFileSync(path.join(__dirname, "private/key/key.pem"), 'utf-8'), | |
cert: fs.readFileSync(path.join(__dirname, "private/key/certificate.pem"), 'utf-8') | |
} | |
}; | |
var https = new hapi.Server("localhost", configuration["api-port"], options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Expands to set self.frame.origin | |
#define UIViewOrigin(X, Y) ({ \ | |
CGRect frame = self.frame; \ | |
frame.origin = CGPointMake(X, Y); \ | |
self.frame = frame; }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sets the view's background to the given image | |
static void SetBackgroundImage(UIView *view, NSString *imageName) | |
{ | |
view.layer.contents = (id)[UIImage imageNamed:imageName].CGImage; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get metric for the object id and today's date | |
var currentDate = new Date(); | |
currentDate.setHours(0); | |
currentDate.setMinutes(0); | |
currentDate.setSeconds(0); | |
console.log(currentDate.toString()); | |
StatMetric.find({ | |
where : { object_id: metricObject.id, stat_type_id: statTypeId, current_date: currentDate} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/MyDrive/nodejs/node_modules/sqlite3/lib/trace.js:28 | |
throw err; | |
^ | |
TypeError: Cannot call method 'split' of undefined | |
at module.exports.QueryGenerator.hashToWhereConditions (/MyDrive/nodejs/node_modules/sequelize/lib/dialects/mysql/query-generator.js:263:29) | |
at _.map.results.length (/MyDrive/nodejs/node_modules/sequelize/node_modules/underscore/underscore.js:102:42) | |
at _.each._.forEach (/MyDrive/nodejs/node_modules/sequelize/node_modules/underscore/underscore.js:89:24) | |
at Function._.map (/MyDrive/nodejs/node_modules/sequelize/node_modules/underscore/underscore.js:101:5) | |
at Object.module.exports.QueryGenerator.hashToWhereConditions (/MyDrive/nodejs/node_modules/sequelize/lib/dialects/mysql/query-generator.js:249:22) | |
at Object.module.exports.QueryGenerator.getWhereConditions (/MyDrive/nodejs/node_modules/sequelize/lib/dialects/mysql/query-generator.js:237:33) |
OlderNewer