-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile-methods
More file actions
214 lines (175 loc) · 4.32 KB
/
Copy pathprofile-methods
File metadata and controls
214 lines (175 loc) · 4.32 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
function mkcd {
mkdir "$@" && cd "$@";
}
function swop {
if [ $# -ne 2 ] && [ $# -ne 3 ]; then
>&2 echo "Usage : swop <regex to replace> <replacement> [directory or files to process]" && return 0
fi
ack -l "$1" "$3" | xargs perl -pi -E "s/$1/$2/g";
}
function hush {
$@ 2> /dev/null
}
function errcho {
(>&2 echo $@)
}
function git_cherry_nibble {
if [ $# -ne 1 ]; then # Other than 1 parameter
>&2 echo "Usage : git_cherry_nibble <commit hash>"
return 0
fi
git cherry-pick $1 && git reset --soft HEAD
}
function git_pop_branch {
branchtopop=$(git current-branch)
git checkout master
git branch --delete $branchtopop
}
function deploy_sisra_proxy {
echo $@
DIR=`pwd`
cd /Users/igor/work/syadem/sisra-ws-security-proxy
gradle build
./deploy.sh $@
cd $DIR
}
function log_sisra_proxy {
if [[ $1 == "local" ]]; then
tail -f /Users/igor/work/syadem/sisra-ws-security-proxy/log/development.log
else
hm ssh $1 prv "tail -f /opt/sisra_ws_security_proxy/sisra_ws_security_proxy.log"
fi
}
function nokogiripleasewithversion {
version="$1"
libxml2_prefix=$(brew --prefix libxml2)
gem install nokogiri -v "$version" -- \
--use-system-libraries \
--with-xml2-include="$libxml2_prefix"/include/libxml2
}
function colp {
column_ref=$1
awk "{print \$$column_ref}"
}
function line {
lineno="$1"
awk "FNR==$lineno"
}
function lines {
start="$1"
endd="$2"
awk "FNR>=$start && FNR<=$endd"
}
function gchain {
for command in "$@"; do
echo $command | xargs git
done
}
function rjq {
if [[ $# < 1 ]]; then
>&2 echo 'rjson $remote:$path $json_selector'
return 0
fi
rclone lsjson $1 | jq $2
}
function agv {
ag -l $@ | xargs -o vim +/\\c"$1"
}
function change_case {
snake_head_regex='s/^([A-Z])/\L\1/g'
snake_inner_regex='s/([a-z0-9])([A-Z])/\1_\L\2/g'
camel_head_regex='s/^([a-z])/\L\1/g'
camel_inner_regex='s/([a-z0-9]_?)([A-Z])/\1\U\2/g'
kebab_head_regex='s/^([A-Z])/\L\1/g'
if [[ $1 == "--snake" ]]; then
head_regex=$snake_head_regex
inner_regex=$snake_inner_regex
elif [[ $1 == "--camel" ]]; then
head_regex=$camel_head_regex
inner_regex=$camel_inner_regex
elif [[ $1 == "--kebab" ]]; then
head_regex=$kebab_head_regex
inner_regex=$camel_inner_regex
else
errcho "Invalid option $1"
errcho "Available options : --snake, --camel, --kebab"
return 0
fi
echo $2 | \
gsed -E $inner_regex | \
gsed -E $head_regex
}
function docker_bash {
container_name="$1" # Accepts substring of name
docker_container_id=$(docker ps -aqf "name=$container_name")
if [[ `echo "$docker_container_id" | wc -l` -gt 1 ]] ; then
>&2 echo Ambiguous container name
>&2 docker ps -af "name=$container_name"
return 0
fi
docker exec -it "$docker_container_id" bash -i
}
function between {
mark1=$1
mark2=$2
awk "/$mark1/{flag=1;next}/$mark2/{flag=0}flag"
}
function brew_tally {
brew outdated | \
grep -v "$(brew list --pinned)" | \
tee ~/.brew_outdated_packages | \
wc -l| \
xargs echo 'Brew outdated packages:'
}
function brew_upgrade {
brew upgrade < ~/.brew_outdated_packages
}
function p12ToCerAndKey {
p12=$1
cer=${p12%.p12}.cer
key=${p12%.p12}.key
openssl pkcs12 -in $p12 -out $cer -clcerts -nokeys
openssl pkcs12 -in $p12 -out $key -nocerts -nodes
}
function ranzer {
dir_part=$1
most_frecent_entry=$(z -l $dir_part|awk 'END{print $NF}')
ranger $most_frecent_entry
}
function af {
regex="$@"
ag -l "$regex" && fd "$regex"
}
function tmig {
rake db:migrate:status|tail -$1
}
function testaing {
method=$1
shift
endpoint='http://localhost:3008/testaing'
header="Content-Type: application/json"
case $method in
start)
payload='{"action":"create", "type":"resources"}'
set -x && curl $endpoint -X POST -d $payload -H "$header"
;;
random)
set -x && curl $endpoint -X POST -d '{"random": "true"}' -H "$header"
;;
stop)
set -x && curl $endpoint/stop -H "$header"
;;
ping)
set -x && curl $endpoint/ping -H "$header"
;;
reset)
set -x && curl $endpoint/reset -H "$header"
;;
cleanup)
set -x && curl $endpoint/clean-up -H "$header"
;;
*)
>&2 echo "Usage : testaing [[start] [object] [amount]|'random'|'stop'|'ping'|'reset'|'cleanup']" && return 0
;;
esac
}