Skip to content

Instantly share code, notes, and snippets.

@labeneator
labeneator / gist:227f3f496afb27a7175c
Created June 3, 2014 14:05
Vagrant uses Chef 10.14.2 which breaks horribly on encountering use_inline_resources
 lmwangi  ~  work  someproject  virts  vagrant provision
/Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.6.2/lib/vagrant/pre-rubygems.rb:31: warning: Insecure world writable dir /usr/local in PATH, mode 040777
/Applications/Vagrant/embedded/gems/gems/bundler-1.6.2/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /usr/local in PATH, mode 040777
==> default: Running provisioner: chef_solo...
Generating chef JSON and uploading...
1 def why_run_supported?
==> default: Running chef-solo...
@labeneator
labeneator / ps_to_pdf_content_protected_pdfs.sh
Last active March 20, 2021 12:47
Getting around Adobe's document protection schemes
############ Adobe badness #############
# In your operating system, create a postscript printer whose address is 127.0.0.1
# Fake a postscript printer using netcat
$ nc -l 127.0.0.1 9100 > printout.ps
# Print your pdf using Adobe Reader to the postscript printer on 127.0.0.1
# Netcat will diligently dump the printout to printout.ps as a postscript file
@labeneator
labeneator / tcp_conversations.sh
Created April 16, 2014 11:31
Summary of TCP conversations in a pcap
# Viewing the tcp conversations in a pcap
tshark -qn -z conv,tcp -r test.pcap
================================================================================
TCP Conversations
Filter:<No Filter>
| <- | | -> | | Total | Relative | Duration |
| Frames Bytes | | Frames Bytes | | Frames Bytes | Start | |
a.b.c.d:31822 <-> e.f.g.h:9999 553 91298 549 36234 1102 127532 0.000000000 5155.6751
a.b.c.d:8645 <-> e.f.g.h:9999 402 66141 402 28210 804 94351 5162.869498000 3715.2102
# First 10 packets of the second TCP stream in the pcap
# Comman separated values with a header for the specified fields
$ tshark -ntu -r test.pcap -Y tcp.stream==1 -c 10 \
-E header=y -Tfields -E separator="," \
-e ip.src \
-e tcp.srcport \
-e "ip.dst" \
-e tcp.dstport \
-e tcp.flags.syn \
-e tcp.flags.ack \
@labeneator
labeneator / buddyinfo.py
Created March 15, 2014 21:38
Pretty prints /proc/buddyinfo
#!/usr/bin/env python
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 textwidth=79 autoindent
"""
Python source code
Last modified: 15 Feb 2014 - 13:38
Last author: lmwangi at gmail com
Displays the available memory fragments
by querying /proc/buddyinfo
@labeneator
labeneator / buddyinfo parsed output
Created March 15, 2014 21:35
Buddyinfo parsed output
2014-03-15 23:34:32,352 - main - INFO - Starting....
2014-03-15 23:34:32,352 - main - INFO - Parsed options: {'size': None}
<logging.Logger object at 0x1102cffd0>
2014-03-15 23:34:32,352 - main - DEBUG - Parsing line: Node 0, zone DMA 5 4 4 4 4 3 2 0 0 0 2
2014-03-15 23:34:32,353 - main - DEBUG - Parsed line: {'numa_node': '0', 'zone': 'DMA', 'nr_free': '5 4 4 4 4 3 2 0 0 0 2'}
2014-03-15 23:34:32,353 - main - DEBUG - Parsing line: Node 0, zone DMA32 2 2 3 2 2 1 3 1 2 3 386
2014-03-15 23:34:32,353 - main - DEBUG - Parsed line: {'numa_node': '0', 'zone': 'DMA32', 'nr_free': '2 2 3 2 2 1 3 1 2 3 386'}
2014-03-15 23:34:32,353 - main - DEBUG - Parsing line: Node 0, zone Normal 56332 12573 2212 959 448 179 35 5 0 0 35002
2014-03-15 23:34:32,353 - main - DEBUG - Parsed l
@labeneator
labeneator / gist:9574151
Created March 15, 2014 21:30
alloc failure
swapper: page allocation failure. order:4, mode:0x20
Pid: 0, comm: swapper Not tainted 2.6.32-gentoo-r7 #1
Call Trace:
<IRQ> [<ffffffff8107f082>] 0xffffffff8107f082
[<ffffffff810a29a4>] 0xffffffff810a29a4
[<ffffffff810a2b9f>] 0xffffffff810a2b9f
[<ffffffff810a2d35>] 0xffffffff810a2d35
[<ffffffff810a2de3>] 0xffffffff810a2de3
[<ffffffff810a2e4e>] 0xffffffff810a2e4e
[<ffffffff813ed961>] 0xffffffff813ed961
@labeneator
labeneator / open_dummy_pipe.py
Last active January 4, 2016 20:59
Dummy writer prevents a fifo from sending EOFs to all readers when the real writer exits.
while True:
self.logger.info("[Re]starting to read %s" % self.input_file)
with open(self.input_file, "rb") as f:
f1 = open (fname, "w") # The dummy writer has to be opened after a reader, otherwise it would block
for line in f:
...do_stuff_with_line...(line)
# Pre-create the fifo
# mkfifo /tmp/example_fifo
# Save this to a file and strace it
# strace -fttt -o open_close python test.py
import time
fname = "/tmp/example_fifo"
with open(fname, "r") as f:
@labeneator
labeneator / broken_pipe_persistent_reader.py
Created January 28, 2014 22:11
This will fail to read a FIFO if writers disappear
while True:
self.logger.info("[Re]starting to read %s" % self.input_file)
with open(self.input_file, "rb") as f:
for line in f:
...do_stuff_with_line...(line)