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 / accesslog_collector.sh
Last active December 15, 2015 21:09
nginx access log collector for graphite; parses a slightly modified "combined" format (`$request_time` added at the end) and pushes 30 second counts and request time averages via UDP, using the line protocol; needs an awk that has mktime (like gawk)
#!/bin/bash
#
# Copyright 2013 Sabin Iacob <iacobs@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@m0n5t3r
m0n5t3r / send-alert
Created June 20, 2013 20:08
bti replacement, because Twittre decided to shut down API version 1.0 and break clients...
#!/usr/bin/env python
import sys
import requests
from requests_oauthlib import OAuth1
if __name__ == '__main__':
consumer_key = '...'
consumer_secret = '...'
access_token_key = '...'
@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 / setup.sh
Last active December 16, 2015 07:50
script to install Magento-related essentials on Ubuntu 14.04 servers without puppet
#!/bin/bash
# percona repo
echo 'deb http://repo.percona.com/apt trusty main
deb-src http://repo.percona.com/apt trusty main
' > /etc/apt/sources.list.d/percona.list
apt-key adv --keyserver pool.sks-keyservers.net --recv-keys 1C4CBDCDCD2EFD2A
@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 / dbus-wrapper
Last active January 7, 2016 11:16
Script that pings Skype for Linux over DBus and alerts you if it's dead (it tends to just become unresponsive, not crash outright); intended to be run from cron every 5 minutes or so
#!/bin/bash
eval $(tr '\0' '\n' </proc/$(pidof gvfsd)/environ | grep DBUS_SESSION_BUS_ADDRESS)
eval $(tr '\0' '\n' </proc/$(pidof gvfsd)/environ | grep DISPLAY)
export DISPLAY DBUS_SESSION_BUS_ADDRESS
exec $*
@m0n5t3r
m0n5t3r / Configuration.h
Created December 8, 2015 06:38
Electron3d / MKS Base 1.3 Marlin configuration
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include "boards.h"
#include "macros.h"
//===========================================================================
//============================= Getting Started =============================
//===========================================================================
/*