Skip to content

Instantly share code, notes, and snippets.

@rksm
rksm / example_pptx.cljs
Created January 23, 2020 15:38
pptx-to-cljs example
(ns pptx-to-cljs.example-pptx)
(def $Content_Types$$xml "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">
<Default Extension=\"jpeg\" ContentType=\"image/jpeg\"/>
<Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>
<Default Extension=\"xml\" ContentType=\"application/xml\"/>
<Override PartName=\"/ppt/presentation.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml\"/>
<Override PartName=\"/ppt/slideMasters/slideMaster1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml\"/>
<Override PartName=\"/ppt/slides/slide1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.slide+xml\"/>
@rksm
rksm / foo.el
Created February 25, 2020 22:52
Tag org-pomodoro entries
(defvar my/org-pomodoro-analyzer-tag "POMODORO"
"Tag to add to an org entry when org-pomodoro clocks in.")
(defun my/org-pomodoro-analyzer-advice (_)
"If a pomodoro is running we ensure that it has a tag
`my/org-pomodoro-analyzer-tag'."
(when (org-clock-is-active)
(save-window-excursion
(with-current-buffer (org-clock-is-active)
import { Color, Line, Point, pt, rect, Rectangle, Transform } from "lively.graphics";
import { string, fun, promise, tree, Path as PropertyPath } from "lively.lang";
import { signal } from "lively.bindings";
import { copy, deserializeSpec, ExpressionSerializer } from "lively.serializer2";
export class Morph {
static get properties() {
return {
name: { group: "core" },
*** 2020-02-28 mac os
*** http://xahlee.info/kbd/kinesis_keyboard_howto.html
*** power user mode: progm + shift + esc
*** mount disk: progm + f1
*** normal keys
[q]>[q]
[w]>[w]
[e]>[l]
@rksm
rksm / init.el
Created February 7, 2021 20:16
shackle
(defun rk/open-compilation-buffer (&optional buffer-or-name shackle-alist shackle-plist)
"Helper for selecting window for opening *compilation* buffers."
;; find existing compilation window left of the current window or left-most window
(let ((win (or (loop for win = (if win (window-left win) (get-buffer-window))
when (or (not (window-left win))
(string-prefix-p "*compilation" (buffer-name (window-buffer win))))
return win)
(get-buffer-window))))
;; if the window is dedicated to a non-compilation buffer, use the current one instead
(when (window-dedicated-p win)
@rksm
rksm / mypy.ini
Last active May 23, 2021 17:06
stricter mypy config
# see https://mypy.readthedocs.io/en/stable/config_file.html#the-mypy-configuration-file
# this makes things more strict and enforces checking non-annotated code
[mypy]
# to keep things clean
warn_redundant_casts = True
warn_unused_ignores = True
# Workaround for bug in MyPy
disallow_subclassing_any = False
@rksm
rksm / init.el
Last active May 31, 2021 23:47
small init.el
(defvar rk/backup-dir (expand-file-name "backup" user-emacs-directory))
(unless (file-exists-p rk/backup-dir)
(mkdir rk/backup-dir))
(setq
backup-by-copying t ; don't clobber symlinks
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
@rksm
rksm / main.rs
Last active October 27, 2021 15:34
rust firestore streaming
use anyhow::Result;
use myclient::gcloud;
use firestore_grpc::tonic::codegen::InterceptedService;
use firestore_grpc::tonic::metadata::MetadataValue;
use firestore_grpc::tonic::transport::{Channel, ClientTlsConfig};
use firestore_grpc::tonic::{Request, Status};
use firestore_grpc::v1::firestore_client::FirestoreClient;
use firestore_grpc::v1::listen_request::TargetChange;
use firestore_grpc::v1::structured_query::CollectionSelector;
let req = ListenRequest {
database: db.clone(),
labels: HashMap::new(),
target_change: Some(TargetChange::AddTarget(Target {
target_id: 0x52757374,
once: false,
target_type: Some(TargetType::Documents(DocumentsTarget {
documents: vec![users_collection],
})),
resume_type: None,
@rksm
rksm / time_limiter.rs
Created August 19, 2022 12:08
Frequency counter / limiter
use std::time::{Duration, Instant};
/// Records the time when [`TimedLimiter::too_frequent`] was called. If this
/// gets called `N` times with a duration of less then `delay`, this method will
/// return `true`, otherwise `false`.
///
/// This is useful to make sure something does not get invoked too frequently.
pub(crate) struct TimedLimiter<const N: usize> {
delay: Duration,
last_changes: [Option<Instant>; N],