Skip to content

Commit

Permalink
added more scripts too
Browse files Browse the repository at this point in the history
  • Loading branch information
hearues-zueke-github committed Apr 28, 2018
1 parent 4782525 commit c62a059
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 0 deletions.
60 changes: 60 additions & 0 deletions guis/simple_hex_editor/main.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>274</width>
<height>258</height>
</rect>
</property>
<property name="windowTitle">
<string>Simple Hex Editor</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>274</width>
<height>27</height>
</rect>
</property>
<widget class="QMenu" name="menuMain">
<property name="title">
<string>Main</string>
</property>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="actionInfo"/>
</widget>
<addaction name="menuMain"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
</action>
<action name="actionInfo">
<property name="text">
<string>Iinfo</string>
</property>
</action>
<action name="actionTest">
<property name="text">
<string>Test</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
37 changes: 37 additions & 0 deletions guis/simple_hex_editor/simple_hex_editor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /usr/bin/python2.7
# -*- coding: utf-8 -*-

import os
import sys

import numpy as np

from datetime import datetime

from PIL import Image
from PyQt4 import Qt, QtCore, QtGui, QtTest, uic

# form_class_dialog = uic.loadUiType("info_dialog.ui")[0]
form_class = uic.loadUiType("main.ui")[0]

class MyWindowClass(QtGui.QMainWindow, form_class):

def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.setupUi(self)

self.actionExit.triggered.connect(self.actionExit_triggered)
# self.actionInfo.triggered.connect(self.action_Info_triggered)

def get_datetime_str(self):
return datetime.now().strftime("%Y%m%d%H%M%S")

def actionExit_triggered(self):
QtCore.QCoreApplication.instance().quit()


if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myWindow = MyWindowClass(None)
myWindow.show()
app.exec_()
27 changes: 27 additions & 0 deletions math_functions/define_generic_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#! /usr/bin/python2.7
# -*- coding: utf-8 -*-

import os
import sys

import numpy as np

import matplotlib.pyplot as plt

from os.path import expanduser

def get_permutation_table(n):
return np.random.permutation(np.arange(0, n))

if __name__ == "__main__":
home_path = expanduser("~")
print("home_path: {}".format(home_path))

m = 15
n = 40
a = np.random.randint(0, m, (n, ))
print("m: {}, n: {}".format(m, n))
print("a: {}".format(a))

perm_tbl = get_permutation_table(16)
print("perm_tbl:\n{}".format(perm_tbl))
61 changes: 61 additions & 0 deletions picture_manipulation/soften_neighbourhood.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#! /usr/bin/python2.7
# -*- coding: utf-8 -*-

import os
import sys

import numpy as np

import matplotlib.pyplot as plt

from os.path import expanduser

def get_2d_idx_table(m, n):
idx_2d_table = np.zeros((m, n, 2)).astype(np.int)

idx_2d_table[:, :, 0] += np.arange(0, m).reshape((m, -1))
idx_2d_table[:, :, 1] += np.arange(0, n).reshape((-1, n))

return idx_2d_table

if __name__ == "__main__":
home_path = expanduser("~")
print("home_path: {}".format(home_path))

idx_frame_3x3 = get_2d_idx_table(3, 3)
print("idx_frame_3x3:\n{}".format(idx_frame_3x3))

h = 5
w = 5

val_table = np.random.randint(0, 10, (h, w))
# print("val_table:\n{}".format(val_table))

val_table_ext_row = np.vstack((val_table[0],
val_table[:],
val_table[-1]))
# print("val_table_ext_row:\n{}".format(val_table_ext_row))

val_table_ext = np.hstack((val_table_ext_row[:, 0].reshape((-1, 1)),
val_table_ext_row[:],
val_table_ext_row[:, -1].reshape((-1, 1))))
print("val_table_ext:\n{}".format(val_table_ext))

j = 1
i = 2

m = 3
n = 3

idx_y_table = np.random.randint(0, h, (m*n, ))
idx_x_table = np.random.randint(0, w, (m*n, ))

print("idx_y_table:\n{}".format(idx_y_table))
print("idx_x_table:\n{}".format(idx_x_table))

idx_table = np.vstack((idx_y_table, idx_x_table))

print("idx_table:\n{}".format(idx_table))

new_vals = val_table[idx_table.tolist()].reshape((m, n))
print("new_vals:\n{}".format(new_vals))
16 changes: 16 additions & 0 deletions test_programs/numpy_huge_matrix_calc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /usr/bin/python2.7

import numpy as np

from time import time

a = np.random.random((1000, 10000))
b = np.random.random((10000, 1000))

start_time = time()
c = np.dot(b, a)
end_time = time()

diff_time = end_time-start_time

print("diff_time: {:.3f}s".format(diff_time))

0 comments on commit c62a059

Please sign in to comment.