Skip to content

Instantly share code, notes, and snippets.

[alex@zmachine python]$ python longurl.py https://t.co/3NFnfJF9am
Code: 301 current URL: https://t.co/3NFnfJF9am Iteration: 1
Code: 301 current URL: http://ow.ly/GgAd30a0r3G Iteration: 2
Code: 301 current URL: https://www.foreignaffairs.com/articles/northern-europe/2017-03-15/natos-northern-alliance?cid=int-lea&pgtype=hpg Iteration: 3
Code: 301 current URL: https://foreignaffairs.com/articles/northern-europe/2017-03-15/natos-northern-alliance Iteration: 4
Code: 301 current URL: https://foreignaffairs.com/articles/northern-europe/2017-03-15/natos-northern-alliance Iteration: 5
https://foreignaffairs.com/articles/northern-europe/2017-03-15/natos-northern-alliance
@yalla
yalla / longurl.py
Created March 17, 2017 18:55
Unshorten URLs, no matter how deep the rabbit hole goes.
import sys
import httplib
import urlparse
# maximum redirects to avoid loops; can't be arsed to build a graph
# and check for cycles.
maxredir = 10
# the orig variable is used to check if the last redirect results in the same
# URL. I've seen sites serving the actual real URL, but still give a 30x
simuruns <- 5000;
diameter <- rnorm(simuruns, mean=0.8, sd=0.003);
strokelength <- rnorm(simuruns, mean=2.5, sd=0.15);
rpm <- 9.5;
desired_mean <- 12;
desired_sd <- 0.2;
simulation <- pi*(diameter/2)^2 * strokelength * rpm;
par(mfrow=c(2,1));
hist(simulation, breaks=100);
@yalla
yalla / gist:bcc25378c076d06d9bdb
Created June 13, 2015 08:48
New valgrind for yalla/stripe
[alex@zmachine stripe]$ valgrind --leak-check=full ./stripe -r ~/Downloads/gtp-u.pcap -w foo.bla
==23267== Memcheck, a memory error detector
==23267== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==23267== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==23267== Command: ./stripe -r /home/alex/Downloads/gtp-u.pcap -w foo.bla
==23267==
Reassembling...
Decapsulating...
@yalla
yalla / gist:72b740a73e13d15cef32
Last active August 29, 2015 14:23
Old valrgind for theclam/stripe
[alex@zmachine stripe]$ valgrind --leak-check=full ./stripe -r ~/Downloads/gtp-u.pcap -w foo.bla
==23053== Memcheck, a memory error detector
==23053== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==23053== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==23053== Command: ./stripe -r /home/alex/Downloads/gtp-u.pcap -w foo.bla
==23053==
Reassembling...
Decapsulating...
@yalla
yalla / evtest.out
Created January 6, 2015 06:19
Output of evtest
$ evtest
No device specified, trying to scan all of /dev/input/event*
Not running as root, no devices may be available.
Available devices:
/dev/input/event0: Sleep Button
/dev/input/event1: Lid Switch
/dev/input/event2: Power Button
/dev/input/event3: AT Translated Set 2 keyboard
/dev/input/event4: PS/2 Generic Mouse
/dev/input/event5: SynPS/2 Synaptics TouchPad
@yalla
yalla / input.xml
Created January 6, 2015 06:06
Supertuxkart input.xml for #1879
<input version="1">
<keyboard enabled="true">
<action name="steerLeft" id="37" event="1" character="0" />
<action name="steerRight" id="39" event="1" character="0" />
<action name="accel" id="38" event="1" character="0" />
<action name="brake" id="40" event="1" character="0" />
<action name="nitro" id="78" event="1" character="0" />
<action name="drift" id="86" event="1" character="0" />
<action name="rescue" id="8" event="1" character="0" />
@yalla
yalla / stk-code-debug.diff
Created January 5, 2015 06:44
STK patch for debugging Xbox 360 controller woes
diff --git a/src/input/device_manager.cpp b/src/input/device_manager.cpp
index 2f884ad..755b81f 100644
--- a/src/input/device_manager.cpp
+++ b/src/input/device_manager.cpp
@@ -184,14 +184,21 @@ void DeviceManager::setAssignMode(const PlayerAssignMode assignMode)
GamePadDevice* DeviceManager::getGamePadFromIrrID(const int id)
{
const int count = m_gamepads.size();
+
+ Log::info("DeviceManager::getGamePadFromIrrID", "id = %i", id);
@yalla
yalla / nintendo_dns.lua
Created December 7, 2012 19:26
tshark lua script to create firewall rules from DNS inspection. Run with tshark -n -i $if -X lua_script:nintendo_dns.lua
-- filterstring
local _filter = '(udp.port == 53) && (dns.count.answers >= 1)'
-- Whiteliste containing alowed RRs (doesn't work yet)
local _whitelist = {"nintendo\..+$", "nintendowifi.net$"}
-- register dns.qry.name and dns.resp.addr
qryname = Field.new("dns.qry.name")
ipaddr = Field.new("dns.resp.addr")
-- Create listener
@yalla
yalla / gist:3160485
Created July 22, 2012 17:47
gnuradio compile errors during gr-uhd
Scanning dependencies of target _uhd_swig
[ 89%] Building CXX object gr-uhd/swig/CMakeFiles/_uhd_swig.dir/uhd_swigPYTHON_wrap.cxx.o
Linking CXX shared module _uhd_swig.so
Undefined symbols for architecture x86_64:
"uhd::get_version_string()", referenced from:
__wrap_get_version_string in uhd_swigPYTHON_wrap.cxx.o
get_version_string() in uhd_swigPYTHON_wrap.cxx.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [gr-uhd/swig/_uhd_swig.so] Error 1