Skip to content

Instantly share code, notes, and snippets.

View t1m0thyj's full-sized avatar

Timothy Johnson t1m0thyj

  • Pittsburgh, PA
  • 19:37 (UTC -04:00)
View GitHub Profile
@t1m0thyj
t1m0thyj / 24hr-clock.py
Last active May 22, 2021 19:27
Digital clock with automatic brightness using Scroll pHAT HD
import sys
import time
from datetime import datetime
import scrollphathd as sphd
from gpiozero import LightSensor
LDR_PIN = 24
MAX_BRIGHTNESS = 0.2
@t1m0thyj
t1m0thyj / assistant_library_with_local_commands_demo.py
Created October 22, 2017 03:27
Custom src/main.py script for Google Assistant on Raspberry Pi
#!/usr/bin/env python3
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@t1m0thyj
t1m0thyj / client.js
Created January 18, 2022 18:17
Node.js client/server performance test with TCP/pipes/sockets
const fs = require("fs");
const net = require("net");
const os = require("os");
let opts = {};
switch (process.argv[2]) {
case "pipe":
opts.path = `\\\\?\\pipe\\${os.userInfo().username}\\ZoweDaemonTest`;
break;
case "socket":
@(
'7zip'
'arduino'
'audacity'
'cinebench'
'conemu'
'crystaldiskinfo'
'filezilla'
'firacode-ttf'
'firefox'
@t1m0thyj
t1m0thyj / timeInterval.fs
Last active May 11, 2022 10:56
Implementation of time interval problem in F# with error handling
// Coded online at https://repl.it/@t1m0thyj/F-Scratchpad-1
open System
let dateStr = "1/1/2000,2/29/2000,2/29/2004,2/29/2008,2/29/2012,2/29/2016,3/14/15 9:26:53"
let getDayDiff (date1:string, date2:string) =
let couldParse, startDate = DateTime.TryParse date1
if (not couldParse) then failwithf "Date '%s' is not valid" date1
let couldParse, endDate = DateTime.TryParse date2
import requests
import subprocess
GITHUB_API = "https://api.github.com"
GITHUB_PAT = "<personal-access-token>"
OLD_USER = "<username>"
NEW_USER = "<username>"
gists = requests.get(GITHUB_API + "/users/" + OLD_USER + "/gists").json()
for gist in gists:
"""zowe_dl.py - Download all data sets matched by a wildcard
Usage: zowe_dl.py <dsname-wildcard> [zowe-args]
Examples:
zowe_dl.py HLQ.* --zosmf-p PROFILE
zowe_dl.py HLQ.* --host HOST --port PORT --user USER --password PASSWORD --no-ru
"""
import json
@t1m0thyj
t1m0thyj / ProfileUtils.ts
Last active May 11, 2022 10:58
Example of how to load default Zowe CLI profile in VS Code extension
import { IProfArgAttrs, IProfile, ProfileInfo } from "@zowe/imperative";
import { trueCasePathSync } from "true-case-path";
import { window, workspace } from "vscode";
/**
* Load properties for the default Zowe CLI profile of a given type.
* @param profileType The type of profile (e.g., "zosmf")
* @returns Profile object with property names and values defined
*/
async function getDefaultProfile(profileType: string): Promise<IProfile> {
#!/bin/bash
set -ex
npmRegistry=$1
tempDir=$(mktemp -d)
cd $tempDir
[[ ! -z "$npmRegistry" ]] && echo "@zowe:registry=$npmRegistry" >> .npmrc
npm init -y
npm install @zowe/cli
ls node_modules # Only one dependency should be at top level (@zowe/cli)
grep flatted node_modules/@zowe/cli/npm-shrinkwrap.json
@t1m0thyj
t1m0thyj / 24hr-Clock.ino
Last active May 11, 2022 10:59
24hr Clock - requires Arduino Uno, ESP8266 ESP-01 Wi-Fi module, and Scroll pHAT HD
#include <Adafruit_IS31FL3731.h>
#include <ezTime.h>
#include <WiFiEsp.h>
#include "arduino_secrets.h"
// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif