Skip to content

Instantly share code, notes, and snippets.

View longfellowone's full-sized avatar

Matt Wright longfellowone

  • Vancouver, Canada
View GitHub Profile
<div class="bg-green">
<div class="container mx-auto">
<ul class="md:flex list-reset">
<li class="hover:bg-grey p-4"><a href="#">Link 1</a></li>
<li class="hover:bg-grey p-4"><a href="#">Link 2</a></li>
<li class="hover:bg-grey p-4"><a href="#">Link 3</a></li>
<li class="hover:bg-grey p-4"><a href="#">Link 4</a></li>
<li class="hover:bg-grey p-4"><a href="#">Link 5</a></li>
</ul>
</div>
<div class="inline-flex w-full justify-center">
<ul>
<li>5</li>
<li>4</li>
<li>3</li>
<li>2</li>
<li>1</li>
</ul>
</div>
@longfellowone
longfellowone / .js
Last active December 31, 2018 02:52
Javascript bold or replace character in string at index position
// Working example
// https://codesandbox.io/s/lr5zjxrn67
// Method #1
function replaceAt(string, indexArray) {
let newString = [...string];
for (let i = 0; i < indexArray.length; i++) {
newString = Object.assign(newString, {
[indexArray[i]]: <b>{newString[indexArray[i]]}</b>
@longfellowone
longfellowone / ObserverDesignPattern.go
Created December 21, 2018 00:36 — forked from sayden/ObserverDesignPattern.go
Observer Pattern in Golang
package main
import "fmt"
//Listener is a
type Listener struct {
ID int
}
//ListenerInterface is an
export const useGrpcRequest = (func, setState) => {
const [params, setParams] = useState(null);
useEffect(() => {
let unmounted = false;
(async () => {
try {
if (!params) return;
const result = await func(params);
if (unmounted) return;
// https://play.golang.org/p/5p28UL4thc_r
package main
import "fmt"
func main() {
s := InitializeServices() // Inject *sql.DB here
s.CreateAuthor(0, "name", "[email protected]") // Example http/grpc/graphql endpoints
const (
stmtCreateUser = iota
stmtGetUser
stmtUpdateUser
)
var stmtPairs = []struct {
id int
stmt string
}{
@longfellowone
longfellowone / .js
Last active February 28, 2020 21:53
gRPC-web ReactJS Hook
import React, { useEffect, useState, useRef, useReducer } from "react";
import { Link } from "react-router-dom";
export const Test = () => {
const [input, setInput] = useState("world");
const [data, refetch] = useGrpcRequest(myRequest, { name: "init" }, []);
// useEffect(() => console.clear(), []);
const handleOnClick = () => {
WDIR := /go/src/github.com/Pisush/tensorflow-and-go
DIR := ${CURDIR}:${WDIR}
DOCKER_IMAGE := dahernan/tensorflow-and-go
login:
docker run -i -v $(DIR) -w $(WDIR) --entrypoint=/bin/bash -t $(DOCKER_IMAGE)
dockerbuild:
docker build -f Dockerfile -t $(DOCKER_IMAGE) .
@longfellowone
longfellowone / 0_main.dart
Created April 24, 2019 17:16 — forked from boformer/0_main.dart
Flutter Service Architecture
import 'package:architecture_playground/home_page.dart';
import 'package:architecture_playground/services.dart';
import 'package:flutter/material.dart';
void main() async {
// perform long-running tasks before "runApp" to display the native splash screen
final services = await Services.initialize();
runApp(ServicesProvider(
services: services,