Skip to content

Instantly share code, notes, and snippets.

View gornostal's full-sized avatar

Oleksandr Gornostal gornostal

  • Kyiv, UA
View GitHub Profile
@gornostal
gornostal / spuploader.sh
Last active October 30, 2015 10:33
Upload files via serial port to a device
#!/bin/bash
target="$1"
remotePath="$2"
device="${3:-/dev/ttyUSB0}"
# compress target files using tar | encode data to base64 string | remove \n
compress="tar -C `dirname $target` -cjvf - `basename $target` | base64 | tr -d '\n'"
# decode base64 string using python (using python because my device doesn't have base64)
base64decode="import base64, sys; sys.stdout.write(base64.b64decode(sys.stdin.read()))"
@gornostal
gornostal / .bashrc
Created September 18, 2012 14:26
.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
@gornostal
gornostal / cleanup.py
Created August 21, 2012 15:46
cleanup.py
#!/usr/bin/env python
import glob
import os
import sys
if len(sys.argv) < 2:
print "Usage: ./cleanup.py path/to/dir/ [max_dir_size_in_gb]"
sys.exit()
@gornostal
gornostal / duplicate_line.py
Created July 1, 2012 12:34
Sublime plugin for duplicating lines
import sublime, sublime_plugin
class DuplicateLineCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
if region.empty():
line = self.view.line(region)
line_contents = self.view.substr(line) + '\n'
self.view.insert(edit, line.begin(), line_contents)
@gornostal
gornostal / .tmux.conf
Created October 6, 2015 15:34
.tmux.conf
# tmux v2.0 installation steps for Ubuntu 14.04 (Trusty Tahr)
# tmux -V
# sudo apt-get update
# sudo apt-get install -y python-software-properties software-properties-common
# sudo add-apt-repository -y ppa:pi-rho/dev
# sudo apt-get update
# sudo apt-get install -y tmux
# tmux -V
# use UTF8
@gornostal
gornostal / conftest.py
Created March 6, 2015 11:59
conftest.py
import pytest
class DictHasValus(dict):
"""
DictHasValus({('foo', 'bar'): 'hello'}) == {'foo': {'bar': 'hello'}}
"""
def __eq__(self, other):
try: