Skip to content

Instantly share code, notes, and snippets.

View alexlouden's full-sized avatar
🐶
👋

Alex Louden alexlouden

🐶
👋
View GitHub Profile

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)
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 / 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:
@alexlouden
alexlouden / CMakeLists.txt
Created July 13, 2016 02:45
Good features to track
cmake_minimum_required(VERSION 3.5)
project(Test)
set(the_target "Test")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# CUDA
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/cuda" ${CMAKE_MODULE_PATH})
FIND_PACKAGE(CUDA)
LIST(APPEND CUDA_NVCC_FLAGS "-arch=compute_30")
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
)
@alexlouden
alexlouden / rifleman.py
Created February 11, 2015 10:34
Rifleman's Creed - gensim Phrases
from gensim.models import Phrases
from nltk.tokenize import word_tokenize
creed = """This is my rifle. There are many like it, but this one is mine.
My rifle is my best friend. It is my life. I must master it as I must master my life.
My rifle, without me, is useless. Without my rifle, I am useless. I must fire my rifle true. I must shoot straighter than my enemy who is trying to kill me. I must shoot him before he shoots me. I will...
My rifle and I know that what counts in war is not the rounds we fire, the noise of our burst, nor the smoke we make. We know that it is the hits that count. We will hit...
My rifle is human, even as I, because it is my life. Thus, I will learn it as a brother. I will learn its weaknesses, its strength, its parts, its accessories, its sights and its barrel. I will keep my rifle clean and ready, even as I am clean and ready. We will become part of each other. We will...
Before God, I swear this creed. My rifle and I are the defenders of my country. We are the masters of our ene
@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 / svg_get_path_length.js
Created April 5, 2014 09:53
Use D3 to determine SVG path length
d3.select('#path4').node().getTotalLength()
@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'