Skip to content

Instantly share code, notes, and snippets.

Avatar
🌤️
The sun is behind every cloud

Fedir RYKHTIK fedir

🌤️
The sun is behind every cloud
View GitHub Profile
@fedir
fedir / gist:5344327
Created Apr 9, 2013
Mount samba partition from Linux (Debian) from shell
View gist:5344327
mount -t cifs -o username=user,password=pass\!word //192.168.XX.XX/someshare /mnt/localdir
View diff_invert.sh
#!/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 Dec 16, 2015
Find all files with the size bigger than 1G #find #fedir
View findBigFiles.sh
#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 Apr 16, 2013
Find the size of all folders ignoring .svn #shell
View gist:5394772
find . -not -iwholename '*.svn*' -print0 | xargs -r0 du -shc
@fedir
fedir / gist:5395709
Created Apr 16, 2013
Files with non UTF8 characters in the name detecting and rename
View gist:5395709
# 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 Apr 16, 2013
Import database from remote host using compression #mysql #dump #zip #ssh
View gist:5396088
ssh -l SSHLOGIN RE.MO.TE.IP "mysqldump DB -uMYSQLLOGIN -pMYSQLPWD | gzip -3 -c" > DB.sql.gz
@fedir
fedir / gist:5433429
Last active Dec 16, 2015
HTML redirection with both meta refresh and JavaScript ref:http://stackoverflow.com/questions/5411538/how-to-redirect-from-html-page
View gist:5433429
<!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 Apr 24, 2013
An empty HTML document (for placeholders, bootstraps etc)
View index.html
<!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 Apr 25, 2013
Parsing access logs to find number of accesses by date, by hour and by minute # Inspired by https://twitter.com/climagic/status/327124836914712576
View get_visits.sh
# 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 Dec 16, 2015
Visitors unique IPs rated by accesses
View get_visitors.sh
# Prints the list of visitors IPs rated by accesses
zcat access.log.21-04-2013.gz | awk {'print $1'} | sort | uniq -c | sort -h