Skip to content

Instantly share code, notes, and snippets.

View nzjrs's full-sized avatar

John nzjrs

View GitHub Profile
@bossjones
bossjones / FooThread.py
Last active October 25, 2020 06:34
Updated PyGtk threading example, originally made by John Stowers at https://gist.github.com/nzjrs/51686 ... This is a more modern example using PyGObject (aka PyGI)... essentially the modern Python Bindings for GLib/GObject/GIO/GTK+. Includes Gtk3 support.
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Refactored by Malcolm Jones to work with GTK+3 PyGobject( aka PyGI ). Mar 2016.
# Demo application showing how once can combine the python
# threading module with GObject signals to make a simple thread
# manager class which can be used to stop horrible blocking GUIs.
#
# (c) 2008, John Stowers <john.stowers@gmail.com>
@jabbalaci
jabbalaci / firefox.py
Created January 5, 2015 11:23
open tabs with Firefox in the background (as requested in http://redd.it/2rd2g9)
#!/usr/bin/env python2
"""
Automate your browser via telnet.
Requirements:
* Firefox
* MozRepl add-on (https://addons.mozilla.org/en-US/firefox/addon/mozrepl/)
- activate the add-on (under Tools -> MozRepl, "Start" and "Activate on startup")
Documentation of gBrowser:
@andreif
andreif / ftpserver.py
Last active November 15, 2021 01:03 — forked from scturtle/ftpserver.py
Simple FTP server in Python 2
# coding=utf-8
import os
import socket
import threading
import time
import traceback
import requests
def make_path(*parts):
@endolith
endolith / designtools.py
Last active December 18, 2015 18:49
GPL-licensed SciPy signal processing tools by Kittipong Piyawanno
from numpy import asarray, array, arange, append, angle, complex128, float64, floor
from numpy import nonzero, sign, mat, sin, cos, exp, zeros, log10, unique, fix, ceil
from numpy import ones, prod, pi, NaN, zeros_like, ravel, any, linspace, diff
from numpy.fft import fft, ifft
from scipy.signal import convolve, freqz, roots, zpk2tf, tf2zpk, remez, get_window
from scipy.interpolate import interp1d
from scipy.linalg import toeplitz, hankel
def find(condition):
"""
@sahib
sahib / clutter.py
Created May 4, 2013 19:56
Playing around with Python/Clutter/Gtk. Simple Swipe Effect.
from gi.repository import GLib, Gtk, GtkClutter, Clutter, Gdk, GdkPixbuf
import sys
from random import random
BROWSERS = 42
class ClutterBrowser(Gtk.ApplicationWindow):
@ju-popov
ju-popov / timestamp.py
Last active April 7, 2021 16:09
Python DateTime / Timestamp Convertion
######################################################################
# CURRENT AWARE LOCAL DATETIME
######################################################################
from datetime import datetime
from tzlocal import get_localzone
local_tz = get_localzone()
local_dt = datetime.now(local_tz)
@why-not
why-not / gist:4582705
Last active February 1, 2024 00:44
Pandas recipe. I find pandas indexing counter intuitive, perhaps my intuitions were shaped by many years in the imperative world. I am collecting some recipes to do things quickly in pandas & to jog my memory.
"""making a dataframe"""
df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
"""quick way to create an interesting data frame to try things out"""
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
"""convert a dictionary into a DataFrame"""
"""make the keys into columns"""
df = pd.DataFrame(dic, index=[0])
@jasonmc
jasonmc / gist:1160951
Created August 21, 2011 18:23
Setting colors in matplotlib easily (can do white-on-black)
def set_foregroundcolor(ax, color):
'''For the specified axes, sets the color of the frame, major ticks,
tick labels, axis labels, title and legend
'''
for tl in ax.get_xticklines() + ax.get_yticklines():
tl.set_color(color)
for spine in ax.spines:
ax.spines[spine].set_edgecolor(color)
for tick in ax.xaxis.get_major_ticks():
tick.label1.set_color(color)