Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Wright wrightmikea

  • San Francisco Bay Area
View GitHub Profile
View risp-2.0.rs
use std::collections::HashMap;
use std::fmt;
use std::io;
use std::num::ParseFloatError;
use std::rc::Rc;
/*
Types
*/
@wrightmikea
wrightmikea / demo-transient2.el
Last active Mar 15, 2021
Emacs-SF - Additional Elisp related to 2021 March 5th Demo of (magit) transient by Mike Wright
View demo-transient2.el
;; Emacs-SF - Additional Elisp related to 2021 March 5th Demo of (magit) transient by Mike Wright
;; in the following two examples, the call to invoke grep is replaced with a message displaying arguments instead.
;; 1 of 2 - the long way (18 non-blank lines of code)
(progn
(defun my-grep-function (&optional args)
(interactive
(list (transient-args 'my-grep-transient)))
@wrightmikea
wrightmikea / demo-tmm.el
Created Mar 15, 2021
Elisp related to text-mode menu part of 2021 March 5 Emacs SF Dmenu Demo by Mike Wright
View demo-tmm.el
;; Elisp related to text-mode menu part of 2021 March 5 Emacs SF Dmenu Demo by Mike Wright
(progn
;; Creating a new menu pane in the menu bar to the right of “Tools” menu
(define-key-after
global-map
[menu-bar mymenu]
(cons "MyMenu" (make-sparse-keymap "mymenu mymenu"))
'tools )
@wrightmikea
wrightmikea / demo-dmenu.el
Created Mar 15, 2021
emacs lisp functions that use dmenu; demonstrated at the Emacs SF 20210305T1000 online meetup by Mike Wright
View demo-dmenu.el
;; emacs lisp functions that use dmenu; demonstrated at the Emacs SF 20210305T1000 online meetup by Mike Wright
;; some of these are copied or derived from a file I found via a github search for dmenu in .el files:
;; https://github.com/maavelar5/dotemacs/blob/2dd1d7e7af035edbfccfcdbbcbefdd55ba19ce44/.emacs.d/functions.el
;; to honor the license in Marco Avelar's functions.el, this file is also licensed under zlib.
;; https://en.wikipedia.org/wiki/Zlib_License
;; FYI, Marco (@marco) has a nice video demo: https://lbry.tv/@marco:55/emacs_dmenu_replacing_ivy:6
;; "Emacs + dmenu is awesome! bye bye Ivy!" October 31st, 2020
@wrightmikea
wrightmikea / demo-nested-hydra-menus.el
Last active Mar 23, 2021
Elisp related to 2021 March 5 Emacs-SF Demo of Nested Hydra Menus by Mike Wright
View demo-nested-hydra-menus.el
;;; demo-nested-hydra-menus.el --- Emacs SF hydra gist -*- lexical-binding: t; -*-
;; Elisp related to 2021 March 5 Emacs-SF Demo of Nested Hydra Menus by Mike Wright
;;
;; (use-package hydra :ensure t)
;;
(progn
(require 'hydra)
(defvar hydra-stack nil)
(defun hydra-push (expr)
@wrightmikea
wrightmikea / demo-transient.el
Created Mar 15, 2021
Elisp related to 2021 March 5th Emacs-SF online Demo of (magit) transient by Mike Wright
View demo-transient.el
;; Elisp related to 2021 March 5th Emacs-SF online Demo of (magit) transient by Mike Wright
;; from: https://github.com/magit/transient/blob/master/docs/transient.org
;; under section "Hydra"
;; A Hydra “body” is equivalent to a Transient “prefix” and a Hydra “head” is equivalent to a Transient “suffix”.
;; Hydra has no equivalent of a Transient “infix”.
(transient-define-prefix outline-navigate ()
:transient-suffix 'transient--do-stay
:transient-non-suffix 'transient--do-warn
[("p" "previous visible heading" outline-previous-visible-heading)
View my-init.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; to show visual artifact when using darkburn, dimmer, and perspective packages
;;
;; run with:
;; # copy the my-init.el gist somewhere, e.g. ~/Downloads
;; mkdir ./target # or rm -rf ./target/*
;; cp my-init.el ./target
;; cd ./target
;; /usr/local/bin/emacs -q -l init.el --batch # ignore the ivy-switch-buffer warning
View main.rs
// https://github.com/rust-lang/rust/issues/49733
// https://doc.rust-lang.org/1.7.0/book/box-syntax-and-patterns.html
#![feature(box_syntax)]
#[derive(Debug)]
struct Bix(u8);
impl Bix {
pub fn new(x: u8) -> Self {
Bix(*box x) // for demo only, box serves no practical purpose here
@wrightmikea
wrightmikea / main.rs
Created Feb 18, 2020
mutating a hashmap in a struct
View main.rs
use std::collections::HashMap;
#[derive(Debug)]
pub struct Element {
pub a: u8,
}
#[derive(Debug)]
pub struct HSS {
pub store: HashMap<u32, Vec<Element>>,
}
fn main() {
View Install-Docker-on-Linux-Mint.sh
# Check that HTTPS transport is available to APT
if [ ! -e /usr/lib/apt/methods/https ]; then
sudo apt-get update
sudo apt-get install -y apt-transport-https
fi
# Add the repository to your APT sources
sudo echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list
# Then import the repository key