Skip to content

Instantly share code, notes, and snippets.

@t0d0r
t0d0r / redis.logrotate
Last active November 24, 2015 14:15
camplight
cat > /etc/logrotate.d/redis <<__EOF__
/var/log/redis/*.log {
weekly
rotate 10
copytruncate
delaycompress
compress
notifempty
missingok
}
@t0d0r
t0d0r / private.xml
Created October 15, 2015 01:50
Filco Multimedia Profile for Karabiner by t0d0r
<?xml version="1.0"?>
<root>
<item>
<name>Filco Multimedia Profile</name>
<!-- https://github.com/tekezo/Karabiner/blob/version_10.11.0/src/bridge/generator/keycode/data/KeyCode.data -->
<identifier>private.switch_profile</identifier>
<autogen>__KeyToKey__ KeyCode::PC_PRINTSCREEN, KeyCode::VK_CONSUMERKEY_MUSIC_PREV</autogen>
<autogen>__KeyToKey__ KeyCode::PC_SCROLLLOCK, KeyCode::VK_CONSUMERKEY_MUSIC_PLAY</autogen>
<autogen>__KeyToKey__ KeyCode::PC_PAUSE, KeyCode::VK_CONSUMERKEY_MUSIC_NEXT</autogen>
@t0d0r
t0d0r / gist:62b25ba39bd36c8a6bdd
Created September 17, 2015 12:14
ruby.ipaddr
require 'ipaddr'
ref_ip = IPAddr.new("255.0.0.1/8")
Ip.all.each { |ip|
puts [ ip.ip, ref_ip.to_s ].join(', ')
ip.update_attribute('reference_ip', ref_ip.to_s)
ref_ip = IPAddr.new(ref_ip.to_i + 1,Socket::AF_INET )
}; nil
@t0d0r
t0d0r / gridhour.ipfw.rb
Last active August 29, 2015 14:27
gridhour.ipfw.rb
start_rule=1000
1.upto(251) { |e|
puts "ipfw add %s pipe %s from any to 172.20.1.%s out xmit lan1" % [ start_rule, start_rule, e ]
puts "ipfw add %s pipe %s from 172.20.1.%s to any in recv lan1" % [ start_rule, start_rule, e ]
puts "ipfw pipe %s config bw 10Mbit/s" % [ start_rule ]
start_rule += 1
}
start_rule=2000
1.upto(251) { |e|
@t0d0r
t0d0r / mysql.grant
Last active August 29, 2015 14:26
mysql: show grants
data=<<__EOF__
127.0.0.1 | iptraf
127.0.0.1 | root
195.138.138.0/255.255.255.192 | iptraf
94.190.186.125 | statista
94.190.192.0/255.255.255.192 | iptraf
94.190.192.10 | gatekeeper
localhost | builder
localhost | callcenter
localhost | goonet
@t0d0r
t0d0r / tcv.ip2ip_old.rb
Last active August 29, 2015 14:11
tcv.mysql.real_ip
a = %w(
10.55.2.150 94.190.178.98
10.30.200.9 94.190.183.152/29
10.30.54.24 94.190.183.13
10.32.100.131 94.190.178.114
10.16.77.100 94.190.178.66)
a.each_slice(2) { |k,v|
puts "#{k} -> #{v}"
puts "update ip_list set ip = '#{v}', ip_old = '#{k}' where ip = '#{k}';"
/var/log/rsync-backupninja.log {
weekly
missingok
rotate 4
compress
delaycompress
notifempty
create 640 root adm
}
#!/usr/bin/env ruby
# encoding: utf-8
c = %w( 101 102 103 104 105 106 107 108 201 202 205 206 207 209 301 302 303 304
305 306 308 401 402 403 405 406 407 408 501 502 503 504 505 506 507 508 601 602
603 604 605 607 608 801 802 803 805 806 807 808 809 901 902 903 904 905 906 908
909 910 917 919 1001 1002 1003 1004 1005 1006 1009 1101 1102 1104 1105 1106
1107 1108 1109 1110 1111 1112 1201 1202 1203 1204 1205 1206 1301 1302 1303 1305
1306 1307 1308 1309 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1501 1502
1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1514 1515 1517 1518 1520 1523
@t0d0r
t0d0r / gist:6051774
Created July 22, 2013 06:52
hosts2ip.rb
#!/usr/bin/env ruby
# encoding: utf-8
# simple script to extract IP addresses for specific sites
# http://www.dkh.minfin.bg/bg/pubs/4/546
require 'socket'
hosts = <<__EOF__
www.bet365.com
#!/usr/bin/perl
use DBI;
use CGI;
use Sys::Hostname;
use warning;
use strict;
my $database = 'to be set';
my $dbserevr = 'server ip/host';
my $dbusername = 'username';