Skip to content

Instantly share code, notes, and snippets.

View mtho11's full-sized avatar

Mike Thompson mtho11

  • Red Hat, Inc. (http://developers.redhat.com)
  • Klamath Falls, Oregon
View GitHub Profile
@mtho11
mtho11 / UseRequestHandler.jsx
Created January 25, 2020 18:12
React Hook for request
import {useState} from 'react';
const useRequestHandler = () => {
const [isLoading, setLoading] = useState(false);
const [hasError, setError] = useState(false);
const [data, setData] = useState(null);
const handleRequest = (request) => {
setLoading(true);
setError(false);
@mtho11
mtho11 / fetchingWithHooks
Created August 20, 2019 16:42
React.js: Fetching with Hooks
import React, { useState, useEffect } from "react";
const useFetch = url => {
const [state, setState] = useState({
loading: true,
error: false,
data: [],
});
useEffect(() => {
@mtho11
mtho11 / keybase.md
Created June 26, 2019 21:25
keybase.md

Keybase proof

I hereby claim:

  • I am mtho11 on github.
  • I am mtho11 (https://keybase.io/mtho11) on keybase.
  • I have a public key ASDBdBM0_TS0tI-HE6sY0kJntB6AHJ-UvkDVp5YyHRb2pAo

To claim this, I am signing this object:

@mtho11
mtho11 / redux-basics.js
Created April 4, 2018 23:44
Sample redux program.
const redux = require('redux');
const createStore = redux.createStore;
const initialState = {
counter: 0
}
// Reducer
const rootReducer = (state = initialState, action) => {
if (action.type === 'INC_COUNTER') {
@mtho11
mtho11 / jq.txt
Created April 2, 2018 20:18
jq using star wars api
Curl command used to display raw API data:
curl -s http://swapi.co/api/people/
Simple jq filter to pretty print JSON response:
curl -s http://swapi.co/api/people/ | jq '.'
Command to display only the results array:
@mtho11
mtho11 / ReactBindingApproaches.js
Created March 28, 2018 20:09 — forked from coryhouse/ReactBindingApproaches.js
React Binding Approaches
// Approach 1: Use React.createClass
var HelloWorld = React.createClass({
getInitialState() {
return { message: 'Hi' };
},
logMessage() {
// this magically works because React.createClass autobinds.
console.log(this.state.message);
},
@mtho11
mtho11 / cy.json
Created March 16, 2018 22:42
JSON file for testing with 2 groups
{
"nodes": [
{
"data": {
"id": "n3",
"text": "details (v1)",
"service": "details.istio-system.svc.cluster.local",
"version": "v1",
"link_prom_graph":
"http://prometheus:9090/graph?g0.range_input=1h\u0026g0.tab=0\u0026g0.expr=istio_request_count%7Bdestination_service%3D%22details.istio-system.svc.cluster.local%22%2Cdestination_version%3D%22v1%22%7D"
@mtho11
mtho11 / namespaces.json
Created March 6, 2018 20:24
Namespaces json sample file
[
{
name: "default"
},
{ name: "development" },
{ name: "fbr-jenkins-slaves" },
{
name: "hayk-test"
},
{
@mtho11
mtho11 / Gemfile.dev.rb
Created August 25, 2017 16:09
Gemfile.dev.rb
# unless dependencies.detect { |d| d.name == "manageiq-ui-classic" }
# gem "manageiq-ui-classic", :path => "/Users/mtho11/projects/manageiq-ui-classic"
# end
#override_gem 'manageiq-ui-classic', :path => File.expand_path('plugins/manageiq-ui-classic', __dir__)
override_gem 'manageiq-ui-classic', :path => File.expand_path("../../manageiq-ui-classic", __dir__)
group :development do
gem "pry-byebug"
# gem "web-console", group: :development
end
@mtho11
mtho11 / gist:42f52cc9bac0be4818fa551edbcecf20
Created August 9, 2017 17:29
Docker Compose file for Hawkular
version: '2'
services:
# set up the wildfly with embedded hawkular-agent
hawkfly:
image: "hawkular/wildfly-hawkular-javaagent:latest"
#ports:
# - "8081:8080"
links:
- hawkular