Skip to content

Instantly share code, notes, and snippets.

Avatar
🐧
Coding up a storm

Peter Flickinger peterfoxflick

🐧
Coding up a storm
View GitHub Profile
@peterfoxflick
peterfoxflick / contentView.swift
Last active Nov 6, 2020
Progress view updated by threads in SwiftUI
View contentView.swift
import SwiftUI
struct ContentView: View {
@State var total = 0
@State var progress = 0
@State private var workItem: DispatchWorkItem?
var body: some View {
@peterfoxflick
peterfoxflick / socailDist.ino
Last active Apr 19, 2020
ATTINY Social Distancing
View socailDist.ino
/*
* Original Ultrasonic code by Rui Santos, https://randomnerdtutorials.com
* Modified by Peter Fox Flick for attiny, peterfoxflick.com
* VIDEO: https://youtu.be/dF5E5jsWSZA
Ultrasonic sensor Pins:
VCC: +5VDC
Trig : Trigger (INPUT) - Pin 0
Echo: Echo (OUTPUT) - Pin 1
View code.gs
var key = "xxxxx"; // for trello
var token = "xxxxx"; // for trello
function main() {
//First get all homework assignments
var homework = UrlFetchApp.fetch('https://byui.instructure.com/api/v1/users/self/upcoming_events?access_token=xxxxxx');
homework = JSON.parse(homework);
//Now create cards for each one
homework.forEach(createCard);
}
View Control.rb
require 'benchmark'
%x(rm output.csv)
file = File.open('output.csv', 'a')
file.puts("N,DoWhile,ForEach,ForOf,ForLoop,While")
file.close
10000.times{ |i|
file = File.open('output.csv', 'a')
@peterfoxflick
peterfoxflick / removeFiles.js
Created May 16, 2019
If you need a simple way to remove files from a cluttered folder in canvas this should help do the trick. It only works in chunks of 100. Run with node.js
View removeFiles.js
var Request = require("request");
const folderID = "XXXX"
const access_token = "XXXXXXXXXX"
delete100()
//Get all the files in a given folder ID and remove them.
function delete100(){
var url = "https://byui.instructure.com/api/v1/folders/" + folderID + "/files?access_token=" + access_token + "&per_page=100"
@peterfoxflick
peterfoxflick / code.gs
Created Feb 26, 2019
Hidden Row Data: A simple Google Add-on that shows the meta data you save to a row in Google Sheets.
View code.gs
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Hidden Row Data')
.addItem('Show Data', 'showSidebar')
.addToUi();
}
function showSidebar() {
var html = HtmlService.createTemplateFromFile('sidebar');
@peterfoxflick
peterfoxflick / CountingUp.rb
Last active Oct 11, 2018
This is for a school project on testing if you can count with the sqrt(2) and (2 + sqrt(2)).
View CountingUp.rb
require 'twitter'
twitter = Twitter::REST::Client.new do |config|
config.consumer_key = "YOUR_CONSUMER_KEY"
config.consumer_secret = "YOUR_CONSUMER_SECRET"
config.access_token = "YOUR_ACCESS_TOKEN"
config.access_token_secret = "YOUR_ACCESS_SECRET"
end
def getA(n)
@peterfoxflick
peterfoxflick / AttinyFlowerPot.ino
Created Aug 11, 2018
The code for a flower pot that has a built-in sensor to detects when the soil is dry and lets you know. The circuit uses an ATtiny85 as the brain and copper tape as the sensor.
View AttinyFlowerPot.ino
/*
ATtiny Indoor Plant
This program flashes a blue light when there is dry dirt.
Pin OUT (only pins that are shown are used)
--[[()]]-- 5V
A3 --[[[]]]--
--[[[]]]--
@peterfoxflick
peterfoxflick / AttinyDarkDetector.ino
Created Aug 11, 2018
This little project makes an ATtiny tell you when it is dark or bright. This project is an excellent introduction to the capabilities of the ATtiny85 chip.
View AttinyDarkDetector.ino
/*
ATtiny Dark Detector
This program turns on a green light when it is bright.
and a red light when it is dark.
Pin OUT (only shows pins used)
--[[()]]-- 5V
--[[[]]]-- A1
@peterfoxflick
peterfoxflick / Change All Sheets
Created Jul 18, 2018
This script take a list of sheets by ID and will iterate through each one. I found this helpful when needing to apply changes to a large number of sheets. If you set it up to run every hour or fifteen minutes it can change as many as you need. If the script times out, it will begin where it left off the next time it runs.
View Change All Sheets
function changeAll() {
//Insert the id of the sheet that contains all the spreadsheets by id
var msheet = SpreadsheetApp.openById('---').getSheetByName("Sheet Ids");
var mdata = msheet.getRange('C:C').getValues();
//m-varname is the master data
var startd = new Date();
var diff = 0;
//Start keeps track of what row you are on incase the script times out.
You can’t perform that action at this time.