Skip to content

Instantly share code, notes, and snippets.

View NetBUG's full-sized avatar

Oleg NetBUG

View GitHub Profile
@NetBUG
NetBUG / optimize_corr_matrix.py
Created May 31, 2017 17:59
Correlation matrices in Python
def build_corr_matrix(in_path="", out_path=""):
df = load_csv(in_path)
n_clusters = 6
n_variables = len(df.columns)
print ("Sorting %d variables" % n_variables)
cluster_size = int(n_variables / n_clusters)
C = df.corr().fillna(0)
C.to_csv(out_path + '_full.txt')
s = C.unstack()
so = s.order(kind="quicksort")[:-n_variables]
@NetBUG
NetBUG / steppers.c
Created June 13, 2017 06:14
Exam sample code
int Index;
int yDir = 7;
int xDir = 5;
int yStep = 4;
int xStep = 2;
int enable = 8;
long ms_x = 0;
long ms_y = 0;
void setup()
@NetBUG
NetBUG / stepmotors.ino
Created June 14, 2017 11:29
Controlling two steppers indeendently
int Motor1EN = 6;
int Motor1dir = 5;
int Motor1step = 4;
int Motor2EN = 9;
int Motor2dir = 8;
int Motor2step = 7;
byte reversButton = 2;
boolean reversButtonPres = false;
@NetBUG
NetBUG / facebook_poller.py
Created June 15, 2017 15:52
FB page status for @philippnox
#!/usr/bin/env python3
#author=ourzhumt
# using https://www.facebook.com/plugins/fan.php?connections=100&id=fablab77
import requests
import bs4 # beautiful_soup4
def extract_users(html):
ls = []
# TODO: Use bs4 to extract <ul class="uiList... and get all users

Keybase proof

I hereby claim:

  • I am netbug on github.
  • I am netbug (https://keybase.io/netbug) on keybase.
  • I have a public key ASDshgg_f-W0sfTzOfwYcyGqC2AFOeFSwVYmBiWTqGRoGAo

To claim this, I am signing this object:

from PIL import Image
img = Image.open('path_to_image.jpg').convert('1')
for i in range(1, img.size[0]):
#for y in range(1, img.size[1]):
# print ('1' if img.getpixel((i, y)) else '0')
line = [img.getpixel((i, y)) for y in range(1, img.size[1])]
print("".join(['1' if s else '0' for s in line]))
@NetBUG
NetBUG / anomaly.py
Created December 20, 2017 13:39
LSTM for international airline passengers problem with window regression framing
#coding=utf-8
import datetime
import numpy as np
import matplotlib.pyplot as plt
import os
import pandas as pd
import pytz
import re
#from scipy import interpolate
import time
@NetBUG
NetBUG / requirements.txt
Created April 5, 2018 10:38
Всё с сервера
bleach==2.1.3
boto==2.48.0
boto3==1.6.19
botocore==1.9.19
bz2file==0.98
certifi==2018.1.18
chardet==3.0.4
command-not-found==0.3
cycler==0.10.0
decorator==4.2.1
@NetBUG
NetBUG / README.md
Created May 13, 2018 11:43
Fab Modules sample with WxWidgets

The file to run is app.py It was originally called make_png_g in Fab Modules

The dependencies are listed at the project page - in fact, now it's easier to run them, you only will need to install python-wxgtk3.0 package in Ubuntu or corresponding package from pip.

The system is way more complicated than you need, the main file creates three panels inherited from the files referenced, I think you will need no more than the code in panel_png.py to load the image, and then display a sliced image plus simplest controls.

You may also consider making a Web application in Flask + UI in JavaScript, and actions are performed when sending a webform.

@NetBUG
NetBUG / led_fader.ino
Created March 22, 2019 12:32
Fading code for RGB strip (not addressable!)
#define RED_LED 6
#define BLUE_LED 5
#define GREEN_LED 9
int brightness = 255;
int gBright = 0;
int rBright = 0;
int bBright = 0;