Skip to content

Instantly share code, notes, and snippets.

View benjiwheeler's full-sized avatar

Benjamin Wheeler benjiwheeler

View GitHub Profile
@benjiwheeler
benjiwheeler / gist:2ab634a61cc4ad0c45a3e5062736bb27
Created January 12, 2024 05:10
gcalcli add event template
gcalcli --client-id=IDHERE.apps.googleusercontent.com --client-secret=SECRETHERE add --calendar "CALENDARNAMEHERE" --duration 120 --where "Brattle Theater, Cambridge, MA" --noprompt --when "1/1/2024 5:00pm" --title "Lunch with mom"
@benjiwheeler
benjiwheeler / todoist_better_today_filter.txt
Last active December 13, 2022 04:13
Todoist filter code to show series of sections, designed to put most immediately actionable items first, and then to order roughly on priority. Mixes in a selection of future dates, with the assumption that there are fewer tasks due per day the farther you get into the future; the idea is to allow you to see and work on items which are not due y…
p1 & (@small | @morning) & !@evening & today, p2 & (@small | @morning) & !@evening & today, p3 & (@small| @morning) & !@evening & today, p1 & !@small & !@morning & !@evening & (today | !@date-specific & ((due after: +2 days & due before: +4 days) | (due after: +9 days & due before: +12 days) | (due after: +35 days & due before: +40 days) | (due after: +75 days & due before: +85 days))), p2 & !@small & !@morning & !@evening & (today | !@date-specific & ((due after: +9 days & due before: +12 days) | (due after: +35 days & due before: +40 days) | (due after: +75 days & due before: +85 days))), p3 & !@small & !@morning & !@evening & (today | !@date-specific & ((due after: +9 days & due before: +12 days) | (due after: +35 days & due before: +40 days) | (due after: +75 days & due before: +85 days))), overdue & @small, No priority & !@evening & today, @evening & today
@benjiwheeler
benjiwheeler / threadtest.py
Last active February 1, 2021 19:22
python thread test
import time
import timeit
from multiprocessing.dummy import (Pool, TimeoutError)
def delay(mynum, delay_secs):
print("starting #%s" % mynum)
time.sleep(delay_secs)
print("done with #%s" % mynum)
return True
@benjiwheeler
benjiwheeler / layout_boilerplate.html
Last active January 21, 2021 17:45
HTML, CSS layout boilerplate with header, footer, responsive content width; source https://jsbin.com/tocuguw
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-git.js"></script>
<script language="JavaScript">
$( document ).ready(function() {
$("#add").on("click", function() {
@benjiwheeler
benjiwheeler / selenium_browse_back.js
Created December 19, 2018 13:27
Selenium test code for browsing back and confirming that page is gone
elementIsVisible (element) {
return this.driver.wait(until.elementIsVisible(element));
}
elementIsNotVisible (element) {
return this.driver.wait(until.elementIsNotVisible(element));
}
const abbyElement = await findByText('Abby'); // Should show editor for new costume
await elementIsVisible(abbyElement);
@benjiwheeler
benjiwheeler / selenium_wait_until_clickable.js
Last active December 19, 2018 13:26
selenium js 3.6 attempt to wait until element is clickable
const costumesTabElement = await findByText('Costumes');
await driver.wait(() => {
return costumesTabElement.isDisplayed().then(displayed => {
console.log('got here A');
if (!displayed) return false;
console.log('got here B');
// costumesTabElement.click();
return costumesTabElement.isEnabled();
});
@benjiwheeler
benjiwheeler / time_utils.py
Last active February 2, 2018 20:37
Python time utils
import datetime
import pytz
# careful, don't assume now() is nyc time! on ec2, it's utc time.
def datetime_from_tz_naive_nyc_to_tz_aware_utc(nyc_datetime_tz_naive):
nyc_datetime_tz_aware = pytz.timezone('US/Eastern').localize(nyc_datetime_tz_naive)
return nyc_datetime_tz_aware.astimezone(pytz.utc)
def utc_tz_aware(utc_datetime_tz_naive):
return pytz.timezone('UTC').localize(utc_datetime_tz_naive)
<div class="legacy_content">
<div class="glitch" data-text="500">500</div>
</div>
...
div {
display: block;
}
@benjiwheeler
benjiwheeler / angularJsonDataService.js
Last active May 18, 2016 16:45
Angular Service to share JSON data among controllers
// data.json could look like:
// {
// "menu": [{"name": "Contact Us"}, {"name": "About Us"}]
// }
// app.js could look like:
var app = angular.module('myApp');
app.factory('commonData', ['$http', '$q', function($http, $q){
<html>
<head>
<!-- Pleace this snippet right after opening the head tag to make it work properly -->
<!-- This code is licensed under GNU GPL v3 -->
<!-- You are allowed to freely copy, distribute and use this code, but removing author credit is strictly prohibited -->
<!-- Generated by http://insider.zone/tools/client-side-url-redirect-generator/ -->
<!-- REDIRECTING STARTS -->
<link rel="canonical" href="http://destinationsitehere.com"/>