Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am d0x on github.
  • I am d0x (https://keybase.io/d0x) on keybase.
  • I have a public key ASAFQZR4Nmbv2Pv-092pVsZXxcb6TSsvKhtc6ysKPRD1HAo

To claim this, I am signing this object:

@d0x
d0x / readCsvInBash.sh
Created October 7, 2015 07:20
Read a CSV from Bash
#!/bin/bash
echo "a,b,c" > test.csv
echo "d,e,f" >> test.csv
OIFS=$IFS
IFS=, #notice: this is your field separator
while read var1 var2 var3
do
@d0x
d0x / MongoDb Profiling
Created June 22, 2015 09:53
Log every mongodb query
db.getProfilingLevel()
db.setProfilingLevel(2) // enables a log for every query
db.system.profile.find().limit(10).sort( { ts : -1 } ).pretty()
@d0x
d0x / Test whether a port is open
Created March 12, 2015 14:16
Test whether a port is open
nc -z -w5 8.8.8.8 53; echo $? #1=failure 0=success
@d0x
d0x / Secure Mongo with IPTables
Last active August 29, 2015 14:16
Secure MongoDB to access it from own IPAdress using IPTables
#as root
apt-get install iptables-persistent -y
iptables -F #Clears most IPTables entries
iptables -A INPUT -p tcp --dport 27017 -s localhost -j ACCEPT
iptables -A INPUT -p tcp --dport 27017 -s 134.3.208.8 -j ACCEPT
iptables -A INPUT -p tcp --dport 27017 -j DROP
iptables-save > /etc/iptables/rules.v4