forked from matschaffer/profile
-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.conf
51 lines (45 loc) · 1.24 KB
/
utils.conf
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
nth_field() {
awk "{print \$$1}"
}
to_iso_time() {
while [ -n "$1" ]; do
ruby -e "require 'time'; puts Time.at($1 / 1000).utc.iso8601"
shift
done
}
to_tvlistings_query() {
ruby <<EOS
%w(time cgi uri).each { |l| require l }
query = CGI.parse(URI.parse("$1").query)
puts "http://eko.dev.cim.comcast.net/cimdata/tv/lineups/tms-@HEADEND_TOKEN@/programs/@START_TIME_TOKEN@/PT@DURATION_TOKEN@m?tvgd=true&vcn=@VCN_TOKEN@&tz=UTC".
gsub('@HEADEND_TOKEN@', query['headend'].first).
gsub('@START_TIME_TOKEN@', URI.escape(Time.at(query['startTime'].first.to_i / 1000).utc.iso8601, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))).
gsub('@DURATION_TOKEN@', ((query['endTime'].first.to_i - query['startTime'].first.to_i) / 60000).to_s).
gsub('@VCN_TOKEN@', query['vcn'].first.to_i.to_s)
EOS
}
tvlistings_check() {
echo `to_tvlistings_query "$1"`
to_tvlistings_query "$1" | xargs curl | tidy -xml -i
}
flike() {
local search path
if [ -z "$2" ]; then
search="$1"
path=.
else
search="$2"
path="$1"
fi
find "${path}" -iname "*${search}*"
}
..() {
local times
times=$(echo $1 | wc -c)
for ((i = 1; i < $times ; i++)); do
cd ..
done
}
curlx() {
curl $@ | tidy -q -xml -i
}