Skip to content

Instantly share code, notes, and snippets.

View jkatayama's full-sized avatar
😷
Working from home

Jumpei Katayama jkatayama

😷
Working from home
  • Tokyo
View GitHub Profile
{
"categories": [
"Decorative Trays & Bowls",
"Electronics",
"Other Dresses",
"Pants",
"Musical Instruments",
"Shirts",
"Tabletop",
"Other Lighting",

When you create a tableCell object for each row all you have to do is call dequeueReusableCellWithIdentifier on your tableView object. But this approach is only aviable when you work with storyboar. If you want to use a fully code-based cell class and one from .xib file, you need to register these identifiers to your tableView object.

Your tableViewCell is not on a tableView in storyboard and is initizlied progmatically

self.tableView.registerClass(<YourCellClass.self, forCellReuseIdentifier: "Cell")

LocationService

  • Add it to info.plist
<key>NSLocationAlwaysUsageDescription</key>
<string>Description</string>

###swift

$ curl https://raw.githubusercontent.com/github/gitignore/master/Swift.gitignore -o .gitignore

###objective-C

$ curl https://raw.githubusercontent.com/github/gitignore/master/Objective-C.gitignore -o .gitignore
@jkatayama
jkatayama / brew_prune_batch.sh
Created February 17, 2016 00:22
Batches broken brew symlinks
while read path
do
if [ -f "$path" ]; then
echo "Pruning $path.."
brew prune “$path”
else
echo "$path not found"
fi
done < "$1"
@jkatayama
jkatayama / which_and_go.sh
Created February 17, 2016 19:48
go to the directory in which your command exists
cd $(dirname "$(which npm)")

iOS9 improvement

Disblae ATS(AppTransportSecurity) to allow http

<key>NSAppTransportSecurity</key>
     <dict>
         <key>NSAllowsArbitraryLoads</key><true/>
     </dict>

iOS sheat-sheet

Get a selected cell's index

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    let path = self.tableView.indexPathForSelectedRow
    segue.destinationViewController.detail = self.detailForIndexPath(path)
}
### 二つの点の距離
``` swift
func distance(pointA: CGPoint, pontB: CGPoint) -> Float {
let dx: Float = abs(pointA.x - pontB.x)
let dy: Float = abs(pointA.y - pontB.y)
let dist = sqrt(dx*dx + dy*dy)
return dist
}