Skip to content

Instantly share code, notes, and snippets.

@droustchev
droustchev / iterm 2 tmux auto-start
Last active Jul 31, 2018
List & attach to active tmux sessions, attach to new `default` session if no previous sessions exist
View iterm 2 tmux auto-start
tmux ls && read tmux_session && tmux attach -t ${tmux_session:-default} || tmux new -s ${tmux_session:-default}
@droustchev
droustchev / _README.md
Last active Apr 8, 2021
tmux vim navigation
View _README.md

I recently tried out the fantastic vim-tmux-navigator tmux plugin. Unfortunately, some the default key bindings conflict with some of the key bindings my fuzzy finder of choice uses. I wanted to remap them to the default vim split navigation commands that are prefixed with C-w, and found the solution of hjdivad in his gist. However, I wanted a simpler solution, so after some more digging I stumbled upon this reddit post and ultimately came up with the following solution, which doesn't rely on key bindings that unbind themselves, but uses tmux's 'key-tables'.

View keybase.md

Keybase proof

I hereby claim:

  • I am droustchev on github.
  • I am droustchev (https://keybase.io/droustchev) on keybase.
  • I have a public key whose fingerprint is 3331 3910 BB89 4F2E 61BE 9521 E545 6303 EA1B 8E0F

To claim this, I am signing this object:

@droustchev
droustchev / date_dropdown.html
Created Apr 7, 2016
Moment Date Length Checker
View date_dropdown.html
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.1/moment.js"></script>
<script>
var langs = [
'en',
'de',
'es',
'fr',
'fr-ca',
'id',
'tr',
@droustchev
droustchev / sqlalchemy_insert_ext.py
Last active Feb 20, 2017 — forked from kung-foo/gist:1730627
SQLAlchemy extension for "ON DUPLICATE KEY UPDATE"
View sqlalchemy_insert_ext.py
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.expression import Insert
@compiles(Insert)
def append_string(insert, compiler, **kw):
s = compiler.visit_insert(insert, **kw)
if 'append_string' in insert.kwargs:
return s + " " + insert.kwargs['append_string']
return s
@droustchev
droustchev / mongodb_dropCollection_helpers.js
Last active Aug 29, 2015
Small helper function that enables you to drop collections based on their name. Use with caution!
View mongodb_dropCollection_helpers.js
function dropCollections (colName) {
var collectionNames = db.getCollectionNames();
for (var i=0,len=collectionNames.length; i<len; i++) {
var collectionName = collectionNames[i];
if(collectionName.indexOf(colName) == 0) {
db[collectionName].drop();
}
}
}
@droustchev
droustchev / mongodb_cloneCollection_helpers.js
Last active Aug 29, 2015
Small helper functions that enable you to easily clone collections that contain a date in the name (e.g. 'logs_2014-02-01') from one MongoDB instance to another.
View mongodb_cloneCollection_helpers.js
function getDateString (date) {
year = date.getFullYear();
month = ('0' + (date.getMonth()+1)).slice(-2);
day = ('0' + date.getDate()).slice(-2);
return year + "-" + month + "-" + day;
}
function dateIterator (colBaseName, startDate, dayCount) {
var date = startDate
var i = 0;
@droustchev
droustchev / autounattend_diskconfig.xml
Last active Dec 11, 2015
Autounattend.xml snippet for wiping and partitioning the disk.
View autounattend_diskconfig.xml
<DiskConfiguration>
<WillShowUI>OnError</WillShowUI>
<Disk>
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
<CreatePartitions>
<CreatePartition>
<Order>1</Order>
<Size>100</Size>
<Type>Primary</Type>