#!/bin/bash
if [ $# -gt 0 ] ; then
($@ &) &>/dev/null
else
cat <<-EOM
Usage: gui [COMMAND] [ARG]...
Runs a command in GUI mode, i.e., detached completely from the executing shell and terminal.
If no command is given, this help message is shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import random | |
import webbrowser | |
mods = list(sys.stdlib_module_names) | |
random.shuffle(mods) | |
for mod in mods: | |
if mod[0] == '_': # Skip Internal Modules | |
continue | |
webbrowser.open(f'https://docs.python.org/3/library/{mod}.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and | |
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope | |
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is | |
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. | |
// Placeholders with the same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "scope": "javascript,typescript", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sh | |
# A Random Manpage shows, you read it, then press "q" | |
# ... and then you get the next random manpage | |
# Exit using Ctrl+Z (SIGKILL) | |
for cmd in `man -k . | cut -d ' ' -f1 | shuf`; do | |
man $cmd; | |
done |
Delete all open instances of class CircleMorph
:
CircleMorph allInstances do: [ :circle | circle delete ]
Or, a slightly shorter way:
CircleMorph allInstancesDo: [ :circle | circle delete ]
In HTML, while defining elements, property values can be omitted.
Here, the htmlProps
function takes a list of property keys or values,
and resolves it into a Map
of keys to values by the following rules:
- A Key
followed by a Val
associates the key with the val in result map.
- A Key
followed by another Key
means the first key has value Nothing
in result map.
- A Val
without a Key
before it indicates an error.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webbrowser | |
from tempfile import NamedTemporaryFile | |
def view_html(html: bytes, **kwargs) -> bool: | |
""" | |
Open HTML input string as a webpage in default browser | |
@return - True if page opened successfully, False otherwise | |
""" | |
with NamedTemporaryFile(suffix='.html', delete=False, **kwargs) as f: | |
f.write(html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Mapping | |
def try_keys(obj: Mapping, *keys, default_value=None): | |
""" | |
Tries each given key (in order) on obj (a dict-like object) and | |
returns value of first key found in object. If no key is found in object, | |
then it returns default_value. | |
>>> try_keys({'a': 1}, 'a', 'b', default_value=0) | |
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro with-attrs [obj-exp & args] | |
`(doto ~obj-exp | |
~@(for [[key val] (partition 2 args)] | |
(list (->> key | |
name | |
capitalize | |
(str ".set") | |
symbol) | |
val)))) | |
OlderNewer