Skip to content

Instantly share code, notes, and snippets.

View fedir's full-sized avatar
🌤️
The sun is behind every cloud

Fedir RYKHTIK fedir

🌤️
The sun is behind every cloud
View GitHub Profile
@fedir
fedir / gist:5344327
Created April 9, 2013 09:25
Mount samba partition from Linux (Debian) from shell
mount -t cifs -o username=user,password=pass\!word //192.168.XX.XX/someshare /mnt/localdir
#!/bin/bash
# Use : diff_invert.sh somepatchtoinvert.diff
PATCHNAME=$1
interdiff $PATCHNAME /dev/null > $PATCHNAME_inverted
rm $PATCHNAME
mv $PATCHNAME_inverted $PATCHNAME
@fedir
fedir / findBigFiles.sh
Last active December 16, 2015 06:49
Find all files with the size bigger than 1G #find #fedir
#Find all files with the size bigger than 1G
find all files > 1 GB find . -type f -size +1G -exec ls -lh {} \;
@fedir
fedir / gist:5394772
Created April 16, 2013 09:57
Find the size of all folders ignoring .svn #shell
find . -not -iwholename '*.svn*' -print0 | xargs -r0 du -shc
@fedir
fedir / gist:5395709
Created April 16, 2013 13:02
Files with non UTF8 characters in the name detecting and rename
# encoding analyzing
find . | grep -P "[\x80-\xFF]" | iconv -f latin1 -t utf8
# test launch
find . | grep -P "[\x80-\xFF]" | rename -n 'BEGIN {binmode STDIN, ":encoding(latin1)"; use Encode;} $_=encode("utf8", $_)'
# rename
find . | grep -P "[\x80-\xFF]" | rename -n 'BEGIN {binmode STDIN, ":encoding(latin1)"; use Encode;} $_=encode("utf8", $_)'
@fedir
fedir / gist:5396088
Created April 16, 2013 13:56
Import database from remote host using compression #mysql #dump #zip #ssh
ssh -l SSHLOGIN RE.MO.TE.IP "mysqldump DB -uMYSQLLOGIN -pMYSQLPWD | gzip -3 -c" > DB.sql.gz
@fedir
fedir / gist:5433429
Last active December 16, 2015 12:19
HTML redirection with both meta refresh and JavaScript ref:http://stackoverflow.com/questions/5411538/how-to-redirect-from-html-page
<!DOCTYPE HTML>
<html lang="fr-FR">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0;url=http://example.com">
<script type="text/javascript">
window.location.href = "http://example.com"
</script>
<title>Page Redirection</title>
</head>
@fedir
fedir / index.html
Created April 24, 2013 12:59
An empty HTML document (for placeholders, bootstraps etc)
<!DOCTYPE HTML>
<html lang="fr-FR">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Content
</body>
</html>
@fedir
fedir / get_visits.sh
Created April 25, 2013 08:39
Parsing access logs to find number of accesses by date, by hour and by minute # Inspired by https://twitter.com/climagic/status/327124836914712576
# Number of accesses, daily
zcat access.log.1.gz | awk {'print $4'} | cut -c2-12 | sort | uniq -c
# Number of accesses, hourly
zcat access.log.1.gz | awk {'print $4'} | cut -c2-15 | sort | uniq -c
# Number of accesses, minutely
zcat access.log.1.gz | awk {'print $4'} | cut -c2-18 | sort | uniq -c
@fedir
fedir / get_visitors.sh
Last active December 16, 2015 15:49
Visitors unique IPs rated by accesses
# Prints the list of visitors IPs rated by accesses
zcat access.log.21-04-2013.gz | awk {'print $1'} | sort | uniq -c | sort -h