Skip to content

Instantly share code, notes, and snippets.

@zarkone
zarkone / flake.nix
Created September 26, 2024 13:59
anytype-ts flake.nix
# also, add nix-ld to configuration.nix:
# programs.nix-ld.enable = true;
# programs.nix-ld.libraries = with pkgs; [
# gtk3
# ];
{
description = "";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.0.tar.gz";
inputs.flake-utils.url = "github:numtide/flake-utils";
@zarkone
zarkone / steam_yearinreview_2023.js
Created December 20, 2023 10:35
Steam, year in review 2023: get total play time
// 1. open browser dev console e.g. with Ctrl+Shift+i
// 2. paste in console at Steam year in review page of your account:
// e.g. https://store.steampowered.com/yearinreview/...somethinghere../2023
(function getSteamStats() {
const appConfigAttrs = document.querySelector("html.responsive body.v6.reactroot.responsive_page.movescrolltocontent div.responsive_page_frame.with_header div.responsive_page_content div#responsive_page_template_content.responsive_page_template_content div#application_config").attributes
const accId = JSON.parse(appConfigAttrs["data-userinfo"].value).accountid
const yearInReview = JSON.parse(appConfigAttrs[`data-yearinreview_${accId}_2023`].value)
const totalPlaytimeSeconds = yearInReview.playtime_stats.total_stats.total_playtime_seconds
console.log("Total play time in steam (hours):", totalPlaytimeSeconds / 3600)

Keybase proof

I hereby claim:

  • I am zarkone on github.
  • I am zarkone (https://keybase.io/zarkone) on keybase.
  • I have a public key ASBUnTH5WPdPPKKTfwnNz8Qi3_ieNhSo1Ij_oG74QKRCggo

To claim this, I am signing this object:

@zarkone
zarkone / helm3.ts
Created October 27, 2020 08:28
Helm3 workaround for pulumi, see https://github.com/pulumi/pulumi-kubernetes/issues/1335. Doens't support arrays and requires manual escaping / marshaling.
import * as child_process from "child_process";
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
const SPAWN_PROCESS_BUFFER_SIZE = 104857600;
export const repos = {
stable: "https://kubernetes-charts.storage.googleapis.com",
prometheus: "https://prometheus-community.github.io/helm-charts",
jetstack: "https://charts.jetstack.io",
ERROR: ld.so: object '/home/zarkone/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
ERROR: ld.so: object '/home/zarkone/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
>>> Adding process 21891 for game ID 1213210
>>> Adding process 21893 for game ID 1213210
Game update: AppID 1213210 "", ProcID 21891, IP 0.0.0.0:0
RecordSteamInterfaceCreation (PID 21891): SteamUtils009 / Utils
RecordSteamInterfaceCreation (PID 21891): SteamUser020 / User
RecordSteamInterfaceCreation (PID 21891): SteamUser020 /
RecordSteamInterfaceCreation (PID 21891): SteamUtils009 /
RecordSteamInterfaceCreation (PID 21891): STEAMAPPS_INTERFACE_VERSION008 /
@zarkone
zarkone / notify.clj
Last active February 18, 2021 08:25
Clojure + PostgreSQL: NOTIFY example
(ns database
(:require [hikari-cp.core :as connection-pool]
[clojure.java.jdbc :as jdbc]
;; ...
))
(defn- to-datasource-options [{:keys [host port username password database-name]}]
@zarkone
zarkone / config.clj
Last active February 14, 2018 05:46
Sample config reload example for Clojure (from our inner project Reaper)
(ns reaper.config
(:import [sun.misc Signal SignalHandler])
(:require [cheshire.core :as json]
[clojure.java.io :as io]
[camel-snake-kebab.core :as case]))
(def config-atom (atom {}))
(defn get-env [var-name]
(or (System/getenv var-name)
@zarkone
zarkone / signals_handler.clj
Created February 14, 2018 05:41
Intercept POSIX signals (like, from kill -SIGHUP) in Clojure
(ns signals-handler
(:import [sun.misc Signal SignalHandler]))
(defn handle-signals
"Sets up POSIX signal handlers."
[]
(Signal/handle
(Signal. "HUP")
(proxy [SignalHandler] []
(handle [sig]
(defun should-collapse-p ()
(string-match-p "\s-*(def.*"
(buffer-substring-no-properties
(line-beginning-position)
(line-end-position))))
(defun open-by-controller (should-collapse-p)
(let* ((region (yafolding-get-element-region))
(beg (car region))
@zarkone
zarkone / backlight.lisp
Created November 1, 2017 02:44
Backlight (brightness) control for stumpwm (using `sysfs`)
(defcommand set-backlight (level) ((:number "Set brightness level:"))
(with-open-file (sys-backlight-file "/sys/class/backlight/intel_backlight/brightness"
:direction :output :if-exists :overwrite)
(format sys-backlight-file "~a~%" (* 100 level))))
;; C-u [1-9] changes level
(defvar *brightness-map* nil)
(setf *brightness-map*
(let ((b (make-sparse-keymap)))
(loop for level from 1 below 10 by 1 do