:g/^/execute ‘.w ‘.line(‘.’).’.txt’
Posts By: fedorishev
Export notes from old Evernote *.exb file to csv
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 <
Make a list of similar urls like www.example.com/page=10
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
Move all files with *.ext extension from subfolders to one folder
find /src/dir -type f -name «*.ext» -exec mv {} —backup=numbered -t /dst/dir/ \;
исправить кодировки имен файлов Ubuntu
sudo apt-get install convmv
find . -type f -print -exec convmv —notest -f
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)
pretty print nested dict with unicode values
>>> import json
>>> print json.dumps({}, sort_keys=True, indent=4, ensure_ascii=False)
http://stackoverflow.com/questions/3229419/pretty-printing-nested-dictionaries-in-python
vim hints
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
batch ods to xls and backwards
Как сконвертировать много файлов из 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
View crontab log in Ubuntu
grep CRON /var/log/syslog
dict to class — рекурсивно
# 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)
Рецепт: