Skip to content

Instantly share code, notes, and snippets.

@mdpuma
mdpuma / .lftprc
Last active August 10, 2018 06:34
lftp optimal settings
set ftp:list-options '-a'
set ftp:ssl-allow false
@mdpuma
mdpuma / gist1.sh
Created November 9, 2017 19:21
get_drive_temp.sh
#!/bin/bash
raid=cciss
maxdisks=7
for i in {0..7}; do
temp=$(smartctl -a -d $raid,$i /dev/sda | grep "Current Drive Temperature:" | awk -F: '{ print $2}')
[ -z "$temp" ] && temp=$(smartctl -a -d $raid,$i /dev/sda | grep "Temperature_Celsius" | grep -oE "[0-9]+" | xargs | cut -d ' ' -f7);
[ -n "$temp" ] && echo slot $i: $temp;
done
@mdpuma
mdpuma / gist:082c06fea56dbeccec1453553f7376c0
Created November 9, 2017 19:18
Cisco model description
# this may be possible mistakes
WS-C2960-24TT-L
WS-C2960-24LC
WS-C2960j-mmnnn-o
j = is gigabit or not
G - gigabit ethernets
@mdpuma
mdpuma / gist:49ee0e1938ff887c2c299cf076dd755a
Created October 14, 2017 17:55
tcpdump filter traffic by vlan (live)
#!/bin/bash
# reference https://serverfault.com/questions/544651/vlan-tags-not-shown-in-packet-capture-linux-via-tcpdump
tcpdump -i eth0 -Uw - arp | tcpdump -en -r - vlan 804
@mdpuma
mdpuma / firefox
Created September 23, 2017 10:27
Intel GPU screen tearing fix
To check if OpenGL OMTC is enabled, go to about:support and under the "Graphics" section look for "GPU Accelerated Windows". If it reports "0/1 Basic (OMTC)" (possibly 0/2), OpenGL OMTC is disabled; if it reports "1/1 OpenGL (OMTC)" (possibly 1/2 or 2/2) it is enabled.
To enable OpenGL OMTC go to about:config and set:
layers.acceleration.force-enabled true
layers.offmainthreadcomposition.enabled true (default)
Restart Firefox for changes to take effect.
@mdpuma
mdpuma / kill_long_queries.sh
Created June 4, 2017 09:41 — forked from julcap/kill_long_queries.sh
Kill long MySQL queries
##################################################
# Kill long queries #
# This shell script will kill queries that have #
# passed the $MAX execution time. #
# Julian Capilla-krumbak #
# lyhan_jr@hotmail.com #
# 21-05-2014 #
##################################################
#!/bin/bash
@mdpuma
mdpuma / lftp.conf
Last active May 26, 2017 04:42 — forked from fxthomas/lftp.conf
Lftp Configuration & mirror including all dot/hidden files
## some useful aliases
alias ls "ls -h"
alias dir ls
alias less more
alias zless zmore
alias bzless bzmore
alias mirror "mirror -v"
alias sync "mirror -R -v -n"
alias reconnect "close; cache flush; cd ."
alias edit "eval -f \"get $0 -o ~/.lftp/edit.tmp.$$ && shell \\\"cp -p ~/.lftp/edit.tmp.$$ ~/.lftp/edit.tmp.$$.orig && $EDITOR ~/.lftp/edit.tmp.$$ && test ~/.lftp/edit.tmp.$$ -nt ~/.lftp/edit.tmp.$$.orig\\\" && put ~/.lftp/edit.tmp.$$ -o $0; shell rm -f ~/.lftp/edit.tmp.$$*\""
@mdpuma
mdpuma / extensions.lua
Created May 11, 2017 18:02 — forked from igmar/extensions.lua
Asterisk LUA dialplan
require("lsqlite3")
-- Igmar: Wanneer closen we dat DB object eigenlijk ?
db = sqlite3.open('/etc/asterisk/users.sqlite')
--CONSOLE = "Console/dsp" -- Console interface for demo
--CONSOLE = "DAHDI/1"
--CONSOLE = "Phone/phone0"
TRUNK = "DAHDI/G1"
@mdpuma
mdpuma / kill_long_mysql_queries.sh
Created April 18, 2017 18:16
kill_long_mysql_queries.sh
#!/bin/bash
IFS='|'
# Id | User | Host | db | Command | Time | State | Info | Progress
mysqladmin pr | sed -E 's/\s+//g' | grep -v '\-\-\-' | grep -vi Time | while read -r id1 id user host db command time state info progress; do
[ -z "$time" ] && continue;
[ "$command" = "Sleep" ] && continue;
if [ "$time" -gt 300 ]; then
mysql -e "kill $id"
echo "killing $id ($db) $info"
@mdpuma
mdpuma / CentOS.txt
Created February 5, 2017 15:49
Different configuration of ip addresses on distros
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="static"
HWADDR="00:26:6C:F3:11:A8" # match network interface by mac address
ONBOOT="yes"
TYPE="Ethernet"
IPADDR=XXX.XXX.XXX.XXX
PREFIX=24
GATEWAY=XXX.XXX.XXX.XXX
DNS1=8.8.8.8