Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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:(notifications@github.com) 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

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 / 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 ()
@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 / 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 / .htaccess
Created April 4, 2018 21:05
Using SSL in production only (set conditional)
# This assumes a, say, virtualhost on your dev machine like the following:
# <Virtualhost *:80>
# # ...
# SetEnv APPLICATION_ENV "development"
# # ...
# </Virtualhost>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:APPLICATION_ENV} !^development$
@paxperscientiam
paxperscientiam / ask.sh
Created February 24, 2018 23:00
Bash General-Purpose Yes/No Prompt Function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# https://djm.me/ask
local prompt default reply
while true; do