Skip to content

Instantly share code, notes, and snippets.

node_modules/@openzeppelin
└── contracts
├── README.md
├── access
│ ├── AccessControl.sol
│ ├── AccessControlEnumerable.sol
│ ├── IAccessControl.sol
│ ├── IAccessControlEnumerable.sol
│ └── Ownable.sol
├── build
@ChristianOConnor
ChristianOConnor / gist:de62cfe1f29dfde059a67dec914df6f6
Created March 23, 2022 19:24
nuxt express backend auth fail 03/23/22
<myusername>@<mycomputername> appBackend % npm run dev
> appbackend@0.0.0 dev
> nodemon --exec babel-node ./src/bin/www
[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `babel-node ./src/bin/www`
@ChristianOConnor
ChristianOConnor / handler.ts
Last active April 25, 2022 00:37
Sanitized Cloudflare Worker Tweet Through API Example (handler.ts)
function getRandomString(length) {
const randomChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
for ( let i = 0; i < length; i++ ) {
result += randomChars.charAt(Math.floor(Math.random() * randomChars.length));
}
return result;
}
function hexToBase64(str) {
const stringChange = str.toString()
@ChristianOConnor
ChristianOConnor / index.ts
Created April 25, 2022 00:59
Sanitized Cloudflare Worker Tweet Through API Example (index.ts)
import { handleRequest } from './handler'
addEventListener('fetch', (event) => {
event.respondWith(handleRequest(event.request))
})
@ChristianOConnor
ChristianOConnor / index.tsx
Created April 29, 2022 22:31
DynamicComponentWithNoSSR attempt 042922 pages/
import Header from '../components/Header';
import Footer from '../components/Footer';
import dynamic from 'next/dynamic'
const DynamicComponentWithNoSSR = dynamic(
() => import('../components/Middle'),
{ ssr: false }
)
export default function Home() {
@ChristianOConnor
ChristianOConnor / Middle.tsx
Created April 29, 2022 22:37
DynamicComponentWithNoSSR attempt 042922 components/
import React from 'react';
import { Button } from 'react-bootstrap';
import { GoogleAuth } from 'google-auth-library';
const url = "https://us-central1-<projectId>.cloudfunctions.net/<functionName>";
const keyFilename = "/path/to/key.json";
class Middle extends React.Component {
async main() {
const auth = new GoogleAuth({keyFilename: keyFilename})
@ChristianOConnor
ChristianOConnor / index.ts
Created June 24, 2022 20:41
Use localStorage for Variable Persistence - Psuedo Code
export default function Home(props: any) {
...
function storePersistence() {
window.localStorage.setItem('personName', 'Firstname Lastname');
}
function printPersistence() {
console.log(window.localStorage.getItem('personName'));
@ChristianOConnor
ChristianOConnor / error-062422-printout-and-code.md
Last active June 25, 2022 05:06
TypeError: res.header is not a function 062422

This is the code:

export async function getServerSideProps({ req, res, query }) {
  const { id } = query
  const cookies = Cookies(req, res)
  const jwt = cookies.get('lit-auth')
  if (!jwt) {
    return {
      props: {
        authorized: false
@ChristianOConnor
ChristianOConnor / islands-Creator.tsx
Created September 17, 2022 00:13
fresh app Creator Island 092622
// import { useState } from "preact/hooks";
import { useState, useEffect } from "preact/hooks";
import { Handlers, PageProps } from "$fresh/server.ts";
import UserDb from "../database.ts";
interface CreatorProps {
email: string,
key: string
}
@ChristianOConnor
ChristianOConnor / routes-api-createUser.tsx
Created September 17, 2022 00:14
fresh app Creator Island 092622
import { Handlers, PageProps } from "$fresh/server.ts";
import UserDb from "../../database.ts";
export const handler = {
POST: async (request, ctx) => {
console.log(await request.json());
if (!request.hasBody) {
ctx.status = 400;
ctx.body = { msg: "Invalid user data" };
return ;