Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris paxperscientiam

View GitHub Profile
@paxperscientiam
paxperscientiam / array_extend_recursive.md
Created Aug 3, 2020 — forked from adrian-enspired/array_extend_recursive.md
array_merge|replace_recursive are frustrating.
View array_extend_recursive.md

say you have two arrays, $a1 and $a2, and you want to combine them.

<?php

$a1 = [
  'a' => 'foo',
  'b' => ['bar']
];
$a2 = [
  'a' => 'bar',
@paxperscientiam
paxperscientiam / low-battery.bash
Created Feb 22, 2020
macos low battery notifications (cron)
View low-battery.bash
#!/usr/bin/env bash
declare -x GEM_HOME=/usr/local/ruby-lang/Gems
declare -x GEM_PATH=/usr/local/ruby-lang/Gems
if pmset -g batt | grep -Eo "Battery Power"
then
x=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1) && [[ $x -lt 50 ]] && /usr/local/ruby-lang/Gems/bin/terminal-notifier -ignoreDnD -title "battery status" -message "low battery (${x}%)"
fi
@paxperscientiam
paxperscientiam / tmux-xpanes-implementation-example.bash
Created Feb 14, 2020
tmux-xpanes-implementation-example.bash
View tmux-xpanes-implementation-example.bash
#!/usr/bin/env bash
unset CDPATH
PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/opt/local/bin
function title ()
{
echo -ne "\033]0;"$*"\007"
View req.js
const path = require('path');
function Req(base) {
this.base = base;
}
Req.prototype.get = function(module, opts) {
if (typeof require(path.resolve(this.base, module)) === 'function' && opts !== undefined) {
return require(path.resolve(this.base, module))(opts)
} else {
View demo.gif
GIF89aYw!ÿ NETSCAPE2.0!ù9,Y‡

     +!.4&%$)!*#.16" 5&;4:2*(#(,4+2)$894+#3.293(3325D%:C0,B7<D87U)B;>B.9C;8Q?+CG,FS8FK;IR8QK:SV;TcBJ+A-"E8(D<4T;&S>2k7i<#C9@NMJB+HD8OX$JQ;WE)UH8XY%ZT:WeZc*oBkS5pj7GHFCLTKRJITYTLERNSWUHTZZHKjJYbF[pT\bV[vZb[KdgLfrZcdWjtYqm[sxfZJb^eidIgeXlp[yhGujWzuGzsYeigflqkqkjttsldslpvuivzv[r‚gmƒhy„j}•w|„u}™vx¡|€;~D{yjƒˆlˆ—z„…uŠ—y’Žx’šz—®} ¹=ƒ=!ƒD‹R*Ži8¢\*¯l2…\AˆuR†zk§zKÇz7€~…„<±>•…Y‰ƒh‡…xŽ’{˜‡e•Šwœ“f™’y§[¬•j¸¢[¸£r΅;͓KŜlÓ§Pɬvç°Uå³oØÌ\ÛÃxïÎ_éÌrùí{‡‰…‡Œ•Œ‘‰‰”–”Œƒ“Ž“–•ˆ—™–ƒ‹¨…›ªƒ³”œ¦•žºŒ¡›› ‹œ¡™Š¡¬ˆ£·™¤¨”¨·™°¹¥›ˆ¨¢Š§¥—­°›·§‡²¬˜»±‰¸²›§©¦¤«´«²¨¨µ¸²­¤±®º¶¶¨·¸¶®Ã¢¨Âª¹Ä©¼Ô³¼Ä±»Ó»Á¹žÂÑ«Â̧ÇÖ®ÑÛ¶ÆɸÊÔ¼ÑÉ»ÑÙ¶Ûé½áíζˆÂ¼©å»‡ØÎËǵÝä¸é̐éدóæ”õé´ÈÉÆÄÍÓÌÒÊÅÕÛÑÎÄÓÎÑÖÕÉÜÜÛÌÛâÚâØÆæíÈéòÎðôØåæÑíòÐðïÔñôâÜÍâÞáïíÓååååíðêòëêóòðîåðîò÷÷éôôôÿñ H° Áƒ*\È°¡Ã‡#JœH±¢Å‹3jÜȑà¿A~Ä÷Qdɓ(Sª\ɲ¥Ë—0cʜI³¦Í›8sêÜɳ§ÏŸ@ƒ
View moose-tooltip.scss
@mixin moose-tooltip($message) {
position: relative;
display: inline-block;
text-decoration: underline dotted blue;
&::before {
opacity: 0;
}
&:hover::before {
opacity: 1;
font-size: 0.8rem;
@paxperscientiam
paxperscientiam / promises.md
Created May 24, 2019 — forked from domenic/promises.md
You're Missing the Point of Promises
View promises.md

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
    // the rest of your code goes here.
View moose-functions.el
(defun dsedivec/called-via-key-binding (cmd)
"Returns non-nil if `this-command-keys' is bound to CMD."
(eq (key-binding (this-command-keys)) cmd))
(defun moose/popup-count-words-region (start end)
"Get word count for positive length active region."
(interactive "r")
(cond ((and (use-region-p)
(dsedivec/called-via-key-binding #'moose/popup-count-words-region))
View moost-test.el
(defun moose/popup-count-words-region (start end &optional args)
"Get word count for positive length active region."
(interactive "r\np")
(cond ((and (use-region-p)
(eq this-command 'moose/popup-count-words-region))
(let ((print-escape-newlines t))
(popup-tip (concat (number-to-string (count-words start end)) " words"))))))
View moost-test.el
(defun moose/popup-count-words-region (start end)
"Get word count for positive length active region."
(interactive "r")
(cond ((and (use-region-p)
(> (region-end) (region-beginning))
(eq this-command 'moose/popup-count-words-region))
(let ((print-escape-newlines t))
(popup-tip (concat (number-to-string (count-words start end)) " words"))))))
You can’t perform that action at this time.