Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Slingin' Code

Dan Stroot dstroot

:octocat:
Slingin' Code
View GitHub Profile
@dstroot
dstroot / github-ubuntu.sh
Last active Sep 20, 2022
Setting up github on Ubuntu
View github-ubuntu.sh
#!/bin/bash
###############################################
# To use:
# wget https://raw.github.com/gist/4411254
# chmod 777 github-ubuntu.sh
# ./github-ubuntu.sh
###############################################
echo "*****************************************"
echo " Step 1: Check your keys"
echo "*****************************************"
View add-update-refresh-github-access-token-on-mac.md

Using an Access Token for the first time

Follow the instructions on Github to Create an Access Token in Github

Configure Git to use the osxkeychain

By default, git credentials are not cached so you need to tell Git if you want to avoid having to provide them each time Github requires you to authenticate. On Mac, Git comes with an “osxkeychain” mode, which caches credentials in the secure keychain that’s attached to your system account.

You can tell Git you want to store credentials in the osxkeychain by running the following:-

@dstroot
dstroot / performance.txt
Created May 25, 2012
Performance Tuning your TCP Stack
View performance.txt
#!/bin/bash
echo "*****************************************"
echo " Based on information from Google"
echo " http://dev.chromium.org/spdy/spdy-best-practices"
echo "*****************************************"
sudo su
yum –y update
echo "*****************************************"
echo " Changing initcwnd and initrwnd"
echo " Step 1: check route settings."
@dstroot
dstroot / install_postgresql.sh
Created Jun 13, 2012
Install PostgreSQL on Amazon AMI
View install_postgresql.sh
#!/bin/bash
###############################################
# To use:
# https://raw.github.com/gist/2776351/???
# chmod 777 install_postgresql.sh
# ./install_postgresql.sh
###############################################
echo "*****************************************"
echo " Installing PostgreSQL"
echo "*****************************************"
@dstroot
dstroot / handlers.go
Last active Feb 3, 2022 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
View handlers.go
package main
import (
"io"
"net/http"
"sync/atomic"
)
func index() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@dstroot
dstroot / useIntersectionObserver.js
Created Nov 6, 2021
The Intersection Observer API allows you to configure a callback that is called whenever an element intersects either the device viewport.
View useIntersectionObserver.js
import { useEffect } from 'react';
const useIntersectionObserver = ({
target,
onIntersect, // callback
threshold = 0.2, // when 20% visible
rootMargin = "0px", // don't adjust viewport margin
}) => {
useEffect(() => {
@dstroot
dstroot / install-redis.sh
Created May 23, 2012
Install Redis on Amazon EC2 AMI
View install-redis.sh
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://raw.github.com/gist/2776679/04ca3bbb9f085b192f6aca945120fe12d59f15f9/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@dstroot
dstroot / app.js
Created Jul 13, 2014
Gulp, BrowserSync, Node, and Nodemon all working in harmony. ;)
View app.js
/**
* World's simplest express server
* - used to serve index.html from /public
*/
var express = require('express');
var serveStatic = require('serve-static');
var app = express();
app.use(serveStatic(__dirname + '/public'));
@dstroot
dstroot / ec2-mysql-installation.sh
Created May 23, 2012
Install mysql on amazon EC2 AMI
View ec2-mysql-installation.sh
#!/bin/bash
###############################################
# To use:
# https://raw.github.com/gist/2776351/5fc6f3a63450ff6986ac916fce54d70c16937646/ec2-mysql-installation.sh
# chmod 777 install-redis.sh# ./install-redis.sh
###############################################
echo "*****************************************"
echo " Installing MySQL"
echo "*****************************************"
echo " "
@dstroot
dstroot / BLOG.md
Created Nov 1, 2019 — forked from elierotenberg/BLOG.md
Idiomatic Data Fetching using React Hooks
View BLOG.md

Idiomatic Data Fetching using React Hooks

This post has been written in collaboration with @klervicn

Virtually all web apps and websites need to pull data from a server, usually through a JSON-returning API. When it comes to integrating data fetching in React component, the "impedence mismatch" between the React components, which are declarative and synchronous, and the HTTP requests, which are imperative and asynchronous, is often problematic.

Many apps use third-party libraries such as Redux or Apollo Client to abstract it away. This requires extra dependencies, and couple your app with a specific library to perform data fetching. In most cases, what we want is a direct way to integrate plain HTTP requests (e.g. using native fetch) for usage in React components.

Here we will discuss how we can use React Hooks to do this in an elegant, scalable manner.