Skip to content

Instantly share code, notes, and snippets.

View longfellowone's full-sized avatar

Matt Wright longfellowone

  • Vancouver, Canada
View GitHub Profile
// _app.tsx
import "../styles/globals.css";
import type { AppProps } from "next/app";
import { useEffect } from "react";
import * as Fathom from "fathom-client";
import { useRouter } from "next/router";
function MyApp({ Component, pageProps }: AppProps) {
const router = useRouter();
@longfellowone
longfellowone / .rs
Last active February 21, 2022 18:59
use async_graphql::ID;
use serde::Serialize;
use server::config::{Configuration, Http, Postgres};
use server::http::App;
use sqlx::{Executor, PgPool};
use uuid::Uuid;
pub struct TestApp {
pub addr: String,
pub pool: PgPool,
mod common;
#[cfg(test)]
mod tests {
use crate::common::{TestApp, Vars};
use async_graphql::ID;
use gql_client::Client;
use serde_json::Value;
use server::error::AppError;
use server::http::project::resolver::Project;
@longfellowone
longfellowone / rust-xp-03-redis.rs
Created October 11, 2021 18:04 — forked from jeremychone/rust-xp-03-redis.rs
Rust Redis with Async/Await (single threaded concurrency) | RustLang by example
#![allow(unused)] // silence unused warnings while exploring (to comment out)
use std::{error::Error, time::Duration};
use tokio::time::sleep;
use redis::{
from_redis_value,
streams::{StreamRangeReply, StreamReadOptions, StreamReadReply},
AsyncCommands, Client,
};
@longfellowone
longfellowone / Dockerfile
Created August 15, 2020 16:13 — forked from terry90/Dockerfile
Rust Dockerfile to build really small containers with postgres and SSL (~20Mo with rocket and diesel). Dependencies are cached for faster builds.
FROM clux/muslrust as build
WORKDIR /app/
# Deps caching begins
COPY Cargo.toml .
COPY Cargo.lock .
RUN mkdir src
RUN echo "fn main() {}" > src/main.rs
package main
import (
"encoding/csv"
"fmt"
"log"
"os"
"path/filepath"
"strings"
"time"
// https://stackoverflow.com/questions/37069186/calculate-working-days-between-two-dates-in-javascript-excepts-holidays
$(document).ready(() => {
$('#calc').click(() => {
var d1 = $('#d1').val();
var d2 = $('#d2').val();
$('#dif').text(workingDaysBetweenDates(d1,d2));
});
});
import React from 'react';
import { Provider1, Provider2, Provider3 } from './';
function ProviderComposer({ contexts, children }) {
return contexts.reduceRight(
// kids = accumulator, parent = currentValue
(kids, parent) =>
React.cloneElement(parent, {
children: kids
}),
func (r *mutationResolver) UpdateUser(ctx context.Context, input UpdateUser) (User, error) {
var fields = bson.M{}
var user User
update := false
if input.First != nil && *input.First != "" {
fields["first"] = *input.First
update = true
}
@longfellowone
longfellowone / .js
Last active April 29, 2019 17:27
Purchasing tempalte
import React, { useState } from "react";
import ReactDOM from "react-dom";
import "./styles.css";
import { orders } from "./models";
const App = () => {
const [currentOrder, setCurrentOrder] = useState(null); // orders[0]
const [searchFocused, setSearchFocused] = useState(false);