Skip to content

Instantly share code, notes, and snippets.

View spiculator's full-sized avatar

Sergey Redin spiculator

View GitHub Profile
#!/usr/bin/perl -w
use strict;
use Cwd 'abs_path';
sub usage() {
die "Usage: $0 [-f] [-l] [-v] <path>
-f unmount subdirectories even if <path> is not mounted
-l use lazy umount
-v verbose mode\n";}
@spiculator
spiculator / openfiles
Created May 29, 2015 14:43
List all open files sorted by size, including deleted files
#!/usr/bin/perl -w
use strict;
use Number::Bytes::Human qw/format_bytes/;
my $count = 30;
if( @ARGV ) {
die "Usage: $0 <count>\n" if @ARGV > 1;
$count = shift @ARGV;
die "bad count\n" unless $count =~ /^\d+/;
}
#!/usr/bin/perl -w
use strict;
use FindBin;
use Digest::MD5 qw/md5_hex/;
use Net::Whois::Raw;
use Storable qw/lock_retrieve lock_nstore/;
my $cache_file = "/var/tmp/domreg_sensor.cache";
my $default_whois_server = "whois.nic.ru";
my $cache_timeout = 6*60*60; # 6 hours
my $now = time;
@spiculator
spiculator / jail.patch
Created June 18, 2014 14:58
fix vulnarability in jail chroot tool
diff --git a/src/jail.c b/src/jail.c
index ecf0cb3..9b1da64 100644
--- a/src/jail.c
+++ b/src/jail.c
@@ -453,8 +453,14 @@ int main(int argc, char *argv[], char *env[]) {
// call the shell overriding current process space
//
- setgid(gid);
- setuid(uid);
@spiculator
spiculator / +.c
Created May 26, 2014 13:30
print command and run it (like `make` does)
#include <stdio.h>
int main(int argc, char **argv)
{
int i;
printf( "+" );
for( i = 1; i < argc; i++ )
printf( " %s", argv[i] );
printf( "\n" );
if( argc > 1 )
@spiculator
spiculator / 0_reuse_code.js
Created January 22, 2014 06:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
package main
import (
"fmt"
"math/big"
"os"
"strconv"
"time"
"unsafe"
)
package main
import "fmt"
import "code.google.com/p/go-tour/tree"
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
if t.Left != nil {
Walk( t.Left, ch )
#!/usr/bin/perl -w
use warnings;
my $i = 1;
my @in = <>;
while(@in) {
local $_;
$_ = shift @in or die;
s/^(\d+)(\r?)$/$i$2/ or die "number of line expected: $_";
@spiculator
spiculator / rsync-3.0.6-sleepflag.patch
Created June 12, 2013 08:25
make rsync sleep every 10 seconds
diff -Naur rsync-3.0.6/Makefile.in rsync-3.0.6-sleepflag/Makefile.in
--- rsync-3.0.6/Makefile.in 2009-04-11 03:24:49.000000000 +0400
+++ rsync-3.0.6-sleepflag/Makefile.in 2010-08-05 22:05:32.000000000 +0400
@@ -35,7 +35,7 @@
OBJS1=flist.o rsync.o generator.o receiver.o cleanup.o sender.o exclude.o \
util.o main.o checksum.o match.o syscall.o log.o backup.o
OBJS2=options.o io.o compat.o hlink.o token.o uidlist.o socket.o hashtable.o \
- fileio.o batch.o clientname.o chmod.o acls.o xattrs.o
+ fileio.o batch.o clientname.o chmod.o acls.o xattrs.o sleeper.o
OBJS3=progress.o pipe.o