Skip to content

Instantly share code, notes, and snippets.

View eliasdorneles's full-sized avatar

Elias Dorneles eliasdorneles

View GitHub Profile
@candidtim
candidtim / myappindicator_v4.py
Last active July 15, 2021 21:40
Minimal Ubuntu AppIndicator in Python, with custom icon and a "Quit" menu item
import os
import signal
from gi.repository import Gtk as gtk
from gi.repository import AppIndicator3 as appindicator
APPINDICATOR_ID = 'myappindicator'
def main():
indicator = appindicator.Indicator.new(APPINDICATOR_ID, os.path.abspath('sample_icon.svg'), appindicator.IndicatorCategory.SYSTEM_SERVICES)
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
@knu2xs
knu2xs / python-random-date.py
Last active July 17, 2023 14:15
Use python function to generate random date in given calendar year.
# import modules
import random
import datetime
# create function accepting a single parameter, the year as a four digit number
def get_random_date(year):
# try to get a date
try:
return datetime.datetime.strptime('{} {}'.format(random.randint(1, 366), year), '%j %Y')
@eliotsykes
eliotsykes / git-aware-bash-prompt.md
Last active April 28, 2023 12:18
Git Aware Bash Prompt
@eliasdorneles
eliasdorneles / just_a_button.py
Last active November 26, 2015 09:07
For Those Times When You Just Want a Button
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
For those times when you just want a button.
Run and notice the new icon in your notifications area.
Inspired by: https://glyph.twistedmatrix.com/2015/07/just-a-button.html
"""
@geier
geier / urwid_example.py
Created May 3, 2016 15:41
minimal urwid example (ListWalker)
import urwid
class SelectableText(urwid.Text):
def selectable(self):
return True
def keypress(self, size, key):
return key
content = urwid.SimpleListWalker([
#!/bin/bash
# This script assumes you're using the directory layout described in the
# documentation at: https://voc.readthedocs.io/en/latest/tutorials/tutorial-0.html
set -e
set -x
abort() {
echo "$*"; exit 1;
}
@eliasdorneles
eliasdorneles / repl-voc.sh
Last active February 28, 2018 00:53
A hack to simulate a REPL for VOC
#!/bin/bash
# For arrow-keys history and other cmdline goodies, install rlwrap and replace
# the first line by: #!/usr/bin/rlwrap bash
# This is a hack to simulate a REPL for VOC (http://pybee.org/voc)
#
# Behind the scenes, every time you try a new expression it appends it to a temporary
# file, recompiles it and re-runs it, omitting the previous output.
#
# This has the caveat that if some expression you enter raises an exception,
@narate
narate / create-hotspot.md
Last active May 16, 2024 04:35
Create Wi-Fi Hotspot on Linux using nmcli

Create a Wi-Fi hotspot on Linux using nmcli

Original post : https://unix.stackexchange.com/a/310699

nmcli con add type wifi ifname wlan0 con-name Hostspot autoconnect yes ssid Hostspot
nmcli con modify Hostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify Hostspot wifi-sec.key-mgmt wpa-psk
nmcli con modify Hostspot wifi-sec.psk "veryveryhardpassword1234"