Setup up a new Raspberry PI headless (without using a monitor, keyboard, mouse, LAN-cable) using WIFI and SSH.
Some assumptions:
- on a mac (local machine)
- the SD card is
disk2at/dev/disk2 - the PI image is named
image.img - the PI's IP is
10.0.0.1
| // https://www.portalefrecce.it/BobHttpLogger/status/train | |
| // somtimes comes as XML or JSON | |
| { | |
| "BobStatus": { | |
| "Train": { | |
| "Id": "9653", | |
| "Token": "IhRbCoYDMQDm0OVbZbIqXw==", | |
| "MealStatus": "on" | |
| } | |
| } |
| #!/usr/bin/env -S deno run --allow-run --quiet | |
| // Collect 5 complete days from the last working month for reporting. | |
| // Everything this or higher adresses the current month. | |
| const MIN_DAY = 27; | |
| const WORK_DAYS:Array<number> = [3, 5]; // ['Wendnesday', 'Friday'] | |
| const JANUARY = 0; | |
| const DECEMBER = 11; | |
| const MAX_DAYS = 31; |
| require 'net/http' | |
| require 'uri' | |
| require 'cgi' | |
| require 'nokogiri' | |
| # require 'open-uri' | |
| SHORT_URL = 'https://www.gotomeet.me/' | |
| JOIN_URL = 'https://global.gotomeeting.com/join/' | |
| IFRAME_URL = 'https://launch.getgo.com/launcher2/launch.html?token=' |
| // first page of content | |
| const START_PAGE = 0; | |
| // fixed size, increasing this number has no effect | |
| const ITEMS_PER_PAGE = 20; | |
| const fetchPage = (page) => fetch(`https://www.netflix.com/api/shakti/vb850f007/viewingactivity?pg=${page}&pgSize=${ITEMS_PER_PAGE}`) | |
| .then(response => response.json()); | |
| // reducer | |
| const addDuration = (accumulator, item) => accumulator + item.duration; |
| function getNormalOnlineView() { | |
| const links = document.getElementsByClassName('OldOnlineViewLink'); | |
| if (links.length === 0) threw new Error('Normal/Old Online View Link was not found.'); | |
| return links[0].href; | |
| } | |
| function checkRadio(radio) { | |
| radio.setAttribute('checked', true); | |
| } |
| # two different ways to implement a find_or_create for Ecto | |
| find_or_create_user = fn user -> | |
| case Repo.all(from u in users, where: u.id == ^user.id and u.email == ^user.email) do | |
| [] -> | |
| %User{} | |
| |> User.changeset(user) | |
| |> Repo.insert!() | |
| _ -> | |
| IO.puts "Already inserted" |
| model = Repo.get!(Model, id) | |
| Ecto.Changeset.change(model) | |
| |> Ecto.Model.Timestamps.put_timestamp(:deleted_at, Ecto.DateTime, true) | |
| |> Repo.update | |
| defmodule BasicApp.ActiveRecord do | |
| defmacro __using__(_) do | |
| quote do | |
| alias BasicApp.Repo | |
| def all(opts \\ []) do | |
| Repo.all __MODULE__, opts | |
| end | |
| def find(clauses, opts \\ []) do |
| #!/bin/sh | |
| # open chrome | |
| # open mail | |
| # open slack | |
| # open iterm | |
| # iterm (and other windows) positioning | |
| # navigate to current project | |
| # start server (node, rails, tests) |