Skip to content

Instantly share code, notes, and snippets.

View gergelypolonkai's full-sized avatar

Gergely Polonkai gergelypolonkai

View GitHub Profile
@gergelypolonkai
gergelypolonkai / openpgp.md
Last active December 30, 2022 06:21
OpenPGP Ariadne verification
@gergelypolonkai
gergelypolonkai / sway-debug-log-uniq
Created July 10, 2020 08:33
Sway debug log (ran through uniq -c to condense output)
1 Jul 10 08:57:55 notebook.lan sway[4801]: 2020-07-10 08:57:55 - [main.c:521] Missing a required Wayland interface
1 Jul 10 08:57:56 notebook.lan sway[4807]: Got sleep lock: 11
1 Jul 10 08:57:56 notebook.lan sway[4803]: 2020-07-10 08:57:56 - [main.c:299] Found config eDP-1 for output eDP-1 (Unknown 0x04A4 0x00000000)
1 Jul 10 08:57:58 notebook.lan sway[4805]: [2020-07-10 08:57:58.128] [info] Resources files: /home/polesz/.config/waybar/config, /home/polesz/.config/waybar/style.css
1 Jul 10 08:57:58 notebook.lan sway[4805]: Unknown option -b
1 Jul 10 08:57:58 notebook.lan sway[4805]: [2020-07-10 08:57:58.314] [warning] For a functional tray you must have libappindicator-* installed and export XDG_CURRENT_DESKTOP=Unity
1 Jul 10 08:58:00 notebook.lan sway[4805]: [2020-07-10 08:58:00.660] [warning] Requested width: 0 exceeds the minimum width: 1920 required by the modules
1 Jul 10 08:58:00 notebook.lan sway[4805]: [2020-07-10 08:58:00.661] [warning] Requested width:
@gergelypolonkai
gergelypolonkai / keybase.md
Created October 24, 2017 10:18
keybase.md

Keybase proof

I hereby claim:

  • I am gergelypolonkai on github.
  • I am gergelypolonkai (https://keybase.io/gergelypolonkai) on keybase.
  • I have a public key whose fingerprint is 13D6 0476 B35A FCA8 BC01 3A32 F42B BA58 B074 0C4C

To claim this, I am signing this object:

@gergelypolonkai
gergelypolonkai / string-checker.py
Created December 22, 2016 08:56
Finding untranslated Python strings
#! /usr/bin/env python3
import ast
import gettext
from gettext import gettext as _
import sys
def get_func_name(node):
cls = node.__class__.__name__
@gergelypolonkai
gergelypolonkai / slugify.py
Created December 8, 2016 14:00
Slugify in Python 3
import re
from unicodedata import normalize
_punctuation_re = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+')
def slugify(text, delim='-'):
"""
Generate an ASCII-only slug.
"""
@gergelypolonkai
gergelypolonkai / python-docstring.el
Created November 30, 2016 07:41
Add Python docstring to anywhere
(defun gpolonkai/prog-in-string-p ()
"Return `t' if point is inside a string."
(nth 3 (syntax-ppss)))
(defun gpolonkai/prog-in-comment-p ()
"Return `t' if point is inside a comment."
(nth 4 (syntax-ppss)))
(defun gpolonkai/python-add-docstring ()
"Add a Python docstring to the current thing. If point is
@gergelypolonkai
gergelypolonkai / idm.el
Last active November 30, 2016 10:29
Get specific fields from the id-manager database
(defun gpolonkai/idm-record-get-field (record field)
"Get FIELD of an id-manager RECORD."
(let ((funcname (intern (concat "idm-record-" (symbol-name field)))))
(when (fboundp funcname)
(funcall funcname record))))
(defun gpolonkai/idm-get-field-for-account (account field)
"Get id-manager password for ACCOUNT."
(let ((db (idm-load-db))
(lookup-record nil))
@gergelypolonkai
gergelypolonkai / open-this-file-as-other-user.el
Created November 10, 2016 10:05
Emacs: Open the current file as another user
(defun open-this-file-as-other-user (user)
"Edit current file as USER, using `tramp' and `sudo'. If the current
buffer is not visiting a file, prompt for a file name."
(interactive "sEdit as user (default: root): ")
(when (string= "" user)
(setq user "root"))
(let* ((filename (or buffer-file-name
(read-file-name (format "Find file (as %s): "
user))))
(tramp-path (concat (format "/sudo:%s@localhost:" user) filename)))
@gergelypolonkai
gergelypolonkai / ser-example.vala
Created October 4, 2016 09:52
Vala Serialization example
/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* core-json-api-simple-object.vala
* Copyright (C) 2015 Luc Chante <luc chante gmail com>
*
*/
public class Core.JsonApi.SimpleObject : Object, Json.Serializable {
public bool serialize_default_value = false;
"""Generic linux daemon base class for python 3.x."""
import sys, os, time, atexit, signal
class daemon:
"""A generic daemon class.
Usage: subclass the daemon class and override the run() method."""
def __init__(self, pidfile): self.pidfile = pidfile