Skip to content

Instantly share code, notes, and snippets.

View ctrlaltdylan's full-sized avatar

Dylan Pierce ctrlaltdylan

View GitHub Profile
@ctrlaltdylan
ctrlaltdylan / shopifyGraphqlClient.js
Created January 5, 2022 11:10
Shopify x-request-id logger with Apollo
import {
ApolloClient,
createHttpLink,
InMemoryCache,
ApolloLink,
} from "@apollo/client";
import fetch from "cross-fetch";
/**
* Shopify x-request-id header logger
@ctrlaltdylan
ctrlaltdylan / mirror.conf
Created January 2, 2016 03:17
The nginx server configuration file needed to host the MirrorMirror application
server {
listen 80;
server_name localhost;
root /home/pi/projects/MirrorMirror/public;
index index.html index.htm index.php;
charset utf-8;
location / {
@ctrlaltdylan
ctrlaltdylan / graphql.js
Last active June 26, 2021 18:35
Proxied Shopify GraphQL NextJS API Endpoint Example ( say that 10 times fast )
import withDb from '../../middleware/withDb'
import { get } from 'lodash'
import httpProxyMiddleware from "next-http-proxy-middleware";
import allowCors from "middleware/allowCors";
import jwt from "jsonwebtoken";
export const config = {
api: {
bodyParser: false,
},
@ctrlaltdylan
ctrlaltdylan / 01_sidekiq_upstart.config
Created December 13, 2019 16:14
EBextension for starting Sidekiq Process on Elasticbeanstalk
files:
"/opt/elasticbeanstalk/support/conf/sidekiq.conf":
mode: "000755"
content: |
description "Elastic Beanstalk Sidekiq Upstart Manager"
start on runlevel [2345]
stop on runlevel [06]
# explained above
respawn
@ctrlaltdylan
ctrlaltdylan / createSearchIndices.js
Last active April 3, 2021 15:19
Mongo Text Searching (with partial matching)
async function createTextSearchIndex(db) {
db.collection("customers").createIndex({
firstName: "text",
lastName: "text",
email: "text",
phone: "text"
});
}
async function createRegexSearchIndex(db) {
@ctrlaltdylan
ctrlaltdylan / vouchedInit.jsx
Last active March 18, 2021 16:06
Vouched extensions example prototype
const vouched = window.Vouched({
appId: { process.env.VOUCHED_API_KEY },
additionalSteps: [
((priorStep, nextStep)) => {
// priorStep is a callback to go back 1 step
// nextStep is a callback that will go to the next step, if none then vouched.onComplete is called
return (
<div>
<h2>Please provide your signature</h2>
@ctrlaltdylan
ctrlaltdylan / deploy.sh
Created September 19, 2018 03:50
Deploying Wordpress with Ansible
ansible-playbook playbook.yml -i hosts.yml -u ubuntu
@ctrlaltdylan
ctrlaltdylan / next.config.js
Created December 10, 2020 18:43
Next config for Heroku to expose public frontend variables at build time
module.exports = {
env: {
NEXT_PUBLIC_SENTRY_DSN: process.env.NEXT_PUBLIC_SENTRY_DSN,
NEXT_PUBLIC_SHOPIFY_API_PUBLIC_KEY: process.env.NEXT_PUBLIC_SHOPIFY_API_PUBLIC_KEY,
},
};
@ctrlaltdylan
ctrlaltdylan / upload.js
Created November 14, 2020 01:38
Browser Axios Cloudinary Upload
let formData = new FormData();
formData.append("upload_preset", "<your preset from Cloudinary Dashboard here> * Required");
formData.append("file", <instance of a File here>);
axios
.post(
"https://api.cloudinary.com/v1_1/<your Cloudinary cloud name here>/image/upload",
formData,
{
@ctrlaltdylan
ctrlaltdylan / compound_search_with_query.js
Created September 11, 2020 00:24
Mongod Text query with compound index
// Create the searchable checks index
db.collection("checks")
.createIndex({ shopName: 1, firstName: "text", lastName: "text" })
.then((res) => {
console.log("checks text index created");
})
.catch((err) => console.log("checks text index creation failed", err));
const checks = await db