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
disk2
at/dev/disk2
- the PI image is named
image.img
- the PI's IP is
10.0.0.1
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) |
#!/bin/sh | |
# TODO(pascal): Get TM status and ask to stop backup. (Also prevent disk ejection below) | |
# stops current time machine backup | |
tmutil stopbackup | |
# eject all disks | |
osascript -e 'tell application "Finder" to eject (every disk whose ejectable is true)' | |
# find and kill node/npm processes |
gem install tracker_api
gem install octokit
gem install git-routines