Skip to content

Instantly share code, notes, and snippets.

View acoyfellow's full-sized avatar
🤖
Building

Jordan Coeyman acoyfellow

🤖
Building
View GitHub Profile
@acoyfellow
acoyfellow / test.html
Created September 16, 2022 20:06
Add URL parameters into formData
<script>
window.beforePost= function(){
params.forEach(function(param){
formData[param.key]= param.val;
});
};
</script>
@acoyfellow
acoyfellow / example.html
Created March 15, 2022 23:03
Phonesites Custom Redirect
<!-- add this code to a Code block. Style with "style" and "class" attributes -->
<button
onclick="window.location= redirect;"
style=""
class="button-reset pv3 tc ba b--transparent bg-animate pointer w-100 br2">
Click Me
</button>
<!-- add this to a page's Custom Code > Below Body -->
@acoyfellow
acoyfellow / example.html
Created March 15, 2022 22:54
Phonesites.com redirect based on "referrerId" URL parameter
<script>
function beforePost(){
var referrerId= params.filter(function(p){
return p.key==='referrerId'
})[0]||{};
// add a new line for each referrer.
if(referrerId.val==='google'){ redirect = "https://google.com" };
};
</script>
@acoyfellow
acoyfellow / service-worker.js
Last active December 15, 2021 14:36
Svelte Kit service worker (does not cache external URLs)
import { timestamp, build, files } from '$service-worker';
const name = `cache-${timestamp}`;
self.addEventListener('install', (event) => {
event.waitUntil(caches.open(name).then((cache) => cache.addAll(['/', ...build, ...files])));
});
self.addEventListener('activate', (event) => {
event.waitUntil(
@acoyfellow
acoyfellow / url-params-inject.html
Created December 3, 2021 20:52
Phonesites Script: Add URL variables into form data
<script>
function beforePost(){
window.params.forEach(function (param) {
formData[param.key]= param.val;
});
};
</script>
@acoyfellow
acoyfellow / cookies-popup.html
Created December 2, 2021 18:12
Cookies Popup Example
<script src="https://unpkg.com/optkit@latest/index.js"></script>
<script>
const acceptedCookies = localStorage.getItem('acceptedCookies');
if(!acceptedCookies){
let optKit = new OptKit({target:document.body})
const testConfirm = async (_) => {
let confirmed = await confirm("Do you accept cookies?");
if (!confirmed) return window.location="https://google.com";
localStorage.setItem('acceptedCookies', true);
};
@acoyfellow
acoyfellow / storage.sol
Last active November 28, 2021 14:35
Example of a simple smart contract
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* @title Storage
* @dev Store & retrieve value in a variable
*/
contract Storage {
uint256 number;
/**
* @dev Store value in variable
@acoyfellow
acoyfellow / stephane.html
Created October 26, 2021 14:38
Stephane Storm Code Snippet
<a href="https://stephanestorm.groovepages.com/ouvrezuncomptegratuit"
class="link relative button-reset pa3 db tc ba b--transparent bg-animate pointer w-100 br2 fw8"
target="_blank">
Plateforme Marketing Digitale
</a>
<details class="pv1 ph2 ph4-ns mw6 center cf tc">
<summary class="bg-blue link relative button-reset pv3 white db tc ba b--transparent bg-animate pointer w-100 br2 fw8">
Details
</summary>
<ul class="list pl0 ml0 center mw6 ba b--light-silver br3">
<li class="ph3 pv2 bb b--light-silver">
<a href="#">Top Option</a>
</li>
<li class="ph3 pv2 bb b--light-silver">
<a href="#">Middle Option(s)</a>
@acoyfellow
acoyfellow / stripe.js
Created September 27, 2021 14:16
Stripe Stuff
//pseudocode, a mix of frontend + backend javascript:
//step1 (frontend):
const checkout = async () => {
try {
let resp = await fetch(`/api/checkout`, {
method: "POST",
headers: {
"content-type": "application/json",
},