Skip to content

Instantly share code, notes, and snippets.

;;; moose-functions.el --- Assortment of functions I find useful. -*- lexical-binding: t; -*-
;; Copyright (C) 2018 Christopher David Ramos
;; Author: Christopher David Ramos <ramos@Jupiter.local>
;; Keywords: convenience
;;; Commentary:
;;; shout out to https://emacs.stackexchange.com/a/358
@paxperscientiam
paxperscientiam / CardService.ts
Last active February 17, 2019 05:26
Wrapper function for GAS CardService.newCardBuilder
// Copyright (C) 2018 Christopher David Ramos
export function _Card(data) {
const objCardBuilder = Object.create(objCardMethods)
const card = CardService.newCardBuilder()
const cardHeader = CardService.newCardHeader()
if (data.name) {
card.setName(data.name)
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1)
}
String.prototype.toTitleCase = function() {
const arrSentence = this.toLowerCase().split(" ")
arrSentence.forEach((word, index, arr) => {
if (word.length > 3) {
arr[index] = word.charAt(0).toUpperCase() + word.slice(1)
}
@paxperscientiam
paxperscientiam / adopting-component-heavy-projects-for-iCloud
Last active February 16, 2019 00:52
[Pro-tip][macOS][iCloud] Renaming components directories for compatibility with iCloud on macOS ~10.14
By default, it's a bad idea to store component heavy projects in an iCloud syncronized directory as the frequent shuffling of hundreds of files puts a heavy burden on the sync service. Moreover, it gets in the way of keeping the important stuff syncronized.
Let's say your project structure looks like this:
~/Documents/project/
└── node_modules
Let's adopt it accordingly:
~/Documents/project/
└── modules.noSync
└── node_modules
function WeatherIconService(WxCondition, isDaytime) {
// https://www.weather.gov/bgm/forecast_terms
// POP Percent Expression of Uncertainty Equivalent Areal Qualifier
// 10 percent (none used) Isolated/ Few
// 20 percent Slight Chance Widely Scattered
// 30, 40, & 50 percent Chance Scattered
// 60 & 70 percent Likely Numerous (or none used)
// 80, 90, & 100 percent (None used) Occasional, periods of, or none used
const TIME = isDaytime ? "DAY" : "NIGHT"
function WeatherIconService(WxCondition, isDaytime) {
// https://www.weather.gov/bgm/forecast_terms
// POP Percent Expression of Uncertainty Equivalent Areal Qualifier
// 10 percent (none used) Isolated/ Few
// 20 percent Slight Chance Widely Scattered
// 30, 40, & 50 percent Chance Scattered
// 60 & 70 percent Likely Numerous (or none used)
// 80, 90, & 100 percent (None used) Occasional, periods of, or none used
const TIME = isDaytime ? "DAY" : "NIGHT"
FROM php:7.3.1-apache
RUN docker-php-ext-install mysqli pdo_mysql pdo && \
docker-php-ext-enable mysqli pdo_mysql pdo
@paxperscientiam
paxperscientiam / transitionToPromise.js
Created December 12, 2018 01:08 — forked from davej/transitionToPromise.js
Do a CSS transition and resolve promise when complete
const transitionToPromise = (el, property, value) =>
new Promise(resolve => {
el.style[property] = value;
const transitionEnded = e => {
if (e.propertyName !== property) return;
el.removeEventListener('transitionend', transitionEnded);
resolve();
}
el.addEventListener('transitionend', transitionEnded);
});
@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;
@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 {