Skip to content

Instantly share code, notes, and snippets.


Chris paxperscientiam

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

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


$a1 = [
  'a' => 'foo',
  'b' => ['bar']
$a2 = [
  'a' => 'bar',
paxperscientiam /
Created May 24, 2019 — forked from domenic/
You're Missing the Point of Promises

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.
paxperscientiam / transitionToPromise.js
Created Dec 12, 2018 — forked from davej/transitionToPromise.js
Do a CSS transition and resolve promise when complete
View transitionToPromise.js
const transitionToPromise = (el, property, value) =>
new Promise(resolve => {[property] = value;
const transitionEnded = e => {
if (e.propertyName !== property) return;
el.removeEventListener('transitionend', transitionEnded);
el.addEventListener('transitionend', transitionEnded);
paxperscientiam / browser_detect.js
Created Dec 11, 2018 — forked from 2107/browser_detect.js
JavaScript: Detect Browser
View browser_detect.js
// 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;
paxperscientiam / media-queries.css
Created Oct 17, 2018 — forked from hemantajax/media-queries.css
Very useful media queries snippets
View media-queries.css
/* 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) {

Gmail and GitHub

Create new filters and create new labels.

Pull Request

from:( 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

View Apps Script Gmail

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 /
Created Feb 24, 2018 — forked from davejamesmiller/
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() {
local prompt default reply
while true; do
paxperscientiam / camelCase.js
Created Nov 15, 2017 — forked from johnsmith17th/camelCase.js
To convert string to camel case in javascript.
View camelCase.js
function toCamelCase(str) {
return str.toLowerCase().replace(/(?:(^.)|(\s+.))/g, function(match) {
return match.charAt(match.length-1).toUpperCase();

SSH agent forwarding and screen

When connecting to a remote server via SSH it is often convenient to use SSH agent forwarding so that you don't need a separate keypair on that server for connecting to further servers.

This is enabled by adding the

ForwardAgent yes

option to any of your Host entries in ~/.ssh/config (or alternatively with the -A option). Don't set this option in a wildcard Host * section since any user on the remote server that can bypass file permissions can now als use keys loaded in your SSH agent. So only use this with hosts you trust.

You can’t perform that action at this time.