Skip to content

Instantly share code, notes, and snippets.

View weiland's full-sized avatar
🍫
🎓 && 💻 #GitHubDropICE

Pascal Weiland weiland

🍫
🎓 && 💻 #GitHubDropICE
View GitHub Profile
@weiland
weiland / gtm.rb
Last active February 17, 2021 09:38
GoTo Meeting ruby script to obtain an *opener* url
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='
@weiland
weiland / main.js
Last active November 11, 2022 14:33
Total Netflix Viewing History in Hours and CO2
// 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;
@weiland
weiland / index.js
Last active July 3, 2019 16:24
EvaSys Auto-Completer - Automatische Ausfüllen / Ergänzen einer EvaSys Umfrage / Evaluation
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);
}
@weiland
weiland / README_new_pi.md
Last active June 16, 2019 09:56
Setup new raspberry pi! \o/

Setup a new Raspberry PI

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
@weiland
weiland / find_or_create.exs
Created September 29, 2016 12:58
Find or Create in Ecto
# 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"
@weiland
weiland / ecto_soft_delete.exs
Created September 26, 2016 13:38
Soft Delete in Ecto
model = Repo.get!(Model, id)
Ecto.Changeset.change(model)
|> Ecto.Model.Timestamps.put_timestamp(:deleted_at, Ecto.DateTime, true)
|> Repo.update
@weiland
weiland / active_record_macro.ex
Created September 26, 2016 12:34
Basic ActiveRecord in Elixir Ecto (as Macro)
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
@weiland
weiland / start_work.sh
Created May 12, 2016 13:20
start_work.sh - scripts to be run when starting working
#!/bin/sh
# open chrome
# open mail
# open slack
# open iterm
# iterm (and other windows) positioning
# navigate to current project
# start server (node, rails, tests)
@weiland
weiland / leave_work.sh
Created May 12, 2016 13:16
leave_work.sh - scripts to run when leaving work on evenings. finish all tasks and close software. make the mac ready to bring it home.
#!/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
@weiland
weiland / readme.md
Created March 8, 2016 09:55
Using git-routines (git start, git finish)