Skip to content

Instantly share code, notes, and snippets.

@nl5887
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save nl5887/a3db77502b801a479e39 to your computer and use it in GitHub Desktop.

Select an option

Save nl5887/a3db77502b801a479e39 to your computer and use it in GitHub Desktop.
Dummy

Find recursively in all go files

find ~/Projects/ -name "*.go"|xargs ack UnmarshalJSON

Retrieve all emailaddresses from file, comma seperated

grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" /tmp/t2.txt|awk '{printf "$"$0"$,"}'

**Install brew formulas from file **

while read p; do brew install $p; done < /tmp/brew.txt

Split push using fish shell

git push --force heroku (bash git subtree split --prefix dist master):master

Find only files in GO

ack smtp ~/Projects/ --type=go

Firewall visualization

tcpdump -ttnql -i pflog0 'proto \tcp' or 'proto \udp' \
        | stdbuf -i0 -o0 -e0 /usr/local/bin/gawk -f 'tcpdump2gource.awk' \
        | gource --multi-sampling --no-vsync --title "pflog0 activity" --key \
          --realtime --highlight-users --highlight-dirs --user-friction 0.2 \
          --user-scale 0.8 --log-format custom --disable-auto-rotate -i 0 -
{
  timestamp=$1
  sip=$3;
  proto=$6;
  dip=substr($5, 1,length($5)-1);
  # direction=$4;
  type="";
  match(dip, /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/)
  dport=substr(dip,RLENGTH+2);
  gsub(".[0-9]*$","",timestamp);
  gsub(".[0-9]*$","",dip);
  network=dip;
  gsub(".[0-9]*$","",network);
  gsub(".[0-9]*$","",sip);
  printf("%s|%s|A|%s/%s.%s|#FF00ff\n",timestamp,sip,network,dip,dport);
  # fflush();
}

grep and patter match

cat check.txt |grep -E -o "message=\"(.*?)\""|sed -n -e "s/message=\"\(.*\)\"/\1/p"

Ralink RT3572

wget "http://www.mediatek.com/AmazonS3/Downloads/linux/DPO_RT5572_LinuxSTA_2.6.1.3_20121022.tar.bz2"

http://ubuntuforums.org/showthread.php?t=1630358

include/os/rt_linux.h

typedef struct _OS_FS_INFO_
{
        kuid_t                          fsuid;
        // int                          fsuid;
        kgid_t                          fsgid;
        // int                          fsgid;
        mm_segment_t    fs;
} OS_FS_INFO;

http://www.mediatek.com/AmazonS3/Downloads/linux/RT2870_Firmware_V22.zip /lib/firmware/

/

hexdump formatting

http://monzool.net/blog/2008/02/18/incomprehensive-hexdump-man-page/

cat /tmp/test.bin |hexdump -e '16/1 "0x%02x, "' -e '"\\n"'

Download Java

curl -LO -H "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8u40-b26/jdk-8u40-linux-x64.rpm"

Retrieve certificate using openssl

openssl s_client -showcerts -connect host:5222 -starttls xmpp
openssl s_client -showcerts -connect www.google.com:443

Clean exim queue

exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | sh
find . -mmin -$((60*24))

Gawk regex

sh /tmp/t.sh | sed "s/&apos;/&/g"|gawk 'match($0, /(([\d\w]+\.)?blue\w*\.ex)/, arr) {print arr[0]": "$0}'|sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment