Kalanand's June 2015 Log

   May 2015   
June 2015
SuMoTuWeThFrSa
 123456
78910111213
14151617181920
21222324252627
282930    
   July 2015   

June 3rd

To perform grep on double quotes I need to enclose them within single quotes:

echo '"member":"time"' | grep -e 'member"'

Shorthand for diff of git commit with its parent


git show $COMMIT
(It'll show you the log message for the commit, and the diff of that particular commit)

Git cherry-pick command


git cherry-pick -x -m 1  
The "-x" argument will automatically add a note to the commit message documenting the hash of the original commit that it came from. The "-m 1" option uses parent 1 as the base.

June 12th

Colors in Matplotlib: Named colors can be specified by using a single character enclosed in quotes. For example, line_color = "r". The named colors are:
b: blue
g: green
r: red
c: cyan
m: magenta
y: yellow
k: black
w: white
Other named colors can be seen illustrated here: http://matplotlib.org/examples/color/named_colors.html

A RGB color can be specified in hexadecimal format as line_color = "#eeefff".

June 15th

Some python anti-patterns

I find the following ones useful occationally

>>> words = ['apple', 'banana', 'orange', 'peach', 'pineapple', 'apricot']
>>> alist = [word for word in words if word.startswith('a')]
>>> print alist
['apple', 'apricot']
>>> print [word[1] for word in words]
['p', 'a', 'r', 'e', 'i', 'p']
>>> print [word[2] for word in words]
['p', 'n', 'a', 'a', 'n', 'r']

June 16th

Checking for 'nan' (= Not A Number) in a mathematical calculation


>>> import math
>>> x=float('nan')
>>> math.isnan(x)
True
Alternatively, you can check x==x because a 'nan'' is not equal to anything including itself.

June 23rd

Commonly used protocol numbers ("Protocol" field in IPv4 header, "Next Header" in IPv6 header):

TCP port number description

Meeting/VoIP services and their default ports

Citrix/GoToMeeting:     1494, 1604, 1853, 8200 (in addition to 80, 443) 
BitTorrent:             6881-7000, 30301 
Windows Live Messenger: 6891-6900
GoogleTalk:             19294, 19295, 19302
Skype Default Protocol: 23399
Polycom server broadcast: 6771
Sony PlayStation RemotePlay: 9293, 9309
Xbox LIVE: 3074
Dropbox: 17500
TOR     9001 (default), 9030 (often used), 9050, 9051, 9150

Other default ports

tcp,udp/13               Daytime protocol
tcp/15                   netstat, Network Status 
tcp/21                   FTP
tcp,udp/22               SSH
tcp,udp/23               telnet
tcp,udp/24               Any private email system
tcp,udp/25,tcp/587,2525  SMTP
tcp,udp/35               Any private printer server
tcp,udp/42               Host Name Server (Nameserv)
tcp,udp/43,63            WhoIs
tcp,udp/66,150,156       SQL
tcp,udp/69               tftp, Trivial File Transfer
tcp,udp/71-74            Remote Job Service 
tcp,udp/79               Finger
tcp,udp/80               HTTP, Google QUIC protocol (UDP only)
tcp,udp/101              NIC Host Name Server
tcp,udp/109,2109         POP-2
tcp,udp/110,3110         POP-3
tcp,udp/115              sftp, Simple File Transfer Protocol
tcp,udp/118,156          SQL Services
tcp,udp/119              nntp, Network News Transfer Protocol
tcp,udp/137-139          NETBIOS
tcp,udp/143,2143         IMAP 
tcp,udp/161              SNMP, Simple Network Management Protocol 
tcp,udp/187              Application Communication Interface 
tcp,udp/194,529,6660-69  Internet Relay Chat (IRC)
tcp,udp/201-208          AppleTalk 
tcp,udp/211              Texas Instruments 914C/G Terminal 
tcp,udp/220,3220         IMAP-3
tcp,udp/241              Error Message servers
tcp,udp/244              Intel Business
tcp,udp/389              ldap, Lightweight Directory Access Protocol
tcp,udp/403              dcap
tcp,udp/443              https, http protocol over TLS/SSL, Google QUIC protocol (UDP only)
tcp,udp/445              SMB on local network, Microsoft-DS
tcp,udp/458              apple quick time
tcp,udp/464              kpasswd
tcp/465,2526             ssmtp, SMTP over SSL
tcp,udp/513              login, who
tcp,udp/514              Syslog, shell
tcp,udp/515              printer, spooler 
tcp,udp/519              unix time 
tcp,udp/525-526          timeserver
tcp,udp/531              conference, chat
tcp,udp/532              readnews
tcp,udp/533              For emergency broadcasts
tcp,udp/537              nmsp, Networked Media Streaming
tcp,udp/543              klogin
tcp,udp/554              rtsp, Real Time Streaming Protocol, QuickTime, AirPlay
tcp,udp/565              whoami
tcp/591                  (Microsoft) exchange servers HTTP
tcp,udp/593              (Microsoft) exchange servers HTTP
tcp,udp/636              ldaps, LDAP protocol over TLS/SSL
tcp,udp/689              nmap
tcp,udp/749-754,760      Kerberos
tcp/808                  Microsoft Net.TCP Port Sharing Service
tcp/829                  Certificate Management Protocol
tcp/843                  Adobe flash
tcp,udp/873              rsync 
tcp,udp/989-990          ftps, ftp over TLS/SSL
tcp,udp/992              telnets, telnet over TLS/SSL
tcp,udp/993              imaps/imap-4, IMAP over TLS/SSL
tcp,udp/994              ircs, IRC over SSL
tcp,udp/995              pop3s, POP-3 over TLS/SSL
tcp,udp/1194             OpenVPN
tcp,udp/1433-1434        Microsoft SQL server
tcp,udp/1500             VLSI License Manager
tcp,udp/1863             MSN Messenger
tcp,udp/1935             Flash media player 
tcp,udp/2401             CVS client/server
tcp/3306                 MySQL 
udp/3478-3497            FaceTime/iMessage
tcp/3689                 daap, iTunes Music Sharing, AirPlay
tcp,udp/3690             SVN, Subversion 
udp/4012                 Media link, Microsoft communication port
tcp/4282,4285            Mycrashplan/Code42 backup 
udp/4272                 Games on Windows
tcp,udp/5001             Yahoo videos, other video servers
tcp,udp/5109             AOL AIM, iChat, Apple Messages
tcp,udp/5222,5269        Jabber Client/Server
tcp/5223                 Apple Push Notification Service
tcp/5432                 PostgreSQL
tcp,udp/5984             couchDB
tcp,udp/6000,6001,6023   X11 Window system
tcp/7000-7001,7199,9160  Cassandra DB
udp/7300-7301            Cisco
tcp/7777                 iChat server, Oracle Cluster File System, Windows backdoor program
tcp/8000                 Splunk web-interface, Commonly used Internet radio streams
tcp,udp/8080             web cache
tcp/8170-8171            podcast
udp/8888                 fortinet, health checkup, other reports
udp/8899                 camera video stream
tcp/9418                 Git Version Control System
udp/16384-16472          rtp, FaceTime, Game Center, iChat AV
tcp,udp/17500            Dropbox LAN sync
udp/19302-19305          Google hangout 
tcp,udp/27017            mongoDB
udp/33001                Aspera large data transfer
tcp/42000-42999          iTunes Radio streams

June 24th

ASN numbers for some popular domains


   dropbox                 AS19679
   linkedin                AS197612
   Tencent                 AS132591, AS132203, AS58835
   YOUTUBE                 AS43515, AS36561, AS36040
   CITRIX                  AS21866, AS16815, AS43204
   FACEBOOK                AS32934
   Evernote                AS53635
   Salesforce              AS14340
   Microsoft               AS8075, AS3598, AS20046, AS13811, AS8068, AS8069, AS8072, AS6182, AS26222
   Microsoft XBOX          AS23468
   Cisco                   AS25949, AS22183, AS109
   Google US               AS36384, AS15169, AS22577, AS36492
   Google CH               AS41264
   Google IN               AS45566
   Amazon US               AS14618, AS16509
   Amazon JP               AS38895
   Amazon IE               AS39111
   SpotXchange             AS62693, AS11742, AS35220
   Sitecore                AS13354
   AT&T                    AS7018
   Yahoo     
             US            AS36229, AS10880, AS14678, AS26085, AS36647, AS26101, AS7233, AS36088, AS14196, AS7280, AS17110, AS5779, AS22565, AS36129, AS10310, AS36646, AS36752
             JP            AS2521, AS23926, AS23816, AS7488, AS24572, AS2554, AS4694
             GB            AS40986, AS15635, AS34010, AS43428, AS34082  
             KR            AS55416, AS38689, AS45502, AS10157
             HK            AS24018, AS55517, AS24236
             CH            AS42173
             TW            AS55417, AS24506
             IN            AS45915, AS45863, AS38072
             DE            AS15896
             SG            AS55418, AS45501
             CN            AS24376

To get list of IP subnets associated with an ASN

To fetch the list of IP subnets used by Facebook, run this command

   whois -h whois.radb.net '!gAS32934'
For better display, we can print each ip in a new line

  for ip in `whois -h whois.radb.net '!gAS32934' | grep /`; do echo $ip; done ;
The current list as of today is:
204.15.20.0/22
69.63.176.0/20
66.220.144.0/20
66.220.144.0/21
69.63.184.0/21
69.63.176.0/21
74.119.76.0/22
69.171.255.0/24
173.252.64.0/18
69.171.224.0/19
69.171.224.0/20
103.4.96.0/22
69.63.176.0/24
173.252.64.0/19
173.252.70.0/24
31.13.64.0/18
31.13.24.0/21
66.220.152.0/21
66.220.159.0/24
69.171.239.0/24
69.171.240.0/20
31.13.64.0/19
31.13.64.0/24
31.13.65.0/24
31.13.67.0/24
31.13.68.0/24
31.13.69.0/24
31.13.70.0/24
31.13.71.0/24
31.13.72.0/24
31.13.73.0/24
31.13.74.0/24
31.13.75.0/24
31.13.76.0/24
31.13.77.0/24
31.13.96.0/19
31.13.66.0/24
173.252.96.0/19
69.63.178.0/24
31.13.78.0/24
31.13.79.0/24
31.13.80.0/24
31.13.82.0/24
31.13.83.0/24
31.13.84.0/24
31.13.85.0/24
31.13.86.0/24
31.13.87.0/24
31.13.88.0/24
31.13.89.0/24
31.13.90.0/24
31.13.91.0/24
31.13.92.0/24
31.13.93.0/24
31.13.94.0/24
31.13.95.0/24
69.171.253.0/24
69.63.186.0/24
31.13.81.0/24
179.60.192.0/22
179.60.192.0/24
179.60.193.0/24
179.60.194.0/24
179.60.195.0/24
185.60.216.0/22
45.64.40.0/22
185.60.216.0/24
185.60.217.0/24
185.60.218.0/24
185.60.219.0/24
129.134.0.0/16
157.240.0.0/16
204.15.20.0/22
69.63.176.0/20
69.63.176.0/21
69.63.184.0/21
66.220.144.0/20
69.63.176.0/20

Go to May's log


Last modified: Wed Jun 24 16:44:51 PDT 2015