Skip to content

Instantly share code, notes, and snippets.

View tdksk's full-sized avatar

Keisuke Tada tdksk

View GitHub Profile
(defun git-top-directory ()
(file-name-as-directory
(replace-regexp-in-string
"\n" ""
(shell-command-to-string "git rev-parse --show-toplevel"))))
(defun open-current-git-top-directory-in-tmux-new-pane ()
(interactive)
(let ((top-dir (git-top-directory)))
(unless (file-directory-p top-dir)
@tdksk
tdksk / UIView+TDKUtil.m
Created November 27, 2014 13:30
UIView maskByRoundingCorners:cornerRadius:
#import "UIView+TDKUtil.h"
@implementation UIView (TDKUtil)
- (void)maskByRoundingCorners:(UIRectCorner)corners
cornerRadius:(CGFloat)cornerRadius
{
[self layoutIfNeeded];
UIBezierPath *maskPath;
@tdksk
tdksk / Playground.swift
Created November 27, 2014 13:31
Swift Playground
import UIKit
// Line Height ----------------------------------------
let label = UILabel(frame: CGRectMake(0, 0, 300, 100))
label.numberOfLines = 0
label.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
label // Raw
@tdksk
tdksk / UILabel+TDKUtil.m
Created November 27, 2014 13:29
UILabel setLineHeightMultiple:
#import "UILabel+TDKUtil.h"
@implementation UILabel (TDKUtil)
- (void)setLineHeightMultiple:(CGFloat)lineHeightMultiple
{
NSMutableAttributedString *attributedString = [self.attributedText mutableCopy];
NSMutableParagraphStyle *paragrahStyle = [NSMutableParagraphStyle new];
paragrahStyle.lineHeightMultiple = lineHeightMultiple;