Skip to content

Instantly share code, notes, and snippets.

View inscapist's full-sized avatar

Felx inscapist

  • Penang, Malaysia
View GitHub Profile
@inscapist
inscapist / Dockerfile
Created June 12, 2022 07:46
python3.5 with gcc4.8
FROM gcc:4
ENV PATH /usr/local/bin:$PATH
ENV LANG C.UTF-8
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
netbase \
&& rm -rf /var/lib/apt/lists/*
ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D
  • What do Etcd, Consul, and Zookeeper do?
    • Service Registration:
      • Host, port number, and sometimes authentication credentials, protocols, versions numbers, and/or environment details.
    • Service Discovery:
      • Ability for client application to query the central registry to learn of service location.
    • Consistent and durable general-purpose K/V store across distributed system.
      • Some solutions support this better than others.
      • Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
  • Centralized locking can be based on this K/V store.
@inscapist
inscapist / easings.cljs
Created May 16, 2022 14:02
Easing Function in clojurescript
(def ^:private easing-fns
{:linear identity
:sine-in #(- 1 (js/Math.cos (/ (* % (.-PI js/Math)) 2)))
:sine-out #(js/Math.sin (/ (* % (.-PI js/Math)) 2))
:sine-in-out #(/ (- (dec (js/Math.cos (* (.-PI js/Math) %)))) 2)
:quad-in #(* % %)
:quad-out #(* % (- 2 %))
:quad-in-out #(if (< % 0.5) (* 2 % %)
(dec (* (- 4 (* 2 %)) %)))
:cubic-out #(inc (apply * (map dec [% % %])))
@inscapist
inscapist / better_dumps.py
Created May 11, 2022 07:55
Better json.dumps supporting set, datetime, timedelta, decimal, object, and sqlalchemy objects
__all__ = ["better_dumps", "better_dump", "json_debug"]
import dataclasses
import datetime
import decimal
import json
from inspect import ismethod
import jsonpickle
from loguru import logger
@inscapist
inscapist / sample_babashka_scripting.clj
Created January 12, 2022 14:29
Simple babashka script with CSV, JSON, str, regex manipulation
#!/usr/bin/env bb
;; https://book.babashka.org
;; https://book.babashka.org/#built-in-namespaces
(ns parse-country-codes
(:require
[cheshire.core :as json]
[clojure.data.csv :as csv]
[clojure.java.io :as io]
[clojure.string :as str]))
@inscapist
inscapist / box-shadow.html
Created January 4, 2022 15:10 — forked from ocean90/box-shadow.html
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@inscapist
inscapist / readme.md
Created December 6, 2021 12:57
Fixes broken brightness control in Arch Linux, on systems with Intel and Nvidia

My machine Spec:

  • Alienware X15 R1
  • QHD w/ GSync
  • RTX3070 MaxQ

It is definitely not an easy process, as everyone is posting this issue yet there is virtually no one posting their config when their setup is working. So I hope this helps someone with a setup like mine: Intel + Nvidia + Advanced Optimus.

I will list the steps I do here:

  1. Disable Advanced Optimus through BIOS (mine is V1.4.0), use only dGPU mode (until Nvidia fixes hybrid)
-- Author: Michael-Keith Bernard
-- Date: August 10, 2012
--
-- Notes: This Trie implementation is a port of the Clojure implementation
-- below. I had to implement quite a few functions from clojure.core to keep the
-- same basic functionality. Probably very little if any of this code is
-- production worthy, but it's interesting all the same. Finally, all of the
-- documentation strings are pulled directly from clojure.core and may not
-- accurately reflect the Lua implementation.
--
@inscapist
inscapist / test.clj
Last active October 21, 2021 09:11
Generate random cryptographic nonce/salt with buddy, in clojure
(-> 16
nonce/random-bytes
codecs/bytes->b64u
codecs/bytes->str)
let rtcConnection = null;
let rtcLoopbackConnection = null;
let loopbackStream = new MediaStream(); // this is the stream you will read from for actual audio output
const offerOptions = {
offerVideo: true,
offerAudio: true,
offerToReceiveAudio: false,
offerToReceiveVideo: false,
};