Skip to content

Instantly share code, notes, and snippets.

View pingzh's full-sized avatar

Ping Zhang pingzh

View GitHub Profile
@pingzh
pingzh / rbenv-howto.md
Last active May 27, 2016 02:33 — forked from MicahElliott/rbenv-howto.md
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev

A simple solution is to move view up with constant of keyboard height.
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name:UIKeyboardWillShowNotification, object: nil);
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name:UIKeyboardWillHideNotification, object: nil);
}
@pingzh
pingzh / RBResizer.swift
Last active May 27, 2016 02:33 — forked from HamptonMakes/RBResizer.swift
Swift Image Resizer
//
// RBResizer.swift
// Locker
//
// Created by Hampton Catlin on 6/20/14.
// Copyright (c) 2014 rarebit. All rights reserved.
//
import UIKit
## hexdiget to digest
hexdigest = Digest::MD5.hexdigest("ping")
digest = hexdigest.scan(/../).map(&:hex).pack("C*")
## digest to hexdigest
digest = Digest::MD5.digest('http://www.example.com')
hexdigest = digest.unpack('H*').first
func onPanGesture(sender: UIPanGestureRecognizer) {
let translation = sender.translationInView(view)
let velocity = sender.velocityInView(view)
if sender.state == UIGestureRecognizerState.Began {
}
else if sender.state == UIGestureRecognizerState.Changed {
contentView.snp_updateConstraints(closure: { (make) -> Void in
make.left.equalTo(view).offset(translation.x)
var followingNumer: UIButton {
if _followingNumer == nil {
_followingNumer = UIButton()
_followingNumer.titleLabel?.lineBreakMode = .ByWordWrapping
_followingNumer.titleLabel?.textAlignment = .Left
_followingNumer.titleLabel?.font = TprofileButtonFont
_followingNumer.setTitleColor(TprofileButtonFontColor, forState: .Normal)
_followingNumer.setTitle("222\nFollowiing", forState: .Normal)
}
return _followingNumer
class MyAccountViewController: UIViewController {
private var _leftBarButtion: UIBarButtonItem!
private var _rightBarButton: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
addSubviews()
addLayout()
}
func addSubviews() {
private let _refreshControl: UIRefreshControl!
//in addSubviews
tableView.addSubview(refreshControl)
func refreshView() {
refreshControl.beginRefreshing()
tableView.reloadData()
//initData()

Public service announcement: never delete postmaster.pid. Really. Great way to get data corruption.

You already had PostgreSQL installed, and you deleted the data dir without stopping the running server. So you now have some orphan PostgreSQL server processes that are managing data files that've been deleted, so they're no longer accessible in the file system and will be fully deleted when the last open file handle to them is closed. You can't use pg_ctl to shut the server down like normal because you've deleted the cluster datadir, so you must simply kill the processes. Kill the postmaster (do not use kill -9, just an ordinary kill will do) and the rest will shut down too.

You will then be able to start a new server in the datadir against the freshly initdb'd data.

It is highly likely that you will experience conflicts down the track unless you uninstall the other older version of PostgreSQL.

In a nutshell:

let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: deal.value)
attributeString.addAttribute(NSStrikethroughStyleAttributeName, value: 1, range: NSMakeRange(0, attributeString.length))
value.attributedText = attributeString