Skip to content

Instantly share code, notes, and snippets.

server {
listen 443 http2 ssl;
server_name konesola.22.fi;
ssl_certificate /etc/letsencrypt/live/somedomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/somedomain.com/privkey.pem;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header X-XSS-Protection 0 always;
add_header X-Content-Type-Options nosniff always;
@pyh
pyh / README
Last active July 19, 2018 20:28
Some hacks that will map IPs to a map (with different colors). Verrrry sketchy, but "works".
"Instructions"
1) Install index.php to some webserver, and run "latlongudp.pl" on the same server.
2) Then feed IPs to the latlongudp.pl server with something like this:
tail -F /var/log/nginx/access_log|perl -e '$|=1;while(<>){print "someidentifier,$1\n" if/(\d+\.\d+\.\d+\.\d+)/}'|nc -u somenode.example.com 5001
Modify someidentifier to to fit your needs.
@pyh
pyh / backup.pl
Created January 14, 2013 15:24
Very high-tech glazier uploader. For large files you would need these 2 patches: https://rt.cpan.org/Public/Bug/Display.html?id=81219 and https://rt.cpan.org/Public/Bug/Display.html?id=81864
#!/usr/bin/perl
use strict;
use warnings;
use Net::Amazon::Glacier;
use File::Find;
use Digest::SHA qw/sha256_hex/;
use File::Slurp;
use Net::Amazon::TreeHash;
@pyh
pyh / delete-all-domain-files.pl
Created November 1, 2012 07:31
Removes a defined domain from MogileFS
#!/usr/bin/perl
# Efficient script to remove all files from MogileFS for defined domain
# Use with extreme caution...
use warnings;
use strict;
use MogileFS::Server;
MogileFS::Config->load_config;
@pyh
pyh / gist:3914461
Created October 18, 2012 20:02
MogileFS helper script that quickly drains selected hosts
#!/usr/bin/perl
# Efficient script to remove all files from some storage nodes
# Use with caution...
# Replicates status=="drain":
# UPDATE device SET status="drain" WHERE hostid IN(1,2,3,4) AND status="alive";
# file_to_queue:
#| fid | devid | type | nexttry | failcount | flags | arg |
@pyh
pyh / DeprioritizeHosts.pm
Created May 24, 2012 19:35
Deprioritize hosts mogilefs plugin
package MogileFS::Plugin::DeprioritizeHosts;
use strict;
use warnings;
our $VERSION = '0.01';
$VERSION = eval $VERSION;
use MogileFS::Util qw(error);
@pyh
pyh / nginx-mogilefsd-upstream.conf
Created April 20, 2012 21:24
Our mogilefs nginx configs
location /dev1 {
client_body_temp_path /var/mogdata/dev1;
}
location /dev2 {
client_body_temp_path /var/mogdata/dev2;
}
location /dev3 {
client_body_temp_path /var/mogdata/dev3;
}
location /dev4 {
@pyh
pyh / gist:1006876
Created June 3, 2011 18:25
rebalance crash
May 27 08:18:46 storage1 mogilefsd[6920]: [monitor(6941)] Timeout contacting 10.1.26.130 dev 28 (http://10.1.26.130:47074/dev28/usage): took 2.00 seconds out of 2 allowed
May 27 08:19:06 storage1 mogilefsd[6943]: crash log: No answer in 4 seconds from parent to child MogileFS::Worker::Fsck=HASH(0x24cb038) [6943], dying at /usr/local/share/perl/5.10.0/MogileFS/Worker.pm line 186.
May 27 08:19:06 storage1 mogilefsd[6925]: crash log: No answer in 4 seconds from parent to child MogileFS::Worker::Replicate=HASH(0x24b8690) [6925], dying at /usr/local/share/perl/5.10.0/MogileFS/Worker.pm line 186.
May 27 08:19:06 storage1 mogilefsd[6928]: crash log: No answer in 4 seconds from parent to child MogileFS::Worker::Replicate=HASH(0x130c0c0) [6928], dying at /usr/local/share/perl/5.10.0/MogileFS/Worker.pm line 186.
May 27 08:19:06 storage1 mogilefsd[6942]: crash log: No answer in 4 seconds from parent to child MogileFS::Worker::JobMaster=HASH(0x24cae88) [6942], dying at /usr/local/share/perl/5.10.0/MogileFS/Worker.pm li
@pyh
pyh / nginx.conf
Created May 25, 2011 19:17
nginx config
worker_processes 1;
error_log /var/log/nginx/error.log notice;
events {
worker_connections 1024;
}
http {
include mime.types;