Skip to content

Instantly share code, notes, and snippets.

View fatso83's full-sized avatar
🐢
Two toddlers. Very little time for OSS after work hours. File a PR!

Carl-Erik Kopseng fatso83

🐢
Two toddlers. Very little time for OSS after work hours. File a PR!
View GitHub Profile
@fatso83
fatso83 / millis.c
Last active December 23, 2021 01:08
Print the number of millis since the Epoch (Jan 1 1970)
/**
* Print the number of millis since the Epoch (Jan 1 1970)
* Compile: cc millis.cc -o millis
* Put in your path: mv millis /usr/local/bin
*/
#include <stdio.h>
#include <sys/time.h>
int main(void)
{
struct timeval time_now;
@fatso83
fatso83 / format-code.gs
Last active August 25, 2021 20:46
Styles a paragraph as code. When adding this script using the Google Docs script editor it will appear under a new menu called "Extras"
// is called by google docs when a document is open
// adds a menu with a menu item that applies a style to the currently selected text
function onOpen() {
DocumentApp.getUi()
.createMenu('Extras')
.addItem('Apply code style', 'applyCodeStyle')
.addToUi();
}
var backgroundColor = "#DDDDDD";
@fatso83
fatso83 / StepForm.tsx
Last active August 15, 2021 15:44
Pay bananas, get monkeys 🤯
/*
This is a typical example of a codebase I inherited 😭
I mean, where do I even start ...
- direct DOM manipulation
- toggling display: none instead of not rendering, ...
- unclear data paths and constant heavy lookups
Oh, are you surprised that this stinking pile of shit is full of bugs? Me neither.
#kilowott #ninestack
@fatso83
fatso83 / log-lunch.sh
Last active May 18, 2021 00:31
Log your lunch hours in JIRA on the CLI. Install on Mac: `curl https://gist.githubusercontent.com/fatso83/cc014edf3f9877b93914e59887e58eb2/raw/ > tmp.sh; sh tmp.sh --install-mac`
#!/bin/bash
################################################################################
# Lunch logger for lazy Making Waves people.
#
# Integrates with native scheduler on OS X
#
# Usage:
# `log-lunch today # will log lunch for today`
# `log-lunch 2016-08-03 # will log lunch for august 3rd`
#
@fatso83
fatso83 / True Group Hacks.md
Last active March 30, 2021 11:57
Oslo Kommune Barnehager TrueGroups: merk alle beskjeder som lest

True Group Hacks

Hvor mange har ikke irritert seg grønn over at det er 317 uleste meldinger i TrueGroups når man logger inn, vel vitende om at man allerede har lest disse på epost? Det finnes jo dessverre ingen "Merk alle som lest" funksjonalitet, så da må man lage det sjøl :)

Dette skriptet finnes nå som eget prosjekt her: https://github.com/fatso83/truegroupshacks

@fatso83
fatso83 / state.not.found.error.page.template.html
Created March 9, 2021 19:35
Velocity template for state.not.found.error.page.template in PingFederate
<!-- This is just to get syntax highlighting:
https://support.pingidentity.com/s/question/0D51W00008BoxciSAB/how-to-customise-page-expired-handling
-->
<!-- So the middle part of the velocity template would look like this -->
<div class="ping-body-container">
<div class="ping-messages">
<div>
The page you are trying to access is no longer available.
</div>
</div>
Rename kebab-case files to PascalCase and vice versa
----------------------------------------------------
- Check the `require()` calls for what to `npm install`
- If you need to modify something else than `*.js` files, just modify the `find` command somewhat
$ node
> class A{ constructor(){ console.log('A normal super class'); } }
undefined
> class B extends A{}
undefined
> new B
A normal super class
B {}
> sinon = require('sinon')
...
@fatso83
fatso83 / gist:85a4934f6fe25ff34af389c4104ad14c
Created September 17, 2020 17:02
jq to csv with newlines
# based on https://medium.com/@henatyokotraveler/convert-json-file-with-line-break-to-csv-with-jq-command-577fe88c5bc1
# but cleaned non-copy-paste friendly ligatures and injected spaces
jq '.some.filter | @csv' | sed 's/\\\\/\\/g' | sed 's/\\\"/\"/g' | sed 's/^"//g' | sed 's/"$//g'
[Unit]
Description=Teamcity agent full
[Service]
Type=simple
User=carlerik
Environment=JAVA_HOME=/home/carlerik/.sdkman/candidates/java/12.0.0-open
ExecStart=/home/carlerik/apps/teamCityBuildAgentFull/bin/agent.sh run
ExecStop=/home/carlerik/apps/teamCityBuildAgentFull/bin/agent.sh stop