Skip to content

Instantly share code, notes, and snippets.

View benoitjpnet's full-sized avatar
🇯🇵
Working from home

Benoit benoitjpnet

🇯🇵
Working from home
View GitHub Profile
#!/bin/sh
# Simple Twitter backup script
date=$(date +'%Y-%m-%d')
t timeline @benpro82 --csv --number 3000 > tweets-$date.csv
t retweets --csv --number 3000 > retweets-$date.csv
t favorites --csv --number 3000 > favorites-$date.csv
t direct_messages --csv --number 3000 > dm_received-$date.csv
t direct_messages_sent --csv --number 3000 > dm_sent-$date.csv
@benoitjpnet
benoitjpnet / mailquserid.sh
Last active December 16, 2015 10:19
Find userid of mails in mailq.
for i in $(mailq | grep -Eo [A-F0-9]{10} | tr -s '\n' ' '); do postcat -q $i | grep userid | grep -Eo "[0-9]{4,}" >> tmp/userid; done
sort -n /tmp/userid | uniq
@benoitjpnet
benoitjpnet / sensors.sh
Created April 16, 2013 09:37
Check temperature of CPU and send mail if critical threshold is reached.
#!/bin/sh
[email protected]
subject="Warning: Temperature critical"
critical=50
temperature=$(sensors -u coretemp-isa-0000 | grep temp2_input | grep -Eo "[0-9.]{2,}")
calc=$(echo "$temperature >= $critical" | bc)
if (( $calc )); then
echo -e "Attention, la température du processeur de la machine samba a dépassé le seuil\nde $critical °C ! Elle est actuellement de $temperature °C.\n\nVérifiez la climatisation de la salle serveur." | mail -s "$subject" "$mailto"
fi
@benoitjpnet
benoitjpnet / gist:5239535
Created March 25, 2013 18:47
Rapid test of compressing algorithms
tar -cavf BENPRO_USB_BTS_LP.tar.lzo BENPRO_USB 1,17s user 1,31s system 36% cpu 6,817 total
440M 25 mars 19:37 BENPRO_USB_BTS_LP.tar.lzo
tar -cavf BENPRO_USB_BTS_LP.tar.gz BENPRO_USB 26,02s user 1,41s system 95% cpu 28,826 total
401M 25 mars 19:39 BENPRO_USB_BTS_LP.tar.gz
tar -cavf BENPRO_USB_BTS_LP.tar.xz BENPRO_USB 272,47s user 2,83s system 100% cpu 4:34,75 total
314M 25 mars 19:44 BENPRO_USB_BTS_LP.tar.xz
tar -cavf BENPRO_USB_BTS_LP.tar.bz2 BENPRO_USB 96,16s user 1,97s system 99% cpu 1:38,66 total
#!/bin/bash
# From https://anothersysadmin.wordpress.com/2008/10/29/kill-every-mysql-select-older-than-x-seconds/
SEC=$1
IFS='|'
if [[ $SEC -lt 1 ]]; then
echo "Usage: $0 SECONDS"
exit 1
fi
mysqladmin proc -v|grep Query|grep -Evi "delete|update|insert|alter table" |while read dummy qid qusr qhost qdb qstat qsec qstat2 query; do
if [ $qsec -gt $SEC ]; then
@benoitjpnet
benoitjpnet / contact_mails
Last active December 14, 2015 07:09
List of contacts when sending a mail for technical purpose on a domain which doesn't announce their technical contacts in a whois.
abuse@<domain>, admin@<domain>, administrator@<domain>, contact@<domain>, info@<domain>, postmaster@<domain>, support@<domain>, webmaster@<domain>
@benoitjpnet
benoitjpnet / scriptusold.sh
Created February 2, 2013 15:36
Scriptus was an old script to automatically add into a webiste Japanese OSTs uploaded/released by Nipponsei group.
#!/bin/sh
#Upload auto for animesost
#benrpo - 27-08-08
#Variables
ftp_user=""
ftp_password=""
ftp_host="animesost.info"
http_user=""
http_pass=""
@benoitjpnet
benoitjpnet / scriptus.sh
Created February 2, 2013 15:33
Scriptus was an old script to automatically add into a webiste Japanese OSTs uploaded/released by Nipponsei group.
#!/bin/bash
####################
#SCRIPTUS #
#Version 2.0a #
#By Benpro #
#[email protected]#
#www.benprobox.fr #
#Date : 27/07/09 #
####################
#!/bin/bash
#Script de connection automatique au réseau wifi et au portail captif de l'université
#de Nancy-Metz
#Start 28/09/10
#Last edit : 5/10/10
#Last Comment : Ajout de la libnotify pour envoyer de msg.
#Révision : stable
#Version : 1.2
#Var
@benoitjpnet
benoitjpnet / .tmux.conf
Last active October 13, 2015 06:57
Tmux Configuration
# Use vi style when copy-paste mode.
set-window-option -g mode-keys vi
# Use ZSH by default
set-option -g default-shell /bin/zsh
# Map alt keys + direction keys for switching pane.
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Active monitoring