Skip to content

Instantly share code, notes, and snippets.

@chenlilyd
chenlilyd / clean-wine.md
Created June 8, 2024 03:37
clean wine leftover

If you don't have Wine installed but you still see "Wine Internet Explorer" as an option in the "Open With" menu, it might be because of leftover desktop entries or MIME associations. Here's how you can clean it up:

  1. Remove Wine Desktop Entries: Desktop entries for Wine applications are usually stored in ~/.local/share/applications. You can remove these manually:

    rm ~/.local/share/applications/wine-*
  2. Update MIME Database:

@chenlilyd
chenlilyd / lti-server-example.py
Last active April 26, 2024 08:59
LTI tool implementation
# You can use this script to test LTI tool implementation on https://saltire.lti.app/platform
# To get a public domain, use: ngrok http 8000
#
# Ref JWK: https://pyjwt.readthedocs.io/en/latest/
import time
from flask import Flask, request, redirect
import jwt
from urllib.parse import urlencode
from uuid import uuid4
from jwcrypto import jwk
@chenlilyd
chenlilyd / hide chatgpt sidebar
Created March 6, 2023 02:08
hide-chatgpt-sidebar.js
// ==UserScript==
// @name Hide ChatGPT Sidebar
// @namespace http://tampermonkey.net/
// @version 0.4
// @description Hide the sidebar of the ChatGPT website
// @author You
// @match https://chat.openai.com/chat*
// @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @grant none
@chenlilyd
chenlilyd / aws-loginsight-query.clj
Created December 13, 2022 12:49
query aws loginsight from clojure
(require
'[clj-http.client :as client]
'[clojure.java.shell :refer [sh]]
'[clojure.string :as s]
'[taoensso.timbre :as log]
'[taoensso.timbre.appenders.core :as appenders])
(defn- aws-logs-start-query
"Starts a aws logs query, returns the query-id"
[{:keys [log-group-names start-time end-time query-string limit]
@chenlilyd
chenlilyd / ring-jetty-project.clj
Last active December 11, 2022 01:17
Test concurrent requests to Jetty
(ns garfield.ring-jetty-project
(:gen-class)
(:require
[cheshire.core :refer [parse-string]]
[clj-http.client :as client]
[clojure.java.io :as io]
[clojure.java.shell :refer [sh]]
[clojure.string :as s]
[com.climate.claypoole :as cp]
[ring.adapter.jetty :refer [run-jetty]]
@chenlilyd
chenlilyd / profile-swap-conj.clj
Created July 6, 2022 23:43
profile swap! conj perfromance
;; check performance of swap! with conj
(require '[clojure.core.async :as a])
(profile {:dynamic? true}
(let [ids (atom [])
n-ids 2000000
tasks (mapv (fn [i] (a/go (p :swap-conj (swap! ids conj i)))) (range n-ids))]
(doseq [t tasks]
(a/<!! t))
(assert (= n-ids (count @ids)))))
@chenlilyd
chenlilyd / core_async_pool_test.clj
Last active May 25, 2022 00:26
core async pool, go block vs threads, etc
(require
'[clojure.core.async :as async]
'[clojure.core.async.impl.protocols :as protocols]
'[clojure.core.async.impl.concurrent :as conc]
'[clojure.core.async.impl.exec.threadpool :as tp])
(import 'java.util.concurrent.Executors)
(def executor-svc (Executors/newFixedThreadPool
4