Fedorishev.ru http://fedorishev.ru записная книжка Sat, 30 Jan 2016 08:26:48 +0000 ru-RU hourly 1 Vim — save all lines to separate file named line number.txt http://fedorishev.ru/2016/01/vim-save-all-lines-to-separate-file-named-line-number-txt/ http://fedorishev.ru/2016/01/vim-save-all-lines-to-separate-file-named-line-number-txt/#respond Sat, 30 Jan 2016 08:26:48 +0000 http://fedorishev.ru/?p=149 :g/^/execute ‘.w ‘.line(‘.’).’.txt’

]]>
http://fedorishev.ru/2016/01/vim-save-all-lines-to-separate-file-named-line-number-txt/feed/ 0
Export notes from old Evernote *.exb file to csv http://fedorishev.ru/2016/01/export-notes-from-old-evernote-exb-file-to-csv/ http://fedorishev.ru/2016/01/export-notes-from-old-evernote-exb-file-to-csv/#respond Tue, 05 Jan 2016 15:11:48 +0000 http://fedorishev.ru/?p=146 EXB is and SQLite3 database file.
Just use bash script to export all the tables to csv

sqlite2csv.sh

# obtains all data tables from database
TS=`sqlite3 $1 «SELECT tbl_name FROM sqlite_master WHERE type=’table’ and tbl_name not like ‘sqlite_%’;»`

# exports each table to csv
for T in $TS; do

sqlite3 $1 < ]]> http://fedorishev.ru/2016/01/export-notes-from-old-evernote-exb-file-to-csv/feed/ 0 Make a list of similar urls like www.example.com/page=10 http://fedorishev.ru/2015/10/make-a-list-of-similar-urls-like-www-example-compage10/ http://fedorishev.ru/2015/10/make-a-list-of-similar-urls-like-www-example-compage10/#respond Wed, 14 Oct 2015 11:39:54 +0000 http://fedorishev.ru/?p=138 1. Make a column of incrementing numbers
:put =range(1,50)
2
.
Use Ctrl+V to select the first column of text in the lines you want to comment.
Then hit Shift+i and type the text you want to insert. (www.example.com/page=)
Then hit Esc, wait 1 second and the inserted text will appear on every line.
Voila

]]>
http://fedorishev.ru/2015/10/make-a-list-of-similar-urls-like-www-example-compage10/feed/ 0
Move all files with *.ext extension from subfolders to one folder http://fedorishev.ru/2015/09/move-all-files-with-ext-extension-from-subfolders-to-one-folder/ http://fedorishev.ru/2015/09/move-all-files-with-ext-extension-from-subfolders-to-one-folder/#respond Wed, 23 Sep 2015 14:03:30 +0000 http://fedorishev.ru/?p=133 find /src/dir -type f -name «*.ext» -exec mv {} —backup=numbered -t /dst/dir/ \;

]]>
http://fedorishev.ru/2015/09/move-all-files-with-ext-extension-from-subfolders-to-one-folder/feed/ 0
исправить кодировки имен файлов Ubuntu http://fedorishev.ru/2015/04/%d0%b8%d1%81%d0%bf%d1%80%d0%b0%d0%b2%d0%b8%d1%82%d1%8c-%d0%ba%d0%be%d0%b4%d0%b8%d1%80%d0%be%d0%b2%d0%ba%d0%b8-%d0%b8%d0%bc%d0%b5%d0%bd-%d1%84%d0%b0%d0%b9%d0%bb%d0%be%d0%b2-ubuntu/ http://fedorishev.ru/2015/04/%d0%b8%d1%81%d0%bf%d1%80%d0%b0%d0%b2%d0%b8%d1%82%d1%8c-%d0%ba%d0%be%d0%b4%d0%b8%d1%80%d0%be%d0%b2%d0%ba%d0%b8-%d0%b8%d0%bc%d0%b5%d0%bd-%d1%84%d0%b0%d0%b9%d0%bb%d0%be%d0%b2-ubuntu/#respond Fri, 17 Apr 2015 10:54:28 +0000 http://fedorishev.ru/?p=126 sudo apt-get install convmv
find . -type f -print -exec convmv —notest -f -t {} \;

UPD: Неприятный случай с «doubly-encoded to utf-8 from iso-8859-5»

#-*-coding:utf8-*-
import os
allfiles=[]
for root, dirs, files in os.walk("./", topdown=False):
for name in files:
allfiles.append(os.path.join(root, name))

