Skip to content

Instantly share code, notes, and snippets.

View jdorfman's full-sized avatar

Justin Dorfman jdorfman

View GitHub Profile
@jdorfman
jdorfman / gist:3045625
Created July 4, 2012 05:53
Install syslog-ng on CentOS 5.7 x64
yum install -y libnet && cd /tmp/
wget http://mirror.chpc.utah.edu/pub/epel/5/i386/epel-release-5-4.noarch.rpm && rpm -Uvh epel-release-5-4.noarch.rpm
wget http://mirror.cogentco.com/pub/linux/epel//5/x86_64/syslog-ng-2.1.4-9.el5.x86_64.rpm && rpm -Uvh syslog-ng-2.1.4-9.el5.x86_64.rpm
HTTP/1.1 200 OK
$ tail -50000 access.log |grep -Po '(?<=http://)[^/]+' |sort |uniq -c |sort -n |tail -30 |sort -nr
2051 s3.domain.com
506 encdn.foo.com
417 www.barfoo.com
384 cdn.example.com
@jdorfman
jdorfman / file.rb
Created July 14, 2012 17:03
must try
sed 's/[abc]/2/gi;s/[def]/3/gi;s/[ghi]/4/gi;s/[jkl]/5/gi;s/[mno]/6/gi;s/[pqrs]/7/gi;s/[tuv]/8/gi;s/[wxyz]/9/gi' <<<"1-800-SHOWNUM" -- Command Line Magic (@climagic)
#!/bin/bash
function getapistats () {
curl -s http://api.example.com/stats > api-stats.txt
awk {'print $1'} api-stats.txt > api-stats-int.txt
awk {'print $2'} api-stats.txt > api-stats-fqdm.txt
}
# api-stats.txt example
# 992 cdn.example.com
curl -IH "Accept-Encoding: gzip" http://cp2pull.rwstest.netdna-cdn.com/flowplayer-3.2.6.min.js
HTTP/1.1 200 OK
Date: Tue, 07 Aug 2012 03:49:44 GMT
Content-Type: application/javascript
Connection: keep-alive
Last-Modified: Fri, 04 Mar 2011 10:01:08 GMT
ETag: "5c04508-41af-49da53993e100"
Vary: Accept-Encoding
Server: NetDNA-cache/2.2
curl -IH "Accept-Encoding: gzip" http://cp2pull.rwstest.netdna-cdn.com/flowplayer-3.2.6.min.js
HTTP/1.1 200 OK
Date: Tue, 07 Aug 2012 03:43:35 GMT
Content-Type: application/javascript
Content-Length: 16815
Connection: keep-alive
Last-Modified: Fri, 04 Mar 2011 10:01:08 GMT
ETag: "5c04508-41af-49da53993e100"
Vary: Accept-Encoding
location / {
gzip on; # Enables Gzip
gzip_min_length 100; # If file is below 100 bytes no on-the-fly compression is made
gzip_types text/plain text/xml application/xml text/css text/javascript application/javascript application/x-javascript text/x-component application/json application/xhtml+xml application/rss+xml application/atom+xml application/vnd.ms-fontobject image/svg+xml application/x-font-ttf font/opentype; # Sets the file/mime types to gzip
gzip_disable "MSIE [1-6]\."; # Disable GZip for IE versions 1-6 user-agents
}
curl -I http://cp2pull.rwstest.netdna-cdn.com/flowplayer-3.2.6.min.js
HTTP/1.1 200 OK
Date: Tue, 07 Aug 2012 01:56:43 GMT
Content-Type: application/javascript
Connection: keep-alive
Last-Modified: Fri, 04 Mar 2011 10:01:08 GMT
ETag: "5c04508-41af-49da53993e100"
Vary: Accept-Encoding
Server: NetDNA-cache/2.2
curl -I http://cp2pull.rwstest.netdna-cdn.com/flowplayer-3.2.6.min.js
HTTP/1.1 200 OK
Date: Tue, 07 Aug 2012 01:56:43 GMT
Content-Type: application/javascript
Connection: keep-alive
Last-Modified: Fri, 04 Mar 2011 10:01:08 GMT
ETag: "5c04508-41af-49da53993e100"
Vary: Accept-Encoding
Server: NetDNA-cache/2.2