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 / 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:
@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 / 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 / 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 / .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 / 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 / audible.js
Last active December 23, 2015 02:59
Scrape audible search results
/**
* To run use http://nrabinowitz.github.com/pjscrape/
* 1. $ phantomjs pjscrape.js audible.js
* 2. Register on mongolab.com
* 3. $ mongoimport -h ds0466148.mongolab.com:45598 -d <dbname> -c <collection> -u <user> -p <password> --file audible.json --jsonArray
* 4. Install greasemonkey (Firefox) or tempermonkey (Chrome)
* 5. Add this userscript https://gist.github.com/gornostal/6570526
* 6. Open https://mongolab.com/databases/audible/collections/fiction_books or whatever you have
*/
@gornostal
gornostal / audible-mongolab.js
Created September 15, 2013 12:53
Tampermonkey script for audible collections in mongolab
// ==UserScript==
// @name Audible-Mongolab
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description https://gist.github.com/gornostal/6570516
// @match https://mongolab.com/databases/audible/collections/*
// @copyright 2012+, You
// ==/UserScript==
@gornostal
gornostal / Sound.md
Created February 5, 2016 21:28
HP Probook 430 G3 Ubuntu drivers
@gornostal
gornostal / readme.md
Created December 28, 2016 11:08
Ubuntu/Linux. Create SWAP file
  • sudo -i
  • cd /var
  • dd if=/dev/zero of=swap.file bs=1M count=2048
  • mkswap swap.file
  • chmod 600 swap.file
  • swapon swap.file
  • // copy UUID
  • vi /etc/fstab ==> UUID=f1ed55b6-357b-4427-86c8-d57f034cf29e none swap defaults 0 0
  • mount -a
  • echo $? // should be 0 if everything is OK