Skip to content

Instantly share code, notes, and snippets.

View aflansburg's full-sized avatar
🔧

Abe Flansburg aflansburg

🔧
View GitHub Profile
@aflansburg
aflansburg / check_imagelinks.py
Created November 17, 2017 14:59
Validating image links in Python with urllib
@aflansburg
aflansburg / removeEmptyRows.js
Created December 7, 2017 16:37
Remove empty rows from Google Sheets (Gsheets)
function onInstall(e){
onOpen(e);
}
function onOpen(e){
var menu = SpreadsheetApp.getUi().createAddonMenu();
menu.addItem('Remove Empty Rows', 'removeEmptyRows');
menu.addToUi();
}
@aflansburg
aflansburg / timestamp_sheet.js
Created December 7, 2017 16:39
Add a timestamp to a cell in Google Sheets (Gsheets)
function addTimestamp(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cell = sheet.getRange('A1');
var d = new Date();
d.setHours(d.getHours());
var user = Session.getActiveUser().getUserLoginId();
user = String(user);
// cosmetic: this just removes the email domain from the user info
user = user.replace('@gmail.com', '');
@aflansburg
aflansburg / parrot.coffee
Created March 15, 2018 05:05
Hubot script to parrot what you desire in the specified room
# Description:
# RCBOT Parrots what you said to the specified room
#
# Dependencies:
# None
#
# Commands:
# rcbot say in #devops "Something blah blah blah"
#
# Author:
@aflansburg
aflansburg / scriptureme.coffee
Last active March 22, 2018 20:31
Bible Verse Quoting for Hubot - scriptureme
# Description:
# Hubot returns scripture using bibleverses package
#
# Dependencies:
# bibleverses
#
# Configuration:
# `npm install bibleverses --save`
#
# Commands:
@aflansburg
aflansburg / cascadeDelay.js
Created May 18, 2018 14:21
Cascading Async/Await Delay against an Array - Node.js
// slight modification and re-application of daliborgogic/delay.js
const timeout = ms => new Promise(res => setTimeout(res, ms));
// index is the index of an array member
async function throttle(index){
console.log(`Index ${index} will fire after ${1500*index}ms`);
return timeout(index*1500);
}
// let's say you have an async operation that makes requests to certain endpoints
@aflansburg
aflansburg / dir-crawl-copy.py
Created June 21, 2018 16:15
Traverse (walk) a directory tree, match filenames provided in csv, copy matched file to another directory
import os
import shutil
import csv
# to store filenames provided in csv
filenames = []
# read single column csv of filenames (no extension)
csv_path = 'parts.csv'
with open(csv_path, newline='') as csvfile:
@aflansburg
aflansburg / user-actions.rb
Last active September 9, 2020 21:22
simple ruby console app example - user auth
# simple user class
class User
def initialize(user_name, password)
@user_name = user_name
@password = password
end
attr_accessor :user_name
attr_accessor :password
end
@aflansburg
aflansburg / chinaFriendlyCaptcha.js
Last active September 15, 2020 13:26
Creating a China friendly captcha w/ Jquery & Rails view
function getCnNumber(x){
if (x > 10 && x <= 20){
const ch = '零一二三四五六七八九十'.split('').map((c, i) => x === i && c).find(s => s);
return '十' + ch;
}
else
return '零一二三四五六七八九十'.split('').map((c, i) => x === i && c).find(s => s);
}
function solveHuman(ans){
@aflansburg
aflansburg / cyberpunk_vaporwave.itermcolors
Created January 13, 2020 19:52
Vaporwave / Cyberpunk 2077 iTerm Color Theme/Scheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.13725490868091583</real>