Skip to content

Instantly share code, notes, and snippets.

View susieyy's full-sized avatar

yohei sugigami susieyy

View GitHub Profile
@susieyy
susieyy / peco_select_repository.fish
Created June 10, 2015 11:20
dotfiles/home/.config/fish/functions/peco_select_repository.fish
function peco_select_repository
if test (count $argv) = 0
set peco_flags --layout=bottom-up
else
set peco_flags --layout=bottom-up --query "$argv"
end
ghq list -p | peco $peco_flags | perl -pe 's/([ ()])/\\\\$1/g'| read foo
if [ $foo ]
@susieyy
susieyy / swift
Created June 17, 2016 10:03
Avoid awkward image animation with re-calculated height
UIView.setAnimationsEnabled(false)
self?.beginUpdates()
self?.endUpdates()
UIView.setAnimationsEnabled(true)
@susieyy
susieyy / 0_reuse_code.js
Created July 31, 2016 04:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@susieyy
susieyy / Check_if_view_controller_is_presented_modally__or_pushed_on_a_navigation_stack.swift
Last active August 3, 2016 09:40
Check if view controller is presented modally, or pushed on a navigation stack
// @see http://stackoverflow.com/a/23620428/1002412
// @see http://level49.com/119
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
if isBeingDismissed() {
// being dismissed
} else if isMovingFromParentViewController() {
// being poped
} else {
@susieyy
susieyy / PreviousViewController.swift
Created August 4, 2016 10:41
Access previous view controller in navigation stack
extension UIViewController {
var previousViewController: UIViewController? {
guard let navigationController = navigationController else { return nil }
let count = navigationController.viewControllers.count
return count < 2 ? nil : navigationController.viewControllers[count - 2]
}
}
@susieyy
susieyy / SeparatorInset.swift
Created August 9, 2016 06:30
UITableView's separator inset
// Hide
cell.separatorInset = UIEdgeInsets(top: 0, left: tableView.bounds.width, bottom: 0, right: 0)
cell.layoutMargins = UIEdgeInsetsZero
// Show
cell.separatorInset = UIEdgeInsetsZero
cell.layoutMargins = UIEdgeInsetsZero
final class SwipeContainerViewController: UIPageViewController {
convenience init() {
self.init(transitionStyle: .Scroll, navigationOrientation: .Horizontal, options: nil)
}
override init(transitionStyle style: UIPageViewControllerTransitionStyle, navigationOrientation: UIPageViewControllerNavigationOrientation, options: [String : AnyObject]?) {
super.init(transitionStyle: style, navigationOrientation: navigationOrientation, options: options)
}
final class SearchContainerViewController: UIViewController {
let hoge: Hoge
convenience init(hoge: Hoge) {
self.init(nibName: nil, bundle: nil)
self.hoge = hoge
}
override init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) { super.init(nibName: nil, bundle: nil) }
required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }
final class OverridedCell: UITableViewCell {
static let identifier = "OverridedCell"
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
prepareView()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
@susieyy
susieyy / PushTransitionWithCustomAnimation.swift
Created February 23, 2017 08:57
push transition with custom animation
let transition = CATransition()
transition.duration = 0.2
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
transition.type = kCATransitionFade
navigationController?.view.layer.addAnimation(transition, forKey: nil)
navigationController?.pushViewController(con, animated: true)