Skip to content

Instantly share code, notes, and snippets.

View spoterianski's full-sized avatar
🏠
Work from home

Sergey Poterianski spoterianski

🏠
Work from home
View GitHub Profile
@spoterianski
spoterianski / git-remote-init.sh
Created December 12, 2011 21:19
Shell script for creating remote repository and link with local
#!/bin/bash
# setup your parameters
ssh_host="yourserver.com"
remote_path="/path_to_git_storage"
# ------------------------------
if [ -z "$1" ]
then
echo "usage: git-remote-init.sh [repository name]"
@spoterianski
spoterianski / sparks.py
Created February 7, 2012 20:28 — forked from stefanv/sparks.py
Command line sparks in Python
#!/usr/bin/python
# coding=utf-8
# Python version of Zach Holman's "spark"
# https://github.com/holman/spark
# by Stefan van der Walt <stefan@sun.ac.za>
"""
USAGE:
@spoterianski
spoterianski / ipconvert.py
Created June 4, 2014 13:44
Convert IP to int and back from int to IP
"""
Convert IPv4 to unsigned int
"""
def ip2uint(ip):
dot1 = ip.index('.')
dot2 = ip.index('.', dot1 + 1)
dot3 = ip.index('.', dot2 + 1)
i1 = int(ip[0: dot1])
i2 = int(ip[dot1 + 1: dot2])
i3 = int(ip[dot2 + 1: dot3])
@spoterianski
spoterianski / 0_reuse_code.js
Created July 23, 2014 16:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@spoterianski
spoterianski / main_fish.py
Last active May 18, 2022 18:17
python fish
#!/usr/bin/env python
# coding=utf-8
import sys
def go(filename):
f = open(filename)
while 1:
lines = f.readlines(100000)
if not lines:
@spoterianski
spoterianski / read_file.py
Last active August 29, 2015 14:05
Read large file by lines
file = open(filename)
while 1:
lines = file.readlines(100000)
if not lines:
break
for line in lines:
print(line)
file.close()
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
@spoterianski
spoterianski / get_yesterday.py
Created February 3, 2015 11:01
get yesterday in python
"""
Get yesterday
"""
def get_yesterday(self):
today = datetime.date.today()
d = datetime.timedelta(days=1)
yesterday = today - d
return yesterday.strftime('%Y%m%d')
@spoterianski
spoterianski / filter_file_by_keys.py
Created July 12, 2016 15:21
filter file by keys
#!/usr/bin/env python
# coding=utf-8
import sys
def go(key_filename, filename):
k = open(key_filename)
keys = list()
while 1:
lines = k.readlines(100000)
@spoterianski
spoterianski / encrypt_openssl.txt
Created November 13, 2017 15:44 — forked from crazybyte/encrypt_openssl.txt
File encryption using OpenSSL
For symmetic encryption, you can use the following:
To encrypt:
openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt
To decrypt:
openssl aes-256-cbc -salt -a -d -in encrypted.txt -out plaintext.txt
For Asymmetric encryption you must first generate your private key and extract the public key.
@spoterianski
spoterianski / hr-logo.ino
Created November 15, 2017 20:50
H&R Logo on ESP32 Wifi Kit (simple demo)
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif