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 / getFileStatisticsByDate.sh
Last active December 17, 2015 21:50
Analyzes filetree and gives statistics of file created by extension and year #shell #statistics
#!/bin/bash
# Analyzes filetree and gives statistics of file created by extension and year
FILEPATH="/var/www/"
TMPFILEFROM=/tmp/datefrom.tmp
TMPFILETO=/tmp/dateto.tmp
echo "all files"
for YEAR in {2013..2005}
do
@fedir
fedir / getRecordsNumberByYear.sh
Last active December 17, 2015 21:58
Gets statistics of records in a TYPO3 table, by modification timecode key #typo3 #statistics
#!/bin/bash
DB_TABLE=pages
DB_CRITERIAL_FIELD=tstamp
YEAR=2005
DB_QUERY="select count(uid) from $DB_TABLE where FROM_UNIXTIME($DB_CRITERIAL_FIELD) >= '$YEAR-01-01 00:00:00' and FROM_UNIXTIME($DB_CRITERIAL_FIELD) <= '$YEAR-12-31 23:59:00';"
echo $DB_QUERY
for i in {2013..2005}
do
@fedir
fedir / getFileExtensionsFromFolder.sh
Last active December 17, 2015 21:59
Get files extensions from a folder recursively #shell // via http://stackoverflow.com/q/1842254
#!/bin/bash
find /var/www/ -type f -iname "*.*" | awk -F. '{print $NF}' | tr '[:upper:]' '[:lower:]' | sort -u
@fedir
fedir / getFilesDetailedStatistics.sh
Last active December 17, 2015 22:39
Find files detailed statistics in shell : path, filesize, date of last access, date of last status change, date of last modification (in locale format; in unixstamp)
#!/bin/bash
# ref. : man find
# printf options
# %p Files name.
# %P Files name with the name of the command line argument under which it was found removed.
# %s Files size in bytes.
# %Ak Files last access time in the format specified by k
# %Ck Files last status change time
# %Tk Files last modification time
# Time options k
@fedir
fedir / getFilesDetailedStatisticsOrderingBySize.sh
Created May 31, 2013 09:54
Find files detailed statistics in shell : filesize, path, date of last access, date of last status change, date of last modification (in locale format; in unixstamp), ordering by size
#!/bin/bash
# ref. : man find
# printf options
# %p Files name.
# %P Files name with the name of the command line argument under which it was found removed.
# %s Files size in bytes.
# %Ak Files last access time in the format specified by k
# %Ck Files last status change time
# %Tk Files last modification time
# Time options k
@fedir
fedir / loadDataFromFile.sql
Last active December 17, 2015 22:48
Load data into SQL table from file
# ref. : http://dev.mysql.com/doc/refman/5.1/en/load-data.html
LOAD DATA INFILE 'filename.txt'
INTO TABLE databasename.tablename
FIELDS TERMINATED BY '\t' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES;
@fedir
fedir / syncForkedGit.sh
Last active December 18, 2015 00:09
Syncing a Forked git Repository With a Master Repository’s Changes // via https://chriscase.cc/2011/02/syncing-a-forked-git-repository-with-a-master-repositorys-changes/
#!/bin/bash
ssh_master=$1
ssh_upstream=$2
git clone $ssh_master
git remote add upstream $ssh_upstream
git fetch upstream
git merge upstream/master
git push origin master
@fedir
fedir / kill.js
Created June 3, 2013 16:50 — forked from davidbgk/kill.js
/**
* Casper script to restart Alwaysdata processes.
*
* Usage:
* $ casperjs kill.js email@example.com mysecretpassword
*/
var casper = require('casper').create();
casper.start("https://admin.alwaysdata.com/login/");
var casper = require('casper').create({logLevel: 'debug', verbose: false}),
schedules = [];
casper.start('http://conf2013.web-5.org/en/conference-schedule/', function() {
schedules = this.evaluate(function() {
var schedules = document.querySelectorAll('.schedule .track > ul > li'),
tag, obj, content;
return Array.prototype.map.call(schedules, function(e) {
obj = {
day: e.querySelector('time').getAttribute('datetime').split(' ')[0],
@fedir
fedir / addSymLink.sh
Created June 4, 2013 13:29
Add an app to /usr/local/bin via a symlink using pwd // via http://casperjs.org/installation.html