for f in allfiles:
try:
newf=f.decode('utf8').encode('latin1').decode('utf8', 'replace')
except:
print "{} is in proper encoding".format(f)
else:
os.rename(f, newf)
print "{} decoded well".format(f)

]]>
http://fedorishev.ru/2015/04/%d0%b8%d1%81%d0%bf%d1%80%d0%b0%d0%b2%d0%b8%d1%82%d1%8c-%d0%ba%d0%be%d0%b4%d0%b8%d1%80%d0%be%d0%b2%d0%ba%d0%b8-%d0%b8%d0%bc%d0%b5%d0%bd-%d1%84%d0%b0%d0%b9%d0%bb%d0%be%d0%b2-ubuntu/feed/ 0
pretty print nested dict with unicode values http://fedorishev.ru/2015/04/pretty-print-nested-dict-with-unicode-values/ http://fedorishev.ru/2015/04/pretty-print-nested-dict-with-unicode-values/#respond Wed, 15 Apr 2015 14:51:42 +0000 http://fedorishev.ru/?p=124 >> import json >>> print json.dumps({}, sort_keys=True, indent=4, ensure_ascii=False) http://stackoverflow.com/questions/3229419/pretty-printing-nested-dictionaries-in-python]]> >>> import json
>>> print json.dumps({}, sort_keys=True, indent=4, ensure_ascii=False)

http://stackoverflow.com/questions/3229419/pretty-printing-nested-dictionaries-in-python

]]>
http://fedorishev.ru/2015/04/pretty-print-nested-dict-with-unicode-values/feed/ 0
vim hints http://fedorishev.ru/2015/02/vim-hints/ http://fedorishev.ru/2015/02/vim-hints/#respond Tue, 17 Feb 2015 13:29:18 +0000 http://fedorishev.ru/?p=121 Write lines to file — :start_line_no,end_line_no w filename
Delete till the end of line — D
Delete till the beginning of line — d0
Paste at the end of line — $p
Show all files open -:ls
Go to middle of line — gm

]]>
http://fedorishev.ru/2015/02/vim-hints/feed/ 0
batch ods to xls and backwards http://fedorishev.ru/2015/02/batch-ods-to-xls-and-backwards/ http://fedorishev.ru/2015/02/batch-ods-to-xls-and-backwards/#respond Tue, 03 Feb 2015 14:00:26 +0000 http://fedorishev.ru/?p=117 *.xls libreoffice —headless — invisible —convert-to xls *.ods *.xls->*.ods libreoffice —headless —invisible —convert-to ods *.xls 2 вариант : unoconv sudo apt-get install unoconv unoconf -f xls *.ods]]> Как сконвертировать много файлов из OpenOffice Calc в Excel и обратно

*.ods-> *.xls
libreoffice —headless — invisible —convert-to xls *.ods

*.xls->*.ods
libreoffice —headless —invisible —convert-to ods *.xls

2 вариант : unoconv

sudo apt-get install unoconv

unoconf -f xls *.ods

]]>
http://fedorishev.ru/2015/02/batch-ods-to-xls-and-backwards/feed/ 0
View crontab log in Ubuntu http://fedorishev.ru/2014/11/view-crontab-log-in-ubuntu/ http://fedorishev.ru/2014/11/view-crontab-log-in-ubuntu/#respond Fri, 14 Nov 2014 12:14:48 +0000 http://fedorishev.ru/?p=112 grep CRON /var/log/syslog

]]>
http://fedorishev.ru/2014/11/view-crontab-log-in-ubuntu/feed/ 0
dict to class — рекурсивно http://fedorishev.ru/2014/04/dict-to-class-%d1%80%d0%b5%d0%ba%d1%83%d1%80%d1%81%d0%b8%d0%b2%d0%bd%d0%be/ http://fedorishev.ru/2014/04/dict-to-class-%d1%80%d0%b5%d0%ba%d1%83%d1%80%d1%81%d0%b8%d0%b2%d0%bd%d0%be/#respond Tue, 29 Apr 2014 18:59:23 +0000 http://fedorishev.ru/?p=109 # convert a dictionary to a class
class Struct(object):
def __init__(self, adict):
"""Convert a dictionary to a class

@param :adict Dictionary
"""
self.__dict__.update(adict)
for k, v in adict.items():
if isinstance(v, dict):
self.__dict__[k] = Struct(v)

def get_object(adict):
"""Convert a dictionary to a class

@param :adict Dictionary
@return :class:Struct
"""
return Struct(adict)

Рецепт:

]]>
http://fedorishev.ru/2014/04/dict-to-class-%d1%80%d0%b5%d0%ba%d1%83%d1%80%d1%81%d0%b8%d0%b2%d0%bd%d0%be/feed/ 0