Skip to content

Instantly share code, notes, and snippets.

View camsloanftc's full-sized avatar

Cam Sloan camsloanftc

  • Squamish, Canada
View GitHub Profile
@lawrencecchen
lawrencecchen / tinysync.ts
Created July 19, 2022 08:26
A Typescript first queue/job/schedule engine.
// i like trpc. i like autocomplete. i like vercel/serverless.
// netlify acquired quirrel.
// theo would shill for a type safe option.
// there's a gap for a type-safe scheduling/cron/queuing/realtime and i want to fill it.
// also, quirrel has weird syntax for
// framing: typescript-first bindings for what you would typically use redis for
const appRouter = createRouter();
https://jennamolby.com/how-to-use-cookies-to-capture-url-parameters/
let YOUR_DOMAIN = "YOUR_DOMAIN.TLD" // ex: scrapingbee.com
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
import React from 'react';
import { BLOCKS } from '@contentful/rich-text-types';
import { documentToHtmlString } from './lib';
import BlogPostBlockquoteEmoji, {
contentfulId as BLOCKQUOTE_EMOJI,
} from '../BlogPostBlockquoteEmoji';
import BlogPostCaption, { contentfulId as CAPTION } from '../BlogPostCaption';
import BlogPostColumns, { contentfulId as COLUMNS } from '../BlogPostColumns';
import BlogPostImage from '../BlogPostImage';
@oakley808
oakley808 / saga-polling.js
Created October 6, 2016 15:47
A recipe for polling an API in redux-saga
export function* main() {
const { payload } = yield take(SOME_START_SIGNAL);
const watcherInstance = yield fork(updateResource, payload);
// cancel task instance on location change
yield take(LOCATION_CHANGE);
yield cancel(watcherInstance);
}
function* updateResource(id) {
@discopatrick
discopatrick / sync-dev.yml
Last active January 19, 2022 16:36
A playbook for use with roots/trellis syncing the local wordpress db and uploads folder to a remote installation.
---
- name: sync uploads and db from staging to local
hosts: my_staging_host
remote_user: "{{ web_user }}"
pre_tasks:
- name: Ensure site is valid
connection: local
fail:
msg: "Site `{{ site | default('') }}` is not valid. Available sites to sync: {{ wordpress_sites.keys() | join(', ') }}"
@biilmann
biilmann / readme.md
Created October 14, 2015 22:07
Quick Guide to Private NPM Modules on Netlify

Using NPM Private Modules on Netlify

Create a .npmrc file for your project like this:

//registry.npmjs.org/:_authToken=${NPM_TOKEN}

Then find your token inside the ~/.npmrc file in your home folder and set it as an NPM_TOKEN environment variable through netlify's admin UI.

@n1k0
n1k0 / pre-commit
Created July 7, 2015 13:07
This git pre-commit hook checks for .only remaining in js mocha test files and prevent commiting if any.
#!/bin/sh
# This checks for .only remaining in js mocha test files and prevent
# commiting if any.
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object