Skip to content

Instantly share code, notes, and snippets.

View markmals's full-sized avatar

Mark Malstrom markmals

View GitHub Profile
import crypto from "crypto";
import { renderToStaticMarkup } from "react-dom/server";
import createMailgun from "mailgun-js";
import type { ActionFunction, LoaderFunction, Session } from "remix";
import { createCookieSessionStorage, json, redirect } from "remix";
/*******************************************************************************
* Before we can do anything, we need to make sure the environment has
* everything we need. If anything is missing, we just prevent the app from
* starting up.
@icanzilb
icanzilb / Result+Task.swift
Created September 14, 2021 15:36
Result initialized with an async operation
extension Result where Failure == Error {
init(_ task: @escaping () async throws -> Success) async {
self = await withCheckedContinuation { [task] continuation in
Task {
do {
continuation.resume(returning: .success(try await task()))
} catch {
continuation.resume(returning: .failure(error))
}
}
import UIKit
import SwiftUI
// Hacky workaround, use at your own risk and all that
struct BottomSheetPresenter<Content>: UIViewRepresentable where Content: View{
let label: String
let content: Content
let detents: [UISheetPresentationController.Detent]
init(_ label: String, detents: [UISheetPresentationController.Detent], @ViewBuilder content: () -> Content) {
##[[
cflags '-I/usr/include/tensorflow'
linklib 'tensorflow'
cinclude '<tensorflow/c/c_api.h>'
]]
global TF_AttrType: type <cimport, nodecl, using> = @enum(cint){
TF_ATTR_STRING = 0,
TF_ATTR_INT = 1,
TF_ATTR_FLOAT = 2,
TF_ATTR_BOOL = 3,
<?
//
// AUTO KEYWORD-BASED FOLLOWER CURATION BOT (by @levelsio)
//
// File: twitterFollowerCuratorBot.php
//
// Created: May 2021
// License: MIT
//
import Cocoa
import Foundation
class Person {
var age: Int
var name: String
init(age: Int, name: String) {
self.age = age
self.name = name
@ryanflorence
ryanflorence / entry-server.tsx
Last active August 4, 2022 06:46
Remix + Styled Components
import ReactDOMServer from "react-dom/server";
import type { EntryContext } from "@remix-run/core";
import Remix from "@remix-run/react/server";
import { renderToString } from "react-dom/server";
import { ServerStyleSheet } from "styled-components";
import StylesContext from "./stylesContext";
export default function handleRequest(
request: Request,
@ben-rogerson
ben-rogerson / twin.code-snippets
Last active June 16, 2023 02:22
Twin Code Snippits for use in vscode - Shortcuts that make working with Twin a little easier
{
// Snippits that make working with Twin a little easier
// https://github.com/ben-rogerson/twin.macro
"Add react import": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "react",
"body": "import React from 'react'",
"description": "Add react import"
},
"Add twin imports": {
@davidsteppenbeck
davidsteppenbeck / PreviewProviderModifier.swift
Last active October 31, 2022 10:30
A SwiftUI view modifier for simple preview providers.
import SwiftUI
enum PreviewProviderMode: CaseIterable {
/// Use for a light appearance preview.
case lightMode
/// Use for a dark appearance preview.
case darkMode
const fetch = require('node-fetch');
async function run() {
let username = "YOUR USERNAME HERE";
let password = "YOUR APP PASSWORD";
let authBasic = new Buffer(username + ':' + password).toString('base64');
let session = await (await fetch('https://jmap.fastmail.com/.well-known/jmap', {
headers: {
"Authorization": "Basic " + authBasic
}
})).json();