Skip to content

Instantly share code, notes, and snippets.

View m0n5t3r's full-sized avatar

Sabin Iacob m0n5t3r

  • in the intertubes
View GitHub Profile
@m0n5t3r
m0n5t3r / fuscribd.js
Created August 2, 2014 06:07
Greasemonkey script to unfuckup Scribd docs
// ==UserScript==
// @name FUScribd
// @namespace m0n5t3r
// @description Makes Scribd documents visible, gives Scribd the finger.
// @include http://www.scribd.com/doc/*
// @version 1
// @grant none
// ==/UserScript==
(function(){
var docs = document.querySelectorAll('div.text_layer'),
@m0n5t3r
m0n5t3r / varnishgrep
Last active August 29, 2015 14:09
Filter varnishlog output and only display those requests that match a regexp pattern; match is against the whole text, not on indivicual fields; requires gawk (Debian derivatives seem to hate gawk, it's not installed by default)
#!/bin/bash
# Copyright: 2014 Sabin Iacob
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
@m0n5t3r
m0n5t3r / screw-flickr-bar.js
Created June 21, 2015 15:21
Remove yahoo bar from Flickr (userscript)
// ==UserScript==
// @id www.flickr.com-3076e643-50f4-42bd-b472-0d5cefff426e@scriptish
// @name Fuck Yahoo Menu Bar
// @version 1.0
// @namespace flickr
// @author m0n5t3r
// @description Remove purple yahoo bar fron flickr
// @include https://www.flickr.com/*
// @run-at document-load
// ==/UserScript==
@m0n5t3r
m0n5t3r / lsfd.sh
Created August 10, 2015 14:37
find file descriptors of cached Flash videos
#!/bin/bash
proc=$(ps ax | awk '/flashplayer/{ if($5 != "awk") { print $1; }}')
[ -z "$proc" ] && exit 0
for p in $proc; do
flash=$(ls -al /proc/$p/fd | grep FlashX)
if [ -n "$flash" ]; then
@m0n5t3r
m0n5t3r / test_custom_baudrate.cpp
Last active September 20, 2015 18:42
Simpler way to do weird baud rate setting in C(++) on (whatever has asm/termbits.h - most likely just Linux) than the (non-working) method recommended by Stuck Overflow
/*
lifted from python's serial.serialposix.set_special_baudrate and made to look like C
compile with `g++ -o test_custom_baudrate test_custom_baudrate.cpp`
using 250000 to test because 3D printing people seem to love it
*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
@m0n5t3r
m0n5t3r / 6cfg.daemon
Created February 11, 2011 20:28
dynamically set up ipv6 for a 2-router dmz with openwrt
#!/bin/sh
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
radvdump | awk '/Router Advertisement/{router=$NF}; /interface eth0\.2/{good_if=1}; /interface br-lan/{good_if=0}; /prefix/{if(good_if && $1 == "prefix"){print router" "$2}}' | while read router prefix; do
old_prefix=$(uci -q get "radvd.@prefix[0].prefix")
new_prefix=$(echo $prefix | sed -e 's@1::1\?/64$@2::/64@g')
lan_addr=$(echo $prefix | sed -e 's@1::1/64$@2::1/64@g')
new_addr=$(echo $prefix | sed -e 's@1::1/64$@1::2/64@g')
@m0n5t3r
m0n5t3r / getlink.py
Last active September 26, 2015 13:07
read URLs encoded as QR codes, open browser; Linux, of course; needs opencv, pygame (for display), zbar for actual decoding
@m0n5t3r
m0n5t3r / 02vpn
Created September 9, 2011 10:27
Start a VPN on connection, don't allow any connections before it if the VPN is supposed to be a default gateway; save as /etc/NetworkManager/dispatcher.d/02vpn
#!/bin/sh -e
if [ -z "$1" ]; then
echo "$0: called with no interface" 1>&2
exit 1;
fi
if [ "$2" != "up" ]; then
exit 0
fi
@m0n5t3r
m0n5t3r / config.yml
Created May 11, 2012 18:46
flexget config for automatically downloading Raspberry pi Linux images
feeds:
raspi:
interval: 24 hours
html:
url: http://www.raspberrypi.org/downloads
links_re:
- http://downloads\.raspberrypi\.org/images/.+\.torrent
regexp:
accept:
@m0n5t3r
m0n5t3r / truncate_logs.sh
Created February 19, 2013 12:00
Magento log cleanup
echo "dataflow_batch_export
dataflow_batch_import
log_customer
log_quote
log_summary
log_summary_type
log_url
log_url_info
log_visitor
log_visitor_info