четверг, 31 марта 2016 г.

wav из mp4

ffmpeg -i input.mp4 -vn -acodec pcm_s16le -ar 44100 -ac 2 output.wav

воскресенье, 3 января 2016 г.

пятница, 25 сентября 2015 г.

среда, 23 сентября 2015 г.

Запуск KOI8-R терминала SSH в UTF-8 окружении

luit -encoding "KOI8-R" ssh ip или xterm -en koi8-r (дальше обычный ssh) mc -S dark --stickchars

четверг, 25 июня 2015 г.

How to change pattern recursively

ack -l 'pattern' | xargs perl -pi -E 's/pattern/replacement/g'

Explanation

ack

ack is an awesome command line tool that is a mix of grepfind, and full Perl regular expressions (not just the GNU subset). Its written in pure Perl, it's fast, it has match highlighting, works on Windows and it's friendlier to programmers than the traditional command line tools. Install it on Ubuntu with sudo apt-get install ack-grep.

xargs

Xargs is an old unix command line tool. It reads items from standard input and executes the command specified followed by the items read for standard input. So basically the list of files generated by ack are being appended to the end of the perl -pi -E 's/pattern/replacemnt/g' command.

perl -pi

Perl is a programming language. The -p option causes Perl to create a loop around your program which iterates over filename arguments. The -i option causes Perl to edit the file in place. You can modify this to create backups. The -E option causes Perl to execute the one line of code specified as the program. In our case the program is just a Perl regex substitution. For more information on Perl command line options perldoc perlrun. For more information on Perl see http://www.perl.org/.

четверг, 19 марта 2015 г.

Linux check motherboard

sudo dmidecode --string baseboard-product-name

четверг, 12 марта 2015 г.

Работа с русскими именами файлов в ZIP и UNZIP под *nix

Увидеть имена файлов путём перекодировки

  ls -N | iconv -f cp1252 -t cp850 | iconv -f cp866

Перекодировать распакованные файлы в utf-8 можно следующей командой:

   find . -type f -exec sh -c 'np=`echo {}|iconv -f cp1252 -t cp850| iconv -f cp866`; mv "{}" "$np"' \;

четверг, 26 февраля 2015 г.

среда, 25 февраля 2015 г.

How to check for changes on remote (origin) git repository?

You could git fetch origin to update the remote branch in your repository to point to the latest version. For a diff against the remote:

 git diff origin/master

If you want to accept the remote changes:

 git merge origin/master

вторник, 7 октября 2014 г.

Read CSV file

sed "s/,/\t/g" filename.csv | less -S

вторник, 5 августа 2014 г.

Convert file from utf8 to cp1251

iconv -f utf8 -t cp1251 < index.php > index.php.1251

Send html POST command from console

curl --data "param1=value1&param2=value2" http://hostname/resource

четверг, 31 июля 2014 г.

Determine and change file character encoding

file -bi [filename]

Example output:

steph@localhost ~ $ file -bi test.txt text/plain; charset=us-ascii 
  
Use vim to change a file's encoding:

set encoding=utf-8
set fileencoding=utf-8

пятница, 1 ноября 2013 г.

суббота, 22 сентября 2012 г.

Split large file

Have you ever want to split a large file into several small files? I’ve face this problem few days ago. I need to split a large file (3GB log file) into several smaller file where i can read it using normal text editor.
To split large file into several smaller files, you can use split command in linux. Just follow the steps below and you will be able to split large file into smaller files.
  • in your shell key in
    $ split –bytes=1m /path/to/large/file
    /path/to/output/file/prefix
  • Done. You just split your large file into several smaller files
* You can change the output file size by changing the –bytes=1m to your preference. You can use b, k, or m. b represent bytes, k represent kilobytes, m represent megabytes.
To restore the original file, you can use cat command.
To join all the smaller file to restore the original file type:-
$ cat prefix* > NEWFILENAME
I recently ran into an issue where I had about 7.5 GB of files split into 512M chunks downloaded from linux machine. The files had been generated using the split command:
split -b 512m files.tgz
This created the following files:
-rw-rw-rw- 1 user group 536870912 Mar 9 20:44 xaa
-rw-rw-rw- 1 user group 536870912 Mar 9 20:46 xab
-rw-rw-rw- 1 user group 536870912 Mar 9 20:49 xac
I wanted to combine them in windows and looked around for a while until I realized you can use Microsoft’s copy utility in binary mode!
copy /b xa* files.tgz /b
Now I’m all done! Hurray for built-in utilities.

пятница, 3 августа 2012 г.

воскресенье, 12 декабря 2010 г.

Переименовать группу файлов

Often over time, we will want to reorganize a group of files by renaming them.

To rename *.txt to *.bak
(e.g. to rename ham.txt to ham.bak)
for f in *.txt; do mv "$f" "${f%.txt}.bak"; done

To remove ‘new-’ from new-*
(e.g. to rename new-ham.txt to ham.txt)
for f in new-*; do mv "$f" "${f#new-}"; done

${variable%pattern} vs ${variable#pattern}

The funny-looking symbol, ${f%.txt} is a useful match-and-remove string operator:
If the pattern ‘.txt’ matches the end of variable $f, it will remove the matching part (that’s ‘.txt‘) and return the rest. Try this:
f=new-ham.txt # define $f as 'new-ham.txt'
echo ${f%.txt} # display 'new-ham'

What about ${f#new-}? It’s almost the same, but it matches the pattern at the beginning of the variable.
echo ${f#new-} # display 'ham.txt'

вторник, 27 июля 2010 г.

android vibrator

To make vibrator works you need make few steps:

1. in sources:

Vibrator vb = ( Vibrator )getApplication().getSystemService( Service.VIBRATOR_SERVICE );
vb.vibrate( 1000 );

2. in application manifest:
"uses-permission android:name="android.permission.VIBRATE"/"

пятница, 14 мая 2010 г.

Как погасить питание на USB программно?

echo "suspend" > /sys/bus/usb/devices/usb2/power/level
echo "auto" > /sys/bus/usb/devices/usb2/power/level

пятница, 4 декабря 2009 г.

Restore files by grep

Шустро восстановить удаленные/потерянные/случайно_измененные текстовые файлы можно и грепом
grep -i -a -B10 -A100 'Строка или текст из файла, который потерпел катастрофу' /dev/sda1 > result.txt 


Соответственно, флаги
-i отвечает за case sensivity,
-a позволяет искать напрямую на /dev/sda1
A и B задают границы относительно этой строки