Skip to content

Instantly share code, notes, and snippets.

@bainfu
bainfu / tsconfig.json
Created December 22, 2023 18:36
Base config
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
import * as cdk from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as fs from 'fs';
import { Construct } from 'constructs';
// import * as sqs from 'aws-cdk-lib/aws-sqs';
export class PlatformPortalUnrealTSXBroadwayStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
@bainfu
bainfu / SignInForm.jsx
Created June 14, 2023 20:44
Example React Hook
import React, { useState, useEffect } from "react";
export const useForm = (callback, initialValues) => {
const [values, setValues] = useState(initialValues || {});
const [isSubmitting, setIsSubmitting] = useState(false);
const handleSubmit = event => {
if (event) event.preventDefault();
setIsSubmitting(true);
Promise.resolve(callback(values)).then(setIsSubmitting(false));
@bainfu
bainfu / RealmServerlessFunctionCallForUpload.swift
Created March 23, 2021 21:34
The Realm Serverless Function Call to upload a UIImage
import Foundation
import UIKit
import RealmSwift
/**
* @param image - A UIImage probably taken from a UIImagePickerController
* @param fileName - The File Name you might want to have it stored in repo
* @param appUser - The currently logged in Realm User
*/
func functionImageUpload(image: UIImage, fileName: String = "test_file_upload", appUser: User) {
@bainfu
bainfu / realmServerlessCloudinaryFileUpload.js
Last active March 23, 2021 21:23
Realm Serverless Cloudinary Upload Function
exports = async (bsonFileData, fileName, venueId) => {
// Define dependencies
const axios = require('axios');
const crypto = require('crypto');
// Define Variables from context
const cloud_name = context.values.get("cloudinaryAccount"); // <-- Cloudinary Account Name
const api_key = context.values.get("cloudinaryApiKey"); // <-- Cloudinary Public API Key
const api_secret = context.values.get("cloudinarySecretApiKey"); // <-- Links to Secret: Cloudinary Secret API Key