Skip to content

Instantly share code, notes, and snippets.

@droustchev
droustchev / teller.livemd
Last active September 2, 2022 18:38
Teller Challenge

Teller Bank Challenge

Mix.install([:req, :jason, :kino])

Your Solution

username = Kino.Input.text("Username") |> Kino.render()
@droustchev
droustchev / iterm 2 tmux auto-start
Last active July 31, 2018 15:55
List & attach to active tmux sessions, attach to new `default` session if no previous sessions exist
tmux ls && read tmux_session && tmux attach -t ${tmux_session:-default} || tmux new -s ${tmux_session:-default}
@droustchev
droustchev / _README.md
Last active April 8, 2021 21:55
tmux vim navigation

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'.

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 April 7, 2016 21:29
Moment Date Length Checker
<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 August 6, 2022 23:34 — forked from kung-foo/gist:1730627
SQLAlchemy extension for "ON DUPLICATE KEY UPDATE"
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 August 29, 2015 13:56
Small helper function that enables you to drop collections based on their name. Use with caution!
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 August 29, 2015 13:56
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.
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 December 11, 2015 22:48
Autounattend.xml snippet for wiping and partitioning the disk.
<DiskConfiguration>
<WillShowUI>OnError</WillShowUI>
<Disk>
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
<CreatePartitions>
<CreatePartition>
<Order>1</Order>
<Size>100</Size>
<Type>Primary</Type>