Skip to content

Instantly share code, notes, and snippets.

View alexlouden's full-sized avatar
🐶
👋

Alex Louden alexlouden

🐶
👋
View GitHub Profile
class PollingBase {
poll = async ({ fn, validate, interval, maxAttempts = 10 }) => {
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
for (let attempts = 0; attempts < maxAttempts; attempts++) {
try {
const result = await fn()
if (validate(result)) {
return result
@alexlouden
alexlouden / 0_usage.js
Last active October 31, 2019 11:33
Custom styled scrollbars
import React from 'react'
import useCustomScrollbars, { scrollbarWidth } from './useCustomScrollbars'
const Container = React.forwardRef(({ bg, children, ...props }, ref) => {
const [localRef, scrollbarsShown, scrollbarStyles] = useCustomScrollbars(
children,
ref,
bg
)

First, let's try just iterating through the list as we delete:

Here we're trying to remove all the numbers in our list under 3.

mylist = [1, 2, 3, 4, 5]

for item in mylist:
    if item < 3:
 mylist.remove(item)
@alexlouden
alexlouden / circle.yml
Last active February 26, 2019 12:54
Check Gastby site for broken links using CircleCI
version: 2
jobs:
build:
working_directory: ~/repo
docker:
- image: circleci/node:10
steps:
- checkout
- run:
@alexlouden
alexlouden / sendmail_slack.py
Created June 13, 2018 04:10
Python program that pretends to be sendmail, sends to Slack webhook instead. Move to /usr/lib/sendmail and make executable (`chmod +x`)
#!/usr/bin/env python3
import sys
import json
import requests
slack_url = "https://hooks.slack.com/services/<webhook URL>"
def get_subject(lines):
try:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexlouden
alexlouden / README.md
Last active January 23, 2018 09:01
Development HTTP/HTTPs servers to echo (and drop) incoming requests

Development HTTP and HTTPS servers to echo (and drop) incoming requests

Generate an SSL cert for HTTPS server

  1. Install openssl and python 3
openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt -subj '/CN=localhost'
@alexlouden
alexlouden / index.html
Last active December 11, 2017 07:41
Icon font sass
<i class="icon-star"></i>

Keybase proof

I hereby claim:

  • I am alexlouden on github.
  • I am alexlouden (https://keybase.io/alexlouden) on keybase.
  • I have a public key whose fingerprint is 4C0B 565D 15A9 4295 95C0 C4D3 0AA5 79A2 F938 FFB2

To claim this, I am signing this object:

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.