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 / format.sh
Last active January 20, 2018 16:58
Format USB drive from command line
lsblk
umount /dev/sdc
sudo fdisk /dev/sdc
d,d,d,d,...
n
w
sudo mkfs.vfat /dev/sdc1
sudo dd if=/path/to/ubuntu.iso of=/dev/sdb bs=1M
@gornostal
gornostal / steps.sh
Created September 6, 2017 13:28
Fedora. Install trusted certificate into the system (p7b file)
openssl pkcs7 -in mycert.p7b -inform DER -print_certs -out mycert.pem
sudo cp mycert.pem /etc/pki/ca-trust/source/anchors/
sudo update-ca-trust
#!/bin/bash
set -ex
cd `dirname $0`
cd ..
ROOT_DIR=$(pwd)
APP=utest
LOWERAPP=${APP,,}
#!/bin/bash -eux
# This is a very simple example on how to bundle a Python application as an AppImage
# using virtualenv and AppImageKit using Ubuntu
# NOTE: Please test the resulting AppImage on your target systems and copy in any additional
# libraries and/or dependencies that might be missing on your target system(s).
########################################################################
# Get virtualenv on the target system
########################################################################
@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
@gornostal
gornostal / Sound.md
Created February 5, 2016 21:28
HP Probook 430 G3 Ubuntu drivers
@gornostal
gornostal / Unicode.md
Created November 22, 2015 10:15
Python 2.7. Unicode Errors Simply Explained

Python 2.7. Unicode Errors Simply Explained

I know I'm late with this article for about 5 years or so, but people are still using Python 2.x, so this subject is relevant I think.

Some facts first:

  • Unicode is an international encoding standard for use with different languages and scripts
  • In python-2.x, there are two types that deal with text.
    1. str is an 8-bit string.
  1. unicode is for strings of unicode code points.
@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 / .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: