Skip to content

Instantly share code, notes, and snippets.

Torgeir Thoresen torgeir

Block or report user

Report or block torgeir

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@torgeir
torgeir / create-bootable-image-using-dd.sh
Created Dec 7, 2019
Create bootable image using dd
View create-bootable-image-using-dd.sh
sudo dd bs=4M if=from-image.iso of=/dev/sdb conv=fdatasync status=progress
@torgeir
torgeir / remove-windows-hibernation-file.sh
Last active Dec 7, 2019
Remove windows hibernation file from ubuntu
View remove-windows-hibernation-file.sh
sudo mkdir /mnt/win
sudo mount -t ntfs-3g /dev/sda2 /mnt/win -o remove_hiberfile
View teknobyen.js
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("https://teknobyen.no/", { waitUntil: "networkidle2" });
await page.content();
const menu = await page.evaluate(() => {
const weekdays = ["Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag"];
return [...document.querySelectorAll(".c-food-menu")].map(m => {
@torgeir
torgeir / traffic-data-api.clj
Last active Nov 1, 2019
Norwegian Public Roads Administration's Traffic Data API from clojure
View traffic-data-api.clj
#!/usr/bin/env boot
(set-env!
:dependencies '[[org.clojure/clojure "1.10.0"]
[org.clojure/data.json "0.2.6"]
[district0x/graphql-query "1.0.6"]
[http-kit "2.3.0"]
[clj-gatling "0.13.0"]
[clj-time "0.15.0"]])
@torgeir
torgeir / fix-grub-config-gone-bad-steps.sh
Created Oct 27, 2019
Fix grub config gone bad ubuntu
View fix-grub-config-gone-bad-steps.sh
# make the bios boot from a live usb stick
# mount the filesystem and change to it
sudo mkdir /mnt/root
sudo mount /dev/sd2 /mnt/root
sudo mount -t proc none /mnt/root/proc
sudo mount -o bind /dev /mnt/root/dev
sudo chroot /mnt/root /bin/bash
# fix the issues
@torgeir
torgeir / boot-physical-win-disk-from-linux.sh
Created Oct 20, 2019
Boot physical win disk from linux
View boot-physical-win-disk-from-linux.sh
# find e.g. Windows 8 (on /dev/sda2)
fgrep menuentry /boot/grub/grub.cfg
# MAKE SURE NOT TO BOOT FROM THE OS YOU ARE ALREADY IN!!
sudo vim /etc/default/grub
# modify it, like
# GRUB_DEFAULT=0
GRUB_DEFAULT="Windows 8 (on /dev/sda2)"
# then create an image for your disk
@torgeir
torgeir / sketch_lines.cljs
Last active Sep 18, 2019
Generative art: Lines between two random lines inverted, repeat
View sketch_lines.cljs
(ns sketches.sketch-lines
(:require [quil.core :as q]
[quil.middleware :as m]
[lib.key-press-handlers :refer [save-image]]
[sketches.palette :refer [find-palette rand-palette]]))
(def body (.-body js/document))
@torgeir
torgeir / compile.cljs
Last active Mar 9, 2019
Using clojurescript to compile clojurescript
View compile.cljs
(ns example.core
(:require [cljs.js :as cjs]
[cljs.analyzer :as ana :include-macros true]
[cljs.reader :as r]
[cljs.pprint :as pprint]))
(enable-console-print!)
(let [src "(ns t.math)
(defn increase [n] (inc n))"
@torgeir
torgeir / torg.ds
Last active Feb 17, 2019
devilspie workspace layout
View torg.ds
/*
Lookup geometry: /usr/bin/xwininfo
Backup: https://gist.github.com/torgeir/401084929e678640b0cd36b3c92b5f03
*/
(and (is (application_name) "Firefox")
(begin
(set_workspace 1)
(geometry "1387x1138+0-32")))
(and (is (application_name) "emacs-snapshot")
@torgeir
torgeir / dependency-stats.js
Created Sep 26, 2018
Lookup various github stats from npm package name; stars, contributors, open issues/prs etc.
View dependency-stats.js
const r2 = require("r2");
const npm = require("npm");
const { spawn } = require("child_process");
const [_, __, accessToken, repo] = process.argv;
const shellCmdStdoutToObject = (cmd, args) =>
new Promise(function(resolve, reject) {
const child = spawn(cmd, args);
let result = "";
You can’t perform that action at this time.