Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Starefossen's full-sized avatar
🚀
Building platforms for the Norwegain Government

Hans Kristian Flaatten Starefossen

🚀
Building platforms for the Norwegain Government
View GitHub Profile
@Starefossen
Starefossen / tmux-cheats.md
Last active April 11, 2024 07:05
My personal tmux cheat sheet for working with sessions, windows, and panes. `NB` I have remapped the command prefix to `ctrl` + `a`.

Sessions

New Session

  • tmux new [-s name] [cmd] (:new) - new session

Switch Session

  • tmux ls (:ls) - list sessions
  • tmux switch [-t name] (:switch) - switches to an existing session
@Starefossen
Starefossen / vim-cheats.md
Last active March 29, 2024 15:07
My vim cheat sheet for working with tabs and window splits.

Tabs

New Tab

  • :tabnew - new blank tab
  • :tabedit [file] - open file in tab

Cursor Movement

  • gt (:tabn) - next tab
@Starefossen
Starefossen / micrometer-prometheus
Created October 4, 2023 21:01
Spring OpenTelemetry Demo Application
# HELP jvm_gc_max_data_size_bytes Max size of long-lived heap memory pool
# TYPE jvm_gc_max_data_size_bytes gauge
jvm_gc_max_data_size_bytes 8.589934592E9
# HELP executor_pool_size_threads The current number of threads in the pool
# TYPE executor_pool_size_threads gauge
executor_pool_size_threads{name="applicationTaskExecutor",} 0.0
# HELP hikaricp_connections_creation_seconds_max Connection creation time
# TYPE hikaricp_connections_creation_seconds_max gauge
hikaricp_connections_creation_seconds_max{pool="HikariPool-1",} 0.0
# HELP hikaricp_connections_creation_seconds Connection creation time
@Starefossen
Starefossen / image_magick.sh
Created November 11, 2014 21:38
Build ImageMagick from source
#!/bin/bash
magick_version=6.8.9-10
magick_install_dir="$HOME/image_magick"
magick_download_url="http://imagemagick.org/download/releases/ImageMagick-$magick_version.tar.gz"
rm -rf $magick_install_dir/*
mkdir -p $magick_install_dir && cd $magick_install_dir
curl -L $magick_download_url | tar -zxf-
cd ImageMagick*
@Starefossen
Starefossen / remoteDataTableView.swift
Last active January 16, 2023 09:50
Remote JSON Data to tableView in iOS 8.0 (Swift)
import UIKit
import Foundation
import XCPlayground
XCPSetExecutionShouldContinueIndefinitely()
class RemoteAPI {
func getData(completionHandler: ((NSArray!, NSError!) -> Void)!) -> Void {
let url: NSURL = NSURL(string: "http://itunes.apple.com/search?term=Turistforeningen&media=software")
let ses = NSURLSession.sharedSession()
@Starefossen
Starefossen / gist:6699580
Last active June 22, 2022 12:37
Command line HTTP POST with custom headers and JSON payload using CURL
curl -X POST \
-H "X-Parse-Application-Id: $APP_ID" \
-H "X-Parse-REST-API-Key: $KEY" \
-H "Content-Type: application/json" \
-d '{"score": 1337, "playerName": "Sean Plott", "cheatMode": false }' \
https://api.parse.com/1/classes/GameScore
@Starefossen
Starefossen / gist:319f36ff30694a775806
Created August 13, 2015 08:24
Resize VirtualBox .vmdk disk
# http://www.midwesternmac.com/blogs/jeff-geerling/resizing-virtualbox-disk-image
# Clone the .vmdk image to a .vdi.
vboxmanage clonehd "virtualdisk.vmdk" "new-virtualdisk.vdi" --format vdi
# Resize the new .vdi image (30720 == 30 GB).
vboxmanage modifyhd "new-virtualdisk.vdi" --resize 30720
# Optional; switch back to a .vmdk.
VBoxManage clonehd "cloned.vdi" "resized.vmdk" --format vmdk
### Keybase proof
I hereby claim:
* I am starefossen on github.
* I am starefossen (https://keybase.io/starefossen) on keybase.
* I have a public key ASBrgxagN9yHjE6uZ3W6fiKcRMNTRXsgyrwvG7rf9Y32DAo
To claim this, I am signing this object:
@Starefossen
Starefossen / server.coffee
Last active June 22, 2020 20:26
Stream MongoDB documents from Node.JS server
"use strict"
http = require 'http'
MongoClient = require('mongodb').MongoClient
stringify = require('JSONStream').stringify
db = null
server = http.createServer (req, res) ->
cursor = db.collection('turer').find()

On the server with tmux

Create a new tmux session:

tmux new-session -s my-session # launch `top`, `htop`, or anything that will regularly updates, then detach

Stream your session: