Skip to content

Instantly share code, notes, and snippets.

@carsonwright
carsonwright / nextInLineHooksEmbedExample.js
Created February 19, 2024 20:19
Next In Line Hooks Embed
// nextInLine = NextInLine.Init({
// ...etc.
// })
// After this /\
nextInLine.events.on("Filters.componentDidSubmit", ()=>{
console.log("Filters DID SUBMIT")
})
nextInLine.events.on("TimeSlots.componentDidSubmit", ()=>{
@carsonwright
carsonwright / livechatscript.js
Created February 9, 2023 17:09
livechatscript.js
var param=window.location.host,page=param+window.location.pathname;
function callKontakScripts(){
var e=httpGet("https://dev-js-management.getkontak.com/api/v2/chat/snippet?param="+param),e=JSON.parse(e);
""!==e&&e.forEach(function(e){var t;
null!==e.pages&&!e.pages.includes(page)||(t=e.code.replace(/<\/script>/,"").replace(/<script>/,""),(e=document.createElement("script")).innerHTML=t,document.body.appendChild(e))})}function httpGet(e){var t=new XMLHttpRequest;
return t.open("GET",e,!1),t.send(null),t.responseText
}
callKontakScripts();
mutation {
createAppointment(
businessId: "an id goes here"
input: {
clientId: "an id goes here"
patientId: "an id goes here"
resources: [
{
employeeId: "an id goes here",
responsibilityId: "an id goes here"
@carsonwright
carsonwright / Pets Favorite Vet
Created October 18, 2021 21:55
Pets Favorite Vet Example
<!-- PLACE THIS SOMWHERE IN THE BODY -->
<div id="nsa-widget"></div>
<!-- PLACE THIS IN THE FOOTER PLUGIN-->
<script type="text/javascript">
var script = document.createElement('script');
script.onload = function() {
var widgetContainer = document.querySelector('#nsa-widget');
var query = window.location.search.substring(1);
var params = {};
import React, { Component } from "react";
import "./styles.css";
/*
* FAKE AXIOS
*/
const axios = {
get: async () => ({
data: [
{
@carsonwright
carsonwright / example.js
Last active October 23, 2020 18:06
example.js
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import axios from 'axios';
const Exercise = props => (
<tr>
<td>{props.exercise.username}</td>
<td>{props.exercise.description}</td>
<td>{props.exercise.duration}</td>
<td>{props.exercise.date.substring(0, 10)}</td>
class Store {
static set(values){
this.value = values
}
static extend(values){
this.value = {
...this.value,
...values
}
}
@carsonwright
carsonwright / pile.js
Last active October 29, 2019 16:59
an idea for making promises suck less
module.exports = (data = {}, promises)=>(
new Promise((resolve, reject)=>{
const promiseKeys = Object.keys(promises)
Promise.all(promiseKeys).then((responses)=>{
for(let [i, response] of responses.entries()){
data[promiseKeys[i]]=response
}
resolve(data)
}).catch((error)=>{
reject(error)
@carsonwright
carsonwright / proposalA.js
Last active October 29, 2019 16:23
Proposal for the reduction of promise chain grossness
let chain = {};
promiseA().then((users)=>{
chain.users = users
return PromiseB()
}).then((accounts)=>{
chain.accounts = accounts
return PromiseC()
}).then((patients)=>{
chain.patients = patients
// do stuff with chain
const currentOrganization = (state=null, {type, payload})=>{
console.log("RUNNING CURRENT ORGANIZATION!")
switch(type){
case 'SET_ORGANIZATION':