Skip to content

Instantly share code, notes, and snippets.

View halfwit's full-sized avatar
🙄
What?! This is the face that launched a thousand ships?!

halfwit halfwit

🙄
What?! This is the face that launched a thousand ships?!
View GitHub Profile
package main
import (
"fmt"
"log"
"github.com/altid/client"
"github.com/altid/client/driver/gtk"
)
func init() {
### Keybase proof
I hereby claim:
* I am halfwit on github.
* I am halfwit (https://keybase.io/halfwit) on keybase.
* I have a public key ASCqs9oAmZyC6KqH7ePmF4u7-Llp_5aNFQmFPFTofuuCpQo
To claim this, I am signing this object:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom">
<xsl:output method="text"/>
<xsl:template match="/atom:feed">
<xsl:for-each select="atom:entry">
<xsl:value-of select="atom:link/@href"/>
<xsl:text>&#x9;</xsl:text>
<xsl:value-of select="atom:title"/>
<xsl:text>&#10;</xsl:text>
@halfwit
halfwit / statusbar.adoc
Created February 17, 2017 01:41 — forked from Earnestly/statusbar.adoc
Simple reactive statusbar
Table of Contents

The main event loop

statusdir=$XDG_RUNTIME_DIR/statusbar
mkdir -pm0700 "$statusdir"
@halfwit
halfwit / client.py
Created December 9, 2015 18:58 — forked from EyalAr/client.py
Demo code for my post about python's blocking stream reading functions.
from subprocess import Popen, PIPE
from time import sleep
# run the shell as a subprocess:
p = Popen(['python', 'shell.py'],
stdin = PIPE, stdout = PIPE, stderr = PIPE, shell = False)
# issue command:
p.stdin.write('command\n')
# let the shell output the result:
sleep(0.1)

These are only examples, for a few very common actions. You are expected to write your own rules for the rest. The syntax is regular JavaScript, but see the polkit(8) manpage for the object structure and available API.

  • If you don't know the action name, run pkaction:

    pkaction | grep cups
    
  • The possible results are YES, AUTH_SELF(_KEEP), AUTH_ADMIN(_KEEP), NO. Returning a result is final. Returning null will continue checking other rules.

  • Put your rules in /etc/polkit-1/rules.d/*.rules. (You can check everything in one giant addRule, or you can have a separate file and separate addRule for each program; it doesn't matter.)

@halfwit
halfwit / makepkg_overview.rst
Created November 25, 2015 23:44 — forked from Earnestly/makepkg_overview.rst
A brief overview of the process involved in creating a pacman package.

A Brief Tour of the Makepkg Process: What Makes a Pacman Package

Introduction

This is a terse document covering the anatomy of a package built for the pacman package manager.

The following example commands can mostly run verbatim to manually create a

@halfwit
halfwit / fonts.draft
Created November 25, 2015 23:43 — forked from Earnestly/fonts.adoc
Better Defaults for Freetype
FONTS Earnestly
Better Defaults for Freetype
Contents
Introduction ....................................................... 16
Better Defaults .................................................... 43
@halfwit
halfwit / c99_ub_list.rst
Created November 25, 2015 23:43 — forked from Earnestly/c99_ub_list.rst
C99 List of Undefined Behavior (193 Cases)

C99 List of Undefined Behavior

From N1256: (See http://port70.net/~nsz/c/c99/n1256.html#J.2)

  • A "shall" or "shall not" requirement that appears outside of a constraint is violated (clause 4).
  • A nonempty source file does not end in a new-line character which is not immediately preceded by a backslash character or ends in a partial preprocessing token or comment (5.1.1.2).
  • Token concatenation produces a character sequence matching the syntax of a universal character name (5.1.1.2).
  • A program in a hosted environment does not define a function named main using one of the specified forms (5.1.2.2.1).
  • A character not in the basic source character set is encountered in a source file, except in an identifier, a character constant, a string literal, a header name, a comment, or a preprocessing token that is never converted to a token (5.2.1).
  • An identifier, comment, string literal, character constant, or header name contains an invalid multibyte character or does not