Skip to content

Instantly share code, notes, and snippets.

@canabady
canabady / add-bootstrap-to-angular2-or-4
Last active August 15, 2017 07:06
Tutorial: Styling Angular CLI apps with Bootstrap
Tutorial: Styling Angular CLI apps with Bootstrap
Add and configure Bootstrap and FontAwesome dependencies
========================================================
$ npm install --save [email protected] font-awesome
Open the file src/styles.css and adding the following two statements.
=====================================================================
@import "~bootstrap/dist/css/bootstrap.min.css";
MPlayer play files recursively in a directory.
I wanted to have my files played in alphabetical order and only avi files (since a couple .srt subtitle files were in there…), so I came up with this :
mplayer -playlist <(find "$PWD" -name "*.avi" -type f | sort)
@canabady
canabady / tmux.md
Created July 5, 2017 05:05 — forked from Bekbolatov/tmux.md
Clean tmux cheat-sheet

Clean tmux cheat-sheet

By resources

sessions

list-sessions        ls         -- List sessions managed by server
new-session          new        -- Create a new session
@canabady
canabady / datetime-applet.sh
Last active February 27, 2017 03:27
Missing date & time from top panel of Unity Desktop - Ubuntu 14.04
# Missing date & time from top panel of Unity Desktop - Ubuntu 14.04
# Try reseting its configuration
dconf reset -f /com/canonical/indicator/datetime/
# If it didn't show up try kill it, it should restart
pkill -f datetime
@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
@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 / 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 / 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 / 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 / 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