Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / flock.py
Last active August 29, 2015 14:03
A file locker that uses the context manager.
import fcntl
class FileLock:
def __init__(self, filename, lock_type):
self.fh = open(filename, "a")
self.lock_type = lock_type
def __enter__(self):
print "Acquiring lock"
@labeneator
labeneator / lsof.output
Created July 8, 2014 12:01
File locking status according to lsof
Tue Jul 8 11:51:18 UTC 2014
Tue Jul 8 11:51:20 UTC 2014
Tue Jul 8 11:51:22 UTC 2014
Tue Jul 8 11:51:24 UTC 2014
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 822 vagrant 3w REG 254,0 0 1973047 /tmp/some_lock_file
python 823 vagrant 3w REG 254,0 0 1973047 /tmp/some_lock_file
@labeneator
labeneator / process_start.out
Created July 8, 2014 12:01
Processes pids and lock acquisition status
Starting process 1
Starting process 2
Starting process 3
Starting process 4
Starting process 5
@labeneator
labeneator / debianise_and_build_a_venv_package.sh
Created July 22, 2014 09:20
How to generate and build a .deb package for python virtualenv projects
#!/bin/sh
# Variables
PKG_NAME=SomeCompany-python-api
PKG_VERSION=0.1
[email protected]
export DEBFULLNAME="Laban Mwangi"
PKG_NAME_VERSION=${PKG_NAME}-${PKG_VERSION}
PKG_SCRIPT_NAME=$(echo $PKG_NAME | sed -e "s/-/_/g")
@labeneator
labeneator / .zshrc
Last active August 29, 2015 14:08
.zshrc
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <[email protected]>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
@labeneator
labeneator / xpilot-server_clang_return_bool.patch
Last active August 29, 2015 14:08
Patch to enable xpilot to build on osx
diff --git a/src/server/suibotdef.c b/src/server/suibotdef.c
index 494f73f..d5202e3 100644
--- a/src/server/suibotdef.c
+++ b/src/server/suibotdef.c
@@ -405,7 +405,7 @@ static bool Get_object_proximity(player_t *pl, object_t *shot, double sqmaxdist,
/* ignore if there is enough time to deal with this object later */
if((time_until_closest < 0) || (time_until_closest > maxtime))
/*option instead of fixed value: options.dodgetime))*/
+ return false;
- return;
@labeneator
labeneator / gist:b5c7ee96192d3e4be61c
Created October 2, 2015 07:17
curling el_capitan || How do grab the pkg from Apple's CDN servers
1. Locate the storedownload process
ps aux |grep storedown
user 494 12.3 0.2 3597016 19724 ?? S 21Sep15 31:14.11 /System/Library/PrivateFrameworks/CommerceKit.framework/Versions/A/Resources/storedownloadd
2. Attach dtruss to the storedownloader process
sudo dtruss -p 494 2>&1 | tee storedownload
3. Start the download on the appstore application
4. Inspect the storedownload process using lsof to figure out the remote endpoints
@labeneator
labeneator / confirm.xml
Last active March 16, 2017 13:43
1. Save confirm xml somewhere
<?xml version="1.0" encoding="utf-8" ?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><ns1:C2BPaymentConfirmationRequest xmlns:ns1="http://cps.huawei.com/cpsinterface/c2bpayment"><TransType>PayBill</TransType><TransID>12655422469971</TransID><TransTime>20140227082020</TransTime><TransAmount>123.00</TransAmount><BusinessShortCode>777126</BusinessShortCode><BillRefNumber>TX1001</BillRefNumber><InvoiceNumber>X334343</InvoiceNumber><OrgAccountBalance>12345.00</OrgAccountBalance><ThirdPartyTransID>1234560000088888</ThirdPartyTransID><MSISDN>0722703615</MSISDN><KYCInfo><KYCName>[Personal Details][First Name]</KYCName><KYCValue>Hoiyor</KYCValue></KYCInfo><KYCInfo><KYCName>[Personal Details][Middle Name]</KYCName><KYCValue>G</KYCValue></KYCInfo><KYCInfo><KYCName>[Personal Details][Last Name]</KYCName><KYCValue>Chen</KYCValue></KYCInfo></ns1:C2BPaymentConfirmationRequest></soapenv:Body></soapenv:Envelope>