Deploy a Express.js project on Heroku
Step by step from command line by Michael Hsu
$ express myfirstexpress && cd myfirstexpress
- (CGSize)calculateSize { | |
NSShadow* shadow = [[NSShadow alloc] init]; | |
shadow.shadowOffset = self.shadowOffset; | |
NSMutableParagraphStyle* paragraph = [[NSMutableParagraphStyle alloc] init]; | |
[paragraph setLineBreakMode:self.lineBreakMode]; | |
[paragraph setAlignment:self.textAlignment]; | |
NSDictionary *attrDict = @{NSFontAttributeName: self.font, NSShadowAttributeName: shadow, NSParagraphStyleAttributeName: paragraph}; |
CABasicAnimation *cornerAnim = [CABasicAnimation animationWithKeyPath:@"cornerRadius"]; | |
cornerAnim.fromValue = @(0.f); | |
cornerAnim.toValue = @(50.f); | |
cornerAnim.duration = 0.5f; | |
[self.redView.layer addAnimation:cornerAnim forKey:@"cornerRadius"]; | |
self.redView.layer.cornerRadius = 50.f; | |
[UIView animateWithDuration:1.0f animations:^{ | |
self.redView.transform = CGAffineTransformMakeRotation(M_PI); |
/** | |
* Algorithm: fixed-partition | |
* | |
* The algorithm outlined by Johannes Treitz in "The algorithm | |
* for a perfectly balanced photo gallery" (see url below). | |
* | |
* Options: | |
* - containerWidth Width of the parent container (in pixels) | |
* - idealElementHeight Ideal element height (in pixels) | |
* - spacing Spacing between items (in pixels) |
1) #import <MagicalRecord/MagicalRecord.h> | |
2) in didFinishLaunchingWithOptions [MagicalRecord setupAutoMigratingCoreDataStack]; | |
3) in [MagicalRecord cleanUp]; |
+ (CGFloat)heightForCellWithPost:(Post *)post { | |
return (CGFloat)fmaxf(70.0f, (float)[self detailTextHeight:post.text] + 45.0f); | |
} | |
+ (CGFloat)detailTextHeight:(NSString *)text { | |
CGRect rectToFit = [text boundingRectWithSize:CGSizeMake(240.0f, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0f]} context:nil]; | |
return rectToFit.size.height; | |
} |
This macro for checking block nullability before executing them: | |
#define BLOCK_EXEC(block, ...) if (block) { block(__VA_ARGS__); }; | |
Moves from this: | |
if (completionBlock) | |
{ | |
completionBlock(arg1, arg2); | |
} | |
to: |
SELECT * , | |
DATE_ADD( | |
birthday, | |
INTERVAL IF(DAYOFYEAR(birthday) >= DAYOFYEAR(CURDATE()), | |
YEAR(CURDATE())-YEAR(birthday), | |
YEAR(CURDATE())-YEAR(birthday)+1 | |
) YEAR | |
) AS `next_birthday` | |
FROM `users` | |
WHERE |
Step by step from command line by Michael Hsu
$ express myfirstexpress && cd myfirstexpress
npm list -g --depth 0 |
const path = require('path'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); | |
module.exports = { | |
mode: 'development', | |
entry: './src/index.js', | |
devtool: 'inline-source-map', | |
devServer: { | |
contentBase: './dist', |