This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM node:14-slim | |
| ENV NODE_ENV=production | |
| COPY pnpm-deploy-output /app | |
| WORKDIR /app | |
| ENTRYPOINT ["/app/entrypoint.sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| See https://wicg.github.io/user-preference-media-features-headers/ for more info on the Client Hint | |
| This code will inform the server which color scheme the user prefers. | |
| It can be used to apply to correct classes and prevent a flash of the wrong scheme during load. | |
| */ | |
| export async function handle({ event, resolve }) { | |
| // Read the Color Scheme Client Hint | |
| const colorScheme = event.request.headers.get('Sec-CH-Prefers-Color-Scheme') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { writable } from "svelte/store"; | |
| import { browser } from "$app/environment"; | |
| //string | |
| export const userName = writable( | |
| (browser && localStorage.getItem("userName")) || "hello world" | |
| ); | |
| userName.subscribe((val) => browser && (localStorage.userName = val)); | |
| // array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "" Source your .vimrc | |
| "source ~/.vimrc | |
| "" -- Suggested options -- | |
| " Show a few lines of context around the cursor. Note that this makes the | |
| " text scroll if you mouse-click near the start or end of the window. | |
| "set number relativenumber | |
| set idearefactormode=keep | |
| set ideajoin | |
| set incsearch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // .eslintrc | |
| { | |
| "env": { | |
| "browser": true, | |
| "es6": true, | |
| "node": true | |
| }, | |
| "extends": [ | |
| "react-app", | |
| "plugin:react/recommended", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { PrismaClient } from '@prisma/client' | |
| import Shopify from '@shopify/shopify-api' | |
| import { Session } from '@shopify/shopify-api/dist/auth/session'; | |
| const prisma = new PrismaClient({ log: ['info', 'warn', 'error'] }) | |
| async function storeCallback(session: Session): Promise<boolean> { | |
| const payload: { [key: string]: any } = { ...session } | |
| return prisma.appSession.upsert({ | |
| create: { id: session.id, payload: payload }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| * | |
| FROM | |
| messages, | |
| ( | |
| SELECT | |
| MAX(id) as lastid | |
| FROM | |
| messages | |
| WHERE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| echo "=========== START LOCAL HTTP / HTTPS TUNNEL AND UPDATE YOUR REMOTE DEV DOMAIN TO POINT IT ===========" | |
| printf "\n" | |
| # Start NGROK in background | |
| echo "⚡️ Starting ngrok" | |
| ngrok http 8080 > /dev/null & | |
| # Wait for ngrok to be available | |
| while ! nc -z localhost 4040; do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { writable } from 'svelte/store' | |
| // returns a store with HTTP access functions for get, post, patch, delete | |
| // anytime an HTTP request is made, the store is updated and all subscribers are notified. | |
| export default function(initial) { | |
| // create the underlying store | |
| const store = writable(initial) | |
| // define a request function that will do `fetch` and update store when request finishes | |
| store.request = async (method, url, params=null) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const fetch = require('node-fetch'); | |
| const FormData = require('form-data'); | |
| const filePath = `path/to/file.ext`; | |
| const form = new FormData(); | |
| const stats = fs.statSync(filePath); | |
| const fileSizeInBytes = stats.size; | |
| const fileStream = fs.createReadStream(filePath); | |
| form.append('field-name', fileStream, { knownLength: fileSizeInBytes }); |
NewerOlder