Skip to content

Instantly share code, notes, and snippets.

View FrancisMurillo's full-sized avatar

Francis Murillo FrancisMurillo

View GitHub Profile
@FrancisMurillo
FrancisMurillo / r2d2_test_connect.rs
Created February 8, 2023 13:54
Carabao Dev - Start transaction on r2d2 connection checkout
use diesel::{
pg::PgConnection,
r2d2::{ConnectionManager, Error as DieselPoolError},
result::ConnectionError,
};
use r2d2::{CustomizeConnection, Pool};
#[derive(Debug)]
struct TestConnection;
@FrancisMurillo
FrancisMurillo / data.jsonl
Created January 17, 2023 11:26
Sample Meilisearch v3 dump
{"uuid":"2b441316-6ecd-4cb5-b6ed-43f94dbe1c12","update":{"status":"enqueued","updateId":5,"meta":"ClearDocuments","enqueuedAt":"2023-01-17T09:04:42.802887774Z"}}
{"uuid":"dcf86d48-0ebf-4a43-95e6-4ab43af30266","update":{"status":"enqueued","updateId":9,"meta":"ClearDocuments","enqueuedAt":"2023-01-17T09:04:44.131021383Z"}}
{"uuid":"2b441316-6ecd-4cb5-b6ed-43f94dbe1c12","update":{"status":"enqueued","updateId":6,"meta":"ClearDocuments","enqueuedAt":"2023-01-17T09:04:44.885871244Z"}}
{"uuid":"2b441316-6ecd-4cb5-b6ed-43f94dbe1c12","update":{"status":"enqueued","updateId":7,"meta":{"DocumentAddition":{"primary_key":null,"method":"ReplaceDocuments","content_uuid":"f29774f0-2951-427a-9e8f-87dc33485dc2"}},"enqueuedAt":"2023-01-17T09:04:52.141635220Z"}}
{"uuid":"75fd9fdd-b2ba-49ca-8e3e-83e6259dce0c","update":{"status":"enqueued","updateId":10,"meta":{"DocumentAddition":{"primary_key":null,"method":"ReplaceDocuments","content_uuid":"ebdc24a9-fe4d-4bed-a3ee-54de2717357f"}},"enqueuedAt":"2023-01-17T09:04:52.455155266Z"}}
use std::fs;
use std::ops::{Deref, DerefMut};
#[derive(Debug)]
struct DB;
#[derive(Debug)]
struct Index(Vec<u8>);
#[derive(Debug)]
@FrancisMurillo
FrancisMurillo / lib.rs
Created August 8, 2020 06:06
Rust Median of Medians
#[cfg(test)]
#[macro_use(quickcheck)]
extern crate quickcheck_macros;
pub fn median<I: Ord + std::fmt::Debug>(items: &mut Vec<I>, index: usize) -> I {
assert!(index < items.len());
items.sort_unstable();
items.remove(index)
@FrancisMurillo
FrancisMurillo / lib.rs
Created May 26, 2020 05:36
Peterson/Filter Lock
#[macro_use]
extern crate log;
use std::{
cell::{RefCell, UnsafeCell},
sync::atomic::{AtomicU8, Ordering},
};
thread_local! {
static THREAD_ID: RefCell<u8> = RefCell::new(0);
}
@FrancisMurillo
FrancisMurillo / prodigy-depends-on.el
Created February 20, 2017 07:23
Prodigy.el :depends-on feature hack
(defvar prodigy-dependency-services nil
"An alist of the service name and some properties that aid in
managing service dependency.")
(defvar prodigy-dependency-service-status-change-hook nil
"A hook for listening in service status changes.")
(defconst prodigy-dependency-condition-prefix "prodigy-dependency-condition"
"A symbol prefix for easier debugging.")
@FrancisMurillo
FrancisMurillo / colored-words.el
Created February 14, 2017 06:49
Colored Words
(cons "freenode"
(concat ;; freenode
(propertize
"free" 'face '(:foreground "#e6e6e6"))
(propertize
"node" 'face '(:foreground "#4beb4a"))))
(cons "emacs"
(propertize
"emacs"
@FrancisMurillo
FrancisMurillo / browsing-w3m-anonymously-tor.el
Last active January 19, 2021 11:29
Browsing w3m Anonymously With tor
(with-eval-after-load 'w3m
(require 'cl nil t)
(require 'cl-compat nil t)
(when (and (executable-find "polipo")
(executable-find "tor"))
(defcustom fn/w3m-polipo-cache-dir (expand-file-name "polipo-cache" user-emacs-directory)
"Polipo cache directory."
:type 'directory)
(defcustom fn/w3m-tor-cache-dir (expand-file-name "tor-cache" user-emacs-directory)
@FrancisMurillo
FrancisMurillo / projin.el
Created January 21, 2017 07:26
Projin DSL
;;; projin.el --- Write projectile ignore files with a DSL -*- lexical-binding: t; -*-
;;
;; Filename: projin.el
;; Description:
;; Author: Francis Murillo
;; Maintainer:
;; Created: Wed Dec 28 21:36:00 2016 (+0800)
;; Version: 0.1
;; Package-Requires: ((emacs "24.4"))
;; Last-Updated:
@FrancisMurillo
FrancisMurillo / magin.el
Created January 21, 2017 07:26
Magin DSL
;;; magin.el --- Write git ignore files with a DSL -*- lexical-binding: t; -*-
;;
;; Filename: magin.el
;; Description:
;; Author: Francis Murillo
;; Maintainer:
;; Created: Wed Dec 28 21:36:00 2016 (+0800)
;; Version: 0.1
;; Package-Requires: ((emacs "24.4"))
;; Last-Updated: