Skip to content

Instantly share code, notes, and snippets.

View aeroaks's full-sized avatar

Akshay Verma aeroaks

  • Netherlands
View GitHub Profile
@aeroaks
aeroaks / wsGui.py
Last active November 4, 2022 09:48
Websocket server with Qt4 GUI using python-websocket-server recieves message from clients and is printed by the GUI using slots
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'websocket.ui'
#
# Created by: PyQt4 UI code generator 4.11.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
@aeroaks
aeroaks / pgcbar.py
Last active April 12, 2016 08:19 — forked from maedoc/pgcbar.py
PyQtGraph colorbar class (using hsv color)
import numpy as np
import pyqtgraph as pg
class ColorBar(pg.GraphicsObject):
def __init__(self, cmap, width, height, ticks=None, tick_labels=None, label=None):
pg.GraphicsObject.__init__(self)
# handle args
@aeroaks
aeroaks / .vimrc
Created July 15, 2015 08:39
VIMRC file
" URL: http://vim.wikia.com/wiki/Example_vimrc
" Authors: http://vim.wikia.com/wiki/Vim_on_Freenode
" Description: A minimal, but feature rich, example .vimrc. If you are a
" newbie, basing your first .vimrc on this file is a good choice.
" If you're a more advanced user, building your own .vimrc based
" on this file is still a good idea.
"------------------------------------------------------------
" Features {{{1
"
@aeroaks
aeroaks / sudoSample.py
Last active September 10, 2023 15:28
Run Sudo command using Python
import subprocess
# run command using Popen and provide password using communicate.
# password requires byte format.
# sudo -S brings password request to PIPE
proc = subprocess.Popen(['sudo', '-S', 'nano', 'test.txt'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate(input=b'password\n')
# Print output and errors
print(proc)
@aeroaks
aeroaks / reset_timer.py
Created December 2, 2014 08:32
Reset Timer in Python
from threading import Thread, Event, Timer
import time
def TimerReset(*args, **kwargs):
""" Global function for Timer """
return _TimerReset(*args, **kwargs)
class _TimerReset(Thread):
"""Call a function after a specified number of seconds:
@aeroaks
aeroaks / sdl2HelloWorld.py
Created October 31, 2014 10:42
SDL2 Hello World
"""Simple example for using sdl2 directly.
Event prints out on the terminal
event.type - type of event
event.key... - symbolic key code for checking which key is checked
event.mouse.x/y - x and y position of the mouse within the window.
Used help from PySDL2 readthedocs page.
Window background code is commented out as it requires a BMP file. Just rename actual file/filename in the code and comment out.
"""

Goal

My goal was pretty simple. Setup a central storage on a Raspberry Pi device, so we could exchange files at home without using the cloud or skype. It wasn't so hard to setup and I do recommend it to everyone that can spare some time and effort into doing this.

List of goals:

  • Central storage to place and exchange files.
  • Accessible from desktop and mobile devices.
  • Available only on the internal network.
@aeroaks
aeroaks / simplebrowser2.py
Created September 4, 2014 09:14
GTK Webkit2 Browser - simple single window
from gi.repository import Gtk
from gi.repository import WebKit2
# initialize WebView
view = WebKit2.WebView()
# initialize Scrolled Window
sw = Gtk.ScrolledWindow()
sw.add(view)
@aeroaks
aeroaks / simplebrowser.py
Last active August 29, 2015 14:06
GTK Webkit Browser - simple single window
from gi.repository import Gtk
from gi.repository import WebKit
# initialize WebView
view = WebKit.WebView()
# initialize Scrolled Window
sw = Gtk.ScrolledWindow()
sw.add(view)