Skip to content

Instantly share code, notes, and snippets.

@paxperscientiam
paxperscientiam / input.bash
Created June 5, 2018 03:40
emacs socket input
CMD=$'(mapcar '"'"'buffer-name (remove-if-not #'"'"'buffer-file-name (buffer-list)))'
read -r result < <(nc -U "${socket}" <<< \
$"-eval ${CMD// /&_}" | \
awk $'FNR == 2 {printf $2}')
@paxperscientiam
paxperscientiam / vhosts.bash
Last active June 22, 2018 03:56
Neatly list Apache virtual hosts
APACHECTL='/path/to/apachectl'
HTTPD_CONFIG='/path/to/httpd.conf'
printf '%s\n' "Server alias list:"
while IFS='' read -r line; do
if [[ $line =~ alias*(.+) ]]; then
printf '%s\n' "${BASH_REMATCH[1]}"
fi
done < <("${APACHECTL}" -f "${HTTPD_CONFIG}" -S)
@paxperscientiam
paxperscientiam / xpanes-schemes.bash
Last active August 4, 2018 03:24
Example implementation of tmux-xpanes with iTerm2
#!/usr/bin/env bash
# Check out tmux-xpanes: https://github.com/greymd/tmux-xpanes
unset CDPATH
PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/opt/local/bin
function title ()

Google Apps Script Gmail Utilities

##sendAndLabel(recipient, subject, body, options, label)##

An alternative to GmailApp.sendEmail(), which applies a label to the message thread in the sender's account.

Sends an email message with optional arguments. The email can contain plain text or an HTML body. The size of the email

@paxperscientiam
paxperscientiam / gmail-github-filters.md
Created August 30, 2018 05:08 — forked from ldez/gmail-github-filters.md
Gmail and GitHub - Filters

Gmail and GitHub

Create new filters and create new labels.

Pull Request

from:([email protected]) AND {"Patch Links" "approved this pull request." "requested changes on this pull request." "commented on this pull request." "pushed 1 commit." "pushed 2 commits." "pushed 3 commits."}

label: gh-pull-request

@paxperscientiam
paxperscientiam / message_emacs_daemon.bash
Last active September 20, 2018 09:37
Querying and commanding an emacs daemon with nc
#!/usr/bin/env bash
# usage:
# message_daemon $'(length (frame-list))' /path/to/socketfile
# => 2
message_daemon () {
local result
local socket
local CMD="${1}"
@paxperscientiam
paxperscientiam / search_rc
Last active September 19, 2018 23:26
Looks in PWD and above for a certain file
#!/usr/bin/env bash
shopt -s extglob
function search_rc() {
local path_test="${PWD//${HOME}}"
if [[ ${#PWD} -eq ${#path_test} ]]; then
printf '%s\n' "Will not search below HOME"
return 1
fi
@paxperscientiam
paxperscientiam / media-queries.css
Created October 17, 2018 22:24 — forked from hemantajax/media-queries.css
Very useful media queries snippets
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
@paxperscientiam
paxperscientiam / tool-tip.scss
Created November 16, 2018 06:47
Example of using SCSS for tool-tips (no javascript)
// note that you'll need to edit out variables for this to work. Also, this isn't guaranteed to work!
@mixin moose-tooltip($message) {
position: relative;
display: inline-block;
text-decoration: underline dotted $oc-blue-3;
&::before {
opacity: 0;
}
&:hover::before {
@paxperscientiam
paxperscientiam / browser_detect.js
Created December 11, 2018 21:41 — forked from 2107/browser_detect.js
JavaScript: Detect Browser
// browser detect
var BrowserDetect = {
init: function() {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function(data) {
for (var i = 0; i < data.length; i++) {
var dataString = data[i].string;