Skip to content

Instantly share code, notes, and snippets.

Verifying my Blockstack ID is secured with the address 1AXPfnwpoUe3CfEv32ukpQAdqVnsS2yAAg https://explorer.blockstack.org/address/1AXPfnwpoUe3CfEv32ukpQAdqVnsS2yAAg
{"sig":"46155a7ba68da804d707dbbbe26f4d8fc47352ff26e1fbc7e9efa4300397ba9c5f9147e587085ea644e2670c9f7b0245ffc892c6c7d056729d064ab808170e690","msghash":"d2caf9c502bda3db64524c16520f7b58febe74107f2ab16b902e6e556c70091e"}

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

### Keybase proof
I hereby claim:
* I am cndaniel on github.
* I am cndaniel (https://keybase.io/cndaniel) on keybase.
* I have a public key ASDlRhMGDvyMlv3XtsL7mpwFRlqhMfq-VWboxBXOFNJKEQo
To claim this, I am signing this object:
@cndaniel
cndaniel / sort.rb
Last active June 7, 2017 07:25
binary_search and find_index
require 'benchmark'
arr = [0, 5, 13, 13, 30, 42, 52, 70, 85, 96, 103, 111, 116, 127, 130, 143, 150, 150, 161, 175, 207, 210, 218, 246, 257, 257, 263, 280, 304, 310, 326, 327, 332, 346, 360, 371, 374, 378, 406, 407, 407, 408, 428, 431, 437, 442, 445, 479, 489, 491, 505, 517, 520, 536, 548, 598, 602, 605, 618, 642, 649, 654, 659, 662, 677, 678, 682, 689, 695, 696, 697, 701, 711, 717, 727, 737, 745, 749, 754, 757, 770, 786, 802, 805, 814, 832, 840, 850, 853, 854, 888, 894, 904, 913, 913, 945, 962, 964, 972, 998]
def binary_search(arr, element)
l = 0
r = arr.length - 1
while l <= r
mid = l + ((r - l) / 2)

一路过来也部署过3、4个Rails App了,其中也使用过mina等远程部署项目,但每次去部署新的App还是会遇到一些大大小小问题。最近和几个朋友正在做一个应用,在部署的过程中又被自己坑了~所以今天准备总结一下,方便自己未来的部署之路,也方便Rails新手学习使用。

#####环境说明 因为Linux的发型版太多,所以不能一一举例,经过自己的实践体验,发现Ubuntu可以更轻松的部署您的Rails App(个人看法,曾经在Centos下部署,遇到了好多坑)。所以该博文将基于以下的部署环境。

  1. 操作系统:Ubuntu14.04
  2. Rails:4.2.0
  3. Ruby:2.2.1
  4. Mysql: 5.6.22
  5. Nginx: 1.8.0
  6. Puma: 2.11.0
class Module
def subclasses
classes = []
ObjectSpace.each_object do |klass|
next unless Module === klass
classes << klass if self > klass
end
classes
end
end
@cndaniel
cndaniel / index.md
Created April 7, 2017 13:32 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

[alias]
st = status
s = status
co = checkout
c = commit -v
ci = commit -a -v
b = branch
d = diff
p = pull
a = add -A .
@cndaniel
cndaniel / Service-start.md
Created March 5, 2017 03:27
brew services start postgresql 无法开机启动资料库

出现 permission denied

往往因为电脑上有多个用户导致的

  1. 先去 system preferences 确定用户的权限是管理员

  2. 再进终端: echo ~ user/whoami , 确定用户名是whoami

  3. 终端输入 sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local赋予权限