:query-repos := <<
(graphql-query
((viewer
(repositories
:arguments
((first . 3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use rusqlite::{ToSql, types::{FromSql, FromSqlResult, ToSqlOutput, ValueRef}}; | |
use miniserde::{Deserialize, Serialize, de::Visitor, make_place, ser::Fragment}; | |
use miniserde::Result; | |
make_place!(Place); | |
#[derive(Serialize, Clone, Deserialize, Debug)] | |
pub struct DateTime( | |
pub time::OffsetDateTime | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function uuidv4() { | |
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => | |
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) | |
); | |
} | |
function lamportMutex(id) { | |
const X = '_lock-X', | |
Y = '_lock-Y'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun flycheck-parse-cargo-rustc (output checker buffer) | |
"Parse Cargo errors from OUTPUT and return a list of `flycheck-error'. | |
CHECKER and BUFFER denote the CHECKER that returned OUTPUT and | |
the BUFFER that was checked respectively. | |
The expected format for OUTPUT is a mix of plain text lines and | |
JSON lines. This function ignores the plain text lines and | |
parses only JSON lines. Each JSON line is expected to be a JSON | |
object that represents a message from Cargo. The format of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; requires git-link package | |
(defun github--goto-issue-or-pr (id type) | |
"Opens a browser with issue or PR (denoted by TYPE) of given ID." | |
(let* ((origin-url (car (git-link--exec "config" "--get" "remote.origin.url"))) | |
(repo-match (string-match "^git@github.com:\\([^\\.]+\\)" origin-url)) | |
(repo-url (concat "https://github.com/" (match-string 1 origin-url))) | |
(sub-path (cond ((eq 'issue type) "/issues") | |
((eq 'pr type) "/pull")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'all-the-icons) | |
(defun with-faicon (icon str &optional height v-adjust) | |
(s-concat (all-the-icons-faicon icon :v-adjust (or v-adjust 0) :height (or height 1)) " " str)) | |
(defun with-fileicon (icon str &optional height v-adjust) | |
(s-concat (all-the-icons-fileicon icon :v-adjust (or v-adjust 0) :height (or height 1)) " " str)) | |
(defun with-octicon (icon str &optional height v-adjust) | |
(s-concat (all-the-icons-octicon icon :v-adjust (or v-adjust 0) :height (or height 1)) " " str)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(pc/defresolver res-with-timeout [_ _] | |
{::pc/output [:foo]} | |
(async/go | |
(let [timeout-ch (async/timeout 3000) | |
[ch res] (async/alts!! [(async/go | |
(do-my-operation-here)) | |
timeout-ch] :priority true)] | |
(if (= ch timeout-ch) | |
(throw (ex-info "Resolver timeout" {:timeout 3000})) | |
res)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:graphql-url = https://api.github.com/graphql | |
:github-token := (auth-source-pass-get "token" "web/github") | |
:headers = << | |
Authorization: Bearer :github-token | |
User-Agent: Emacs | |
# | |
:query-repos := << |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(deftype Employee [name id] | |
Object | |
(equals [a b] (= (.id a) (.id b))) | |
(hashCode [this] (.hashCode (.id this))) | |
(toString [this] (.name this))) | |
(def vince (Employee. "Vince" 42)) | |
(def vincent (Employee. "Vincent" 42)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn remote-req [result] | |
(Thread/sleep 1000) | |
result) | |
(defmacro plet [bindings & body] | |
(let [bents (partition 2 (destructure bindings)) | |
smap (into {} (map (fn [[b _]] | |
[b `(deref ~b)]) | |
bents)) | |
bindings (vec (mapcat (fn [[b v]] |
NewerOlder