Skip to content

Instantly share code, notes, and snippets.

@patricksimpson
patricksimpson / static-search.js
Created Jan 14, 2019
A little search for static sites, using Lunr.js!
View static-search.js
(function() {
if (window.fetch) {
let searchPage = document.querySelector('.search-body');
if (searchPage) {
let addLunr = document.createElement('script');
addLunr.src = '/static/js/lunr.js';
document.body.appendChild(addLunr);
addLunr.onload = function() {
fetch('/lunr.json').then(function(response) {
return response.json();
View keybase.md

Keybase proof

I hereby claim:

  • I am patricksimpson on github.
  • I am patricksimpson (https://keybase.io/patricksimpson) on keybase.
  • I have a public key ASBhv__xF1M8Vi8U7sqEiLz5uVBSlopVhbY8oGlmIG_BSQo

To claim this, I am signing this object:

View debug-server.txt
uptime # uptime and CPU stress
w # or better yet:last |head # who is/has been in
netstat -tlpn # find server role
df -h # out of disk space?
grep kill /var/log/messages # out of memory?
View vpnstart.sh
keychainItem=vpn # this name has to match "Account" for the entry you make in keychain
VPNName="" # match the name of the VPN service to run
function isnt_connected () {
scutil --nc status "$VPNName" | sed -n 1p | grep -qv Connected
}
get_pw () {
security 2>&1 >/dev/null find-generic-password -ga $keychainItem \
@patricksimpson
patricksimpson / module.js
Last active Apr 16, 2020
JavaScript Design Patterns
View module.js
var options = {
username: 'blah',
server: '127.0.0.1'
};
var ConfigObject = (function(params) {
var username = params.username || '',
server = params.server || '',
password = params.password || '';
@patricksimpson
patricksimpson / fix-mysql-5-7
Created Feb 23, 2017
fix mysql 5.7 on macos serria
View fix-mysql-5-7
If you have installed mysql 5.7 using homebrew, on macos serria
Edit your file ~/.my.cnf ( If it does not exist, create it. )
Add the following lines:
[mysqld]
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Save and exit the file.
View chickendoor.cpp
int led = D0;
void setup() {
// This part is mostly the same:
pinMode(led,OUTPUT); // Our LED pin is output (lighting up the LED)
Particle.subscribe("opendoor", myOpen);
Particle.subscribe("closedoor", myClose);
digitalWrite(led, HIGH);
delay(2500);
View removeURLParam.js
var removeURLParam = function (url, parameter) {
var fragment = url.split('#'),
urlparts= fragment[0].split('?'),
urlBase = '',
queryString = '',
prefix = '',
pars = null,
i = 0;
if (urlparts.length>=2)
View Symbol.js
const MY_KEY = Symbol();
let obj = {
[MY_KEY]: 123
};
"use strict";
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
View circle.yml
general:
artifacts:
- "~/artifact_example.tar.gz"
machine:
php:
version: 5.6.2
test:
override: