-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreferences
138 lines (117 loc) · 4.94 KB
/
references
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# ------------------------------
# FOR REFERENCES ONLY
# Used by the gg bash function
# ------------------------------
# ------------------------------
# Rails
# ------------------------------
# Run rake task from rails console
require 'rake'
app.load_tasks
Rake::Task['task_name'].invoke
binding.remote_pry in code, pry-remote in console
bundle install ~/gem_install_dir --no-deployment --without development test local
# migrations
rails generate scaffold ModelName name:string
rails generate model ModelName name:string # model & migration
rails generate migration ModelName name:string # only migration file
rake db:migrate:status
rake db:rollback STEP=2
rake db:test:prepare # update test DB with pending migrations
# show indexes of an ActiveRecord table
ActiveRecord::Base.connection.indexes(table_name).inspect
ActiveRecord::Migration.index_exists?(:subscriptions, :business_id)
# new rails app template / generator gems
thoughtbot / suspenders
RailsApps / rails-composer
# ------------------------------
# MySQL
# ------------------------------
# ------------------------------
# SSL / Certs
# ------------------------------
openssl s_client -connect "domain_name:port" --showcerts # show certs of site
# ------------------------------
# Windows commands
# ------------------------------
quser # show login time
# ------------------------------
# Linux / Bash
# ------------------------------
nc -z $HOSTNAME $PORT # test to see if it's alive, -z to scan only
alias stopmail='sudo postfix stop'
alias startmail='sudo postfix start'
VAR1="${VAR1:-default_value}" # parameter expansion, set to default_value if it's not set
yum provides '*/modules/mod_ldap.so' # find yum packages containing this file
cd - # cd to previous directory
last # show history of last logged in users
<space> command # A space before a bash command is not recorded in history.
> file.txt # flush the content of a text file, same as cat /dev/null > file.txt
The key to autocompletion is the bash command complete
You can print the rules for vim using: complete -p vim
Likewise you can remove these specific rules with: complete -r vim
Removing the rules resets it to defaults - the usual paths and file names completion
without any extra logic. This can be used to fix auto-complete issues.
: <<'COMMENT'
/etc/profile
The systemwide initialization file, executed for login shells
~/.bash_profile
This file loads whenever Mac OS Terminal or its tab is open.
The personal initialization file, executed for login shells
e.g., when you login from another host, or login at the text
console of a local unix machine. Similar to ~/.profile.
Classically, ~/.profile is used by Bourne Shell.
~/.bashrc
The individual per-interactive-shell startup file.
The ~/.bashrc script is read every time a shell is started.
~/.bashrc should be as lightweight (minimal) as possible
to reduce the overhead when starting a non-login shell.
~/.bash_logout
The individual login shell cleanup file,
executed when a login shell exits.
COMMENT
# ------------------------------
# Git
# ------------------------------
git config --unset core.autocrlf # remove a git config
git clean -fd # remove untracked files and directories
# ------------------------------
# Vim
# ------------------------------
:let " show all variables
:echo <variable> # show var value
http://learnvimscriptthehardway.stevelosh.com/chapters/19.html - learn about variables and options, local and global
Lessons Learned:
Do not put variable value of a directory in quotes as it is treated differently as a value in the current directory
let sessiondir=~/vs # errors with: Invalid expression: ~/vs ; to fix use: let sessiondir=$HOME."/vs"
let l:sessiondir=$HOME."/vs" # errors with: Illegal variable name: l:sessiondir ;
let &l:<var> is used to set the local value of an option as a variable. It's not to be used for regular variable.
Option and regular variable are different things.
Options are vim reserved variables for configuring vim.
mksession takes variables as literals. Ref: https://stackoverflow.com/questions/13459103
To solve this, use: execute "mksession! ".sessiondir."/temp"
call vs execute
:call: Call a function.
:exec: Executes a string as an Ex command. It's similar to eval in javascript.
in vimrc, leader is the \ key
# normal mode
s - delete char & insert
S - delete line & insert
vip - select paragraph
ga - show hex code of character under cursor
# edit mode
Ctrl+v+u+<char hex code> - insert a special char, use 'ga' to find hex code
# visual mode
s - replace highlighted text
# ------------------------------
# LDAP
# ------------------------------
ldapsearch -x -W -D $HTTPD_VDE_USER -v -LLL -H "ldaps://domain_name" -b "c=us" "(CN=tran ch*)" -d 5 # -d 5 for debug level 5
env | grep -i LDAP
unset LDAPTLS_CERT_LDAPTLS_CACERT # or set LDAPTLS_KEY
cat /etc/openldap/ldap.conf
echo $TLS_CACERTDIR
# ------------------------------
# Mac
# ------------------------------
Lock Screen shortcut (High Seirra): Control+Command+Q