Skip to content

Instantly share code, notes, and snippets.

Avatar

Gergely Polonkai gergelypolonkai

View GitHub Profile
@gergelypolonkai
gergelypolonkai / sway-debug-log-uniq
Created Jul 10, 2020
Sway debug log (ran through uniq -c to condense output)
View sway-debug-log-uniq
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:
View openpgp.md
View 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 Dec 22, 2016
Finding untranslated Python strings
View string-checker.py
#! /usr/bin/env python3
import ast
import gettext
from gettext import gettext as _
import sys
def get_func_name(node):
cls = node.__class__.__name__
View slugify.py
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 Nov 30, 2016
Add Python docstring to anywhere
View python-docstring.el
(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 Nov 30, 2016
Get specific fields from the id-manager database
View idm.el
(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 Nov 10, 2016
Emacs: Open the current file as another user
View open-this-file-as-other-user.el
(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 Oct 4, 2016
Vala Serialization example
View ser-example.vala
/* -*- 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;
View daemonize.py
"""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