Skip to content

Instantly share code, notes, and snippets.

@canabady
canabady / .vimrc
Last active February 6, 2017 06:49
Setting options for Gist Plugin in VIMRC
" for creating gists
Plugin 'mattn/webapi-vim'
Plugin 'mattn/gist-vim'
""""""""""""""""""""""""""""
" GIST Options
""""""""""""""""""""""""""""
" If you set g:gist_clip_command, gist.vim will copy the gist code with option '-c'
let g:gist_clip_command = 'xclip -selection clipboard'
@canabady
canabady / .vimrc
Last active February 6, 2017 06:47
Shortcut for editing and sourcing VIMRC
" Quickly edit/reload VIMRC configuration file
nnoremap gev :e $MYVIMRC<CR>
nnoremap gsv :so $MYVIMRC<CR>
if has ('autocmd') " Remain compatible with earlier versions
augroup vimrc " Source vim configuration upon save
autocmd! BufWritePost $MYVIMRC source % | echom "Reloaded " . $MYVIMRC | redraw
autocmd! BufWritePost $MYGVIMRC if has('gui_running') | so % | echom "Reloaded " . $MYGVIMRC | endif | redraw
augroup END
endif " has autocmd
@canabady
canabady / duptools-gdrive.sh
Created January 1, 2017 12:06 — forked from vibragiel/duptools-gdrive.sh
An example on how to use duplicity to perform encrypted incremental backups on Google Drive. Changes over tileo's original script: Google Drive instead of S3 as backend storage. Zenity dialogs to ask for credentials. IGNORE variable to exclude a list of directories from the backup. Verbosity raised to level 8. Activated asynchronous uploads.
#!/bin/bash
# directories to be included, space separated
SOURCE="/home/chewie /etc"
# directories to be excluded, space separated
IGNORE="/home/chewie/Downloads /home/chewie/Steam"
DRIVE_FOLDER="duplicity-backup"
LOGFILE=/home/chewie/duplicity.log
# set email to receive a backup report
EMAIL=""
@canabady
canabady / lighttpd-fastcgi-solution.html
Last active May 25, 2022 23:12
Unexpected end of file perhaps the fastcgi process died lighttpd
Issue:
Unexpected end of file perhaps the fastcgi process died lighttpd
Solution:
Check lighttpd cgi config.
For more info refer: https://www.cyberciti.biz/tips/lighttpd-php-fastcgi-configuration.html
@canabady
canabady / vim-replace-last-occurence-in-a-line
Last active January 30, 2017 05:41
Vim Tips: replace last occurrence in line
The easiest way would be to allow arbitrary text in front of the match, and specify the matched region using \zs:
:%s/.*\zsone/two/
To change a line till the last of occurence of word 'one' in it
c/.*\zsone/e
@canabady
canabady / mysql-alter-column.sql
Last active February 6, 2017 06:05
How to alter a column and change the default value in MYSQL ?
/* How to alter a column and change the default value in MYSQL ? */
ALTER TABLE foobar_data MODIFY COLUMN col VARCHAR(255) NOT NULL DEFAULT '{}';
/* A second possibility which does the same (thanks to juergen_d): */
/* --------------------------------------------------------------- */
ALTER TABLE foobar_data CHANGE COLUMN col col VARCHAR(255) NOT NULL DEFAULT '{}';
@canabady
canabady / imagemagick-pdf-2-jpg.sh
Last active February 6, 2017 06:35
Convert PDF to image with high resolution
# ===========================================================
# Convert PDF to image with high resolution
# ===========================================================
convert -density 300 -trim test.pdf -quality 100 test.jpg
# ===========================================================
@canabady
canabady / vim-tip-add-del-block-of-code
Last active January 31, 2017 11:19
To Add or Delete a block of code in all buffer
========
VIM TIPS
========
Adding a block of code inside a function in all opened buffer
-------------------------------------------------------------
// Disable literals
$this->setup(array('phqlLiterals' => true ));
@canabady
canabady / unicode-error.py
Last active February 6, 2017 05:59
How to fix: UnicodeDecodeError: 'ascii' codec can't decode byte
# How to fix: “UnicodeDecodeError: 'ascii' codec can't decode byte”
# -----------------------------------------------------------------
# Add the below code in the heading of python file
import sys
reload(sys)
sys.setdefaultencoding('utf8')
@canabady
canabady / sqlite3.ProgrammingError.py
Last active May 14, 2024 14:51
Incorrect number of bindings supplied. The current statement uses 1, and there are 74 supplied
# sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 74 supplied
# You need to pass in a sequence, but you forgot the comma to make your parameters a tuple:
cursor.execute('INSERT INTO images VALUES(?)', (img,))
# Without the comma, (img) is just a grouped expression, not a tuple, and thus the img string is treated as the input sequence. If that string is 74 characters long, then Python sees that as 74 separate bind values, each one character long.
>>> len(img)
74