Skip to content

Instantly share code, notes, and snippets.

@joshlarsen
joshlarsen / deploy.sh
Last active May 13, 2021
Basic Jekyll Deploy Action
View deploy.sh
#!/bin/bash
set -e
DEST="${JEKYLL_DESTINATION:-_site}"
REPO="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
BRANCH="gh-pages"
BUNDLE_BUILD__SASSC=--disable-march-tune-native
echo "Installing gems..."
View netcat_web_server_one_liner.sh
while true; do echo -e "HTTP/1.1 200 OK\n\n $(date)" | nc -l localhost 4000; done
@joshlarsen
joshlarsen / app.rb
Last active Feb 28, 2021
Faktory polyglot speed tests
View app.rb
require 'connection_pool'
require 'faktory'
T = ARGV[0].to_i
puts "Starting #{T} jobs for each (ruby, node, python)"
puts Time.now()
SomeRubyWorker = Faktory::Job.set(queue: 'ruby', jobtype: 'RubyWorker')
SomeNodeWorker = Faktory::Job.set(queue: 'node', jobtype: 'nodeWorker')
SomePythonWorker = Faktory::Job.set(queue: 'python', jobtype: 'python_worker')
@joshlarsen
joshlarsen / down.sh
Created Jun 16, 2020
Monitor IPS uptime by pinging an external IP
View down.sh
#!/bin/bash
#
# Ping external IP from wired network to monitor for ISP outtage
# 2020-06-16
#
# runs on pi-hole from cron every day
#
# kill any other instances running
# name log file day_of_month_down.txt
# remove todays log file if there is one, since it will be a month old
@joshlarsen
joshlarsen / cloudSettings
Last active May 11, 2021
vscode settings
View cloudSettings
{"lastUpload":"2021-05-11T19:24:40.876Z","extensionVersion":"v3.4.3"}
@joshlarsen
joshlarsen / dns.sh
Created Mar 19, 2019
DNSimple dynamic IP update script
View dns.sh
#!/bin/bash
#
# Update DNSimple DNS record if ISP IP changes
#
# Requirements:
# existing DNS record hosted with DNSimple
# curl in $PATH
#
# run from cron
#
@joshlarsen
joshlarsen / app.js
Created Mar 19, 2019
Google Cloud Functions Node.js 8 Simple Emulator
View app.js
/**
* Inspiration taken from here https://github.com/GoogleCloudPlatform/cloud-functions-emulator/issues/258#issuecomment-413786762
* Alternative: https://github.com/GoogleCloudPlatform/cloud-functions-emulator/issues/258#issuecomment-407996126
*
* Original: https://github.com/GoogleCloudPlatform/cloud-functions-emulator/issues/258#issuecomment-437080813
*/
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
@joshlarsen
joshlarsen / irb.rb
Created Jan 9, 2019
Ruby backtrace in IRB
View irb.rb
begin
# Some exception throwing code
rescue => e
puts "Error during processing: #{$!}"
puts "Backtrace:\n\t#{e.backtrace.join("\n\t")}"
end
@joshlarsen
joshlarsen / server.js
Created Oct 19, 2018
Simple node.js proxy with dynamic route lookups via Redis
View server.js
const http = require('http');
const httpProxy = require('http-proxy');
const redis = require('redis');
// listen port
const port = 5050;
// redis client
const client = redis.createClient();