Skip to content

Instantly share code, notes, and snippets.

View clavery's full-sized avatar

Charles Lavery clavery

View GitHub Profile
@clavery
clavery / routes.jsx
Last active February 15, 2024 18:03 — forked from sandragolden/routes.jsx
Hybrid Override routes.jsx
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
/* istanbul ignore file */
// NOTE!
// This file is being ignored in the test coverage report for now. It reports `0%` functions
@clavery
clavery / server.js
Last active July 7, 2023 02:44
Simple HTTP Rest Server in Node that operates on a JSON file backend
/*
* Simple API Sample Server
*
* Serves from file ./_data.json writing to arrays with GET, POST, PUT, PATCH, DELETE
*
* Create a _data.json file like:
*
* {
* "todos": [],
* "people": []
@clavery
clavery / frigate_0.10_notification.yaml
Last active February 16, 2023 20:44 — forked from hunterjm/frigate_0.10_notification.yaml
Frigate 0.10 Notifications (w/ occupancy filter list)
blueprint:
name: Frigate Notification (0.10.0 w/ occupancy filter)
description: |
## Frigate Mobile App Notification
This blueprint will send a notification to your device when a Frigate event for the selected camera is fired. The notification will initially include the thumbnail of the detection, but include an actionable notification allowing you to view the clip and snapshot.
With this blueprint, you may send the notification to multiple devices by leaving "Device" blank and instead use a [notification group][1].
### Software Version Requirements
@clavery
clavery / validate.py
Last active September 7, 2022 07:24
"""
SFCC Schema Validator
Author: Charles Lavery <[email protected]>
Requires packages:
- lxml
- jsonschema
Place XSD and JSON schemas in a `./schemas` subdirectory relative to this file (download from
https://documentation.b2c.commercecloud.salesforce.com/DOC3/index.jsp?topic=%2Fcom.demandware.dochelp%2FDWAPI%2Fxsd%2FSchemas.html
@clavery
clavery / pattern_match.py
Created July 27, 2015 04:17
python matching of patterns to guess state names
from difflib import SequenceMatcher
states = {
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
@clavery
clavery / async_await.js
Created July 22, 2015 03:07
async await with babel example
require("babel/polyfill");
document.writeln("async testing; look at console log");
function promiseReturningFunction() {
return new Promise(function(resolve,reject) {
setTimeout( () => resolve("resolved message"), 2000);
});
}
function promiseReturningFunction2() {
@clavery
clavery / component.js
Created February 3, 2015 17:37
ES6 React component w/ mixin support
import React from 'react';
import _ from 'underscore';
var LIFECYCLE_EVENTS = [
'componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
@clavery
clavery / decorators.py
Last active August 3, 2022 16:48
Flask decorator for rate limiting w/ Redis
import logging
import time
from functools import wraps
from flask import request, jsonify
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
logger = logging.getLogger(__name__)
@clavery
clavery / Vagrantfile
Last active August 29, 2015 14:08 — forked from joehinkle/Vagrantfile
Simple PHP vagrant box for Centos 6
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "chef/centos-6.6"
config.vm.provision :shell, path: "bootstrap.sh"
config.vm.network "forwarded_port", guest: 80, host: 8080
@clavery
clavery / Vagrantfile
Last active March 1, 2018 20:14 — forked from joehinkle/Vagrantfile
Simple PHP vagrant box for ubuntu trusty 64 w/ Mysql
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision :shell, path: "bootstrap.sh"
config.vm.network "forwarded_port", guest: 80, host: 8080