create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
package com.tomgibara.android.util; | |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.view.ViewGroup; | |
/** | |
* A layout that arranges views into a grid of same-sized squares. |
First, install nginx for mac with "brew install nginx". | |
Then follow homebrew's instructions to know where the config file is. | |
1. To use https you will need a self-signed certificate: https://devcenter.heroku.com/articles/ssl-certificate-self | |
2. Copy it somewhere (use full path in the example below for server.* files) | |
3. sudo nginx -s reload | |
4. Access https://localhost/ | |
Edit /usr/local/etc/nginx/nginx.conf: |
create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
Use: for testing against email regex | |
ref: http://codefool.tumblr.com/post/15288874550/list-of-valid-and-invalid-email-addresses | |
List of Valid Email Addresses | |
email@example.com | |
firstname.lastname@example.com | |
email@subdomain.example.com | |
firstname+lastname@example.com |
extension UIImage { | |
func cropsToSquare() -> UIImage { | |
let refWidth = CGFloat(CGImageGetWidth(self.CGImage)) | |
let refHeight = CGFloat(CGImageGetHeight(self.CGImage)) | |
let cropSize = refWidth > refHeight ? refHeight : refWidth | |
let x = (refWidth - cropSize) / 2.0 | |
let y = (refHeight - cropSize) / 2.0 | |
let cropRect = CGRectMake(x, y, cropSize, cropSize) |
extension String { | |
func snakeCased() -> String? { | |
let pattern = "([a-z0-9])([A-Z])" | |
let regex = try? NSRegularExpression(pattern: pattern, options: []) | |
let range = NSRange(location: 0, length: self.characters.count) | |
return regex?.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: "$1_$2").lowercased() | |
} | |
} |
import UIKit | |
import AVKit | |
import AVFoundation | |
import AssetsLibrary | |
func synchronized(_ object: AnyObject, block: () -> Void) { | |
objc_sync_enter(object) | |
block() | |
objc_sync_exit(object) | |
} |
enum Foo: String, Codable { | |
case a | |
case b | |
case c | |
} | |
extension RawRepresentable where RawValue == String, Self: Codable { | |
init(from decoder: Decoder) throws { | |
var container = try decoder.unkeyedContainer() | |
let rawValue = try container.decode(String.self) |
import UIKit | |
import AVFoundation | |
class ViewController: UIViewController { | |
override func viewDidAppear(_ animated: Bool) { | |
super.viewDidAppear(animated) | |
switch AVCaptureDevice.authorizationStatus(for: .video) { | |
case .notDetermined: |
for line in `adb devices | grep -v "List" |grep -v ":" | awk '{print $1}'` | |
do | |
device=`echo $line | awk '{print $1}'` | |
echo "Running commands for $device" | |
echo "Restarting $device in TCP mode on port 5555..." | |
adb -s "$device" tcpip 5555 | |
echo "Waiting for $device to switch to TCP mode..." | |
sleep 7 | |
ip_addr=$(adb -s "$device" shell ip route | grep wlan| grep -o ' 192.*$' | awk '{print $1":5555"}') | |
echo "Connecting to Device via WIFI on $ip_addr" |