Install rbenv and ruby-build to Amazon Linux (cloud-init).
- Copy & paste content of
user-data.sh
to EC2 RunInstances user-data - Then, logging in to EC2 instance as ec2-user and run
install-ruby.sh
.
Install rbenv and ruby-build to Amazon Linux (cloud-init).
user-data.sh
to EC2 RunInstances user-datainstall-ruby.sh
.[alias] | |
verbs = !git log --pretty=format:'%s' | cut -d \" \" -f 1 | sort | uniq -c | sort -nr |
- (UIImage *)compressImage:(UIImage *)image{ | |
float actualHeight = image.size.height; | |
float actualWidth = image.size.width; | |
float maxHeight = 600.0; | |
float maxWidth = 800.0; | |
float imgRatio = actualWidth/actualHeight; | |
float maxRatio = maxWidth/maxHeight; | |
float compressionQuality = 0.5;//50 percent compression | |
if (actualHeight > maxHeight || actualWidth > maxWidth) { |
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'` | |
# or... | |
sudo killall coreaudiod |
# expand_path is genuine and DOES KNOW ABOUT absolute and relative paths | |
File.expand_path('relative/path/to/dir_or_file', '/start/path') # "/start/path/relative/path/to/dir_or_file" | |
File.expand_path('../application', __FILE__) # "/absolute/path/to/FILE/../application" | |
File.expand_path('/path/to/dir_or_file', '/start/path') # "/path/to/dir_or_file" | |
File.expand_path('../path/to/dir_or_file', '/start/path') # "/start/path/to/dir_or_file" | |
# join seems to be STUPID. It just joins strings (and adds file separator if needed) | |
File.join('some/path/', '/other/path.rb') # "some/path/other/path.rb" | |
# modify the global load path: |
ACTION | |
AD_HOC_CODE_SIGNING_ALLOWED | |
ALTERNATE_GROUP | |
ALTERNATE_MODE | |
ALTERNATE_OWNER | |
ALWAYS_SEARCH_USER_PATHS | |
ALWAYS_USE_SEPARATE_HEADERMAPS | |
APPLE_INTERNAL_DEVELOPER_DIR | |
APPLE_INTERNAL_DIR | |
APPLE_INTERNAL_DOCUMENTATION_DIR |
Suppose you have a network method that only uses a single block callback
typedef void (^Handler)(BOOL success, id response, NSError *error);
- (void)makeRequestWithHandler:(Handler)handler;
But you have to make this request dozens of times, and you want to reuse the same failure handler in most cases? Easy, just have a factory function that returns a block:
typedef void (^SuccessHandler)(id response);
typedef void (^ErrorHandler)(NSError *error);
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
#!/bin/bash | |
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport | |
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport |
Bash is the JavaScript of systems programming. Although in some cases it's better to use a systems language like C or Go, Bash is an ideal systems language for smaller POSIX-oriented or command line tasks. Here's three quick reasons why:
This document is how I write Bash and how I'd like collaborators to write Bash with me in my open source projects. It's based on a lot of experience and time collecting best practices. Most of them come from these two articles, but here integrated, slightly modified, and focusing on the most bang for buck items. Plus some ne