Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 40 lines (35 sloc) 1.229 kb
7d02270 @mathiasbynens Initial commit.
mathiasbynens authored
1 # Create a new directory and enter it
6117c55 @mathiasbynens Add `json` function. Example usage: `json http://fronteers.nl/congres…
mathiasbynens authored
2 function md() {
6b75bfc @mathiasbynens Use tabs instead of double-space indents
mathiasbynens authored
3 mkdir -p "$@" && cd "$@"
7d02270 @mathiasbynens Initial commit.
mathiasbynens authored
4 }
5
6 # Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL.
7 # Send a fake UA string for sites that sniff it instead of using the Accept-Encoding header. (Looking at you, ajax.googleapis.com!)
6117c55 @mathiasbynens Add `json` function. Example usage: `json http://fronteers.nl/congres…
mathiasbynens authored
8 function httpcompression() {
6b75bfc @mathiasbynens Use tabs instead of double-space indents
mathiasbynens authored
9 encoding="$(curl -LIs -H 'User-Agent: Mozilla/5 Gecko' -H 'Accept-Encoding: gzip,deflate,compress,sdch' "$1" | grep '^Content-Encoding:')" && echo "$1 is encoded using ${encoding#* }" || echo "$1 is not using any encoding"
7d02270 @mathiasbynens Initial commit.
mathiasbynens authored
10 }
11
9b0af44 @mathiasbynens Allow piping to the `json` function
mathiasbynens authored
12 # Syntax-highlight JSON strings or files
6117c55 @mathiasbynens Add `json` function. Example usage: `json http://fronteers.nl/congres…
mathiasbynens authored
13 function json() {
9b0af44 @mathiasbynens Allow piping to the `json` function
mathiasbynens authored
14 if [ -p /dev/stdin ]; then
15 # piping, e.g. `echo '{"foo":42}' | json`
16 while read data; do
17 python -mjson.tool <<< "$data" | pygmentize -l javascript
18 done
19 else
20 # e.g. `json '{"foo":42}'`
21 python -mjson.tool <<< "$*" | pygmentize -l javascript
22 fi
6117c55 @mathiasbynens Add `json` function. Example usage: `json http://fronteers.nl/congres…
mathiasbynens authored
23 }
24
7d02270 @mathiasbynens Initial commit.
mathiasbynens authored
25 # All the dig info
6117c55 @mathiasbynens Add `json` function. Example usage: `json http://fronteers.nl/congres…
mathiasbynens authored
26 function digga() {
6b75bfc @mathiasbynens Use tabs instead of double-space indents
mathiasbynens authored
27 dig +nocmd "$1" any +multiline +noall +answer
e3c4b0e @mathiasbynens Add `escape` function which escapes UTF-8 characters into their 3-byt…
mathiasbynens authored
28 }
29
30 # Escape UTF-8 characters into their 3-byte format
31 function escape() {
6b75bfc @mathiasbynens Use tabs instead of double-space indents
mathiasbynens authored
32 printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u)
33 echo # newline
fad9536 @mathiasbynens Add `unidecode` function
mathiasbynens authored
34 }
35
36 # Decode \x{ABCD}-style Unicode escape sequences
37 function unidecode() {
6b75bfc @mathiasbynens Use tabs instead of double-space indents
mathiasbynens authored
38 perl -e "binmode(STDOUT, ':utf8'); print \"$@\""
39 echo # newline
df229c4 @mathiasbynens Whitespace cleanup.
mathiasbynens authored
40 }
Something went wrong with that request. Please try again.