Skip to content

Instantly share code, notes, and snippets.

View mwfogleman's full-sized avatar

Tasshin Fogleman mwfogleman

View GitHub Profile
@mwfogleman
mwfogleman / gist:95cc60c87a9323876c6c
Last active May 19, 2018 23:28
Emacs: narrow-or-widen-dwim
(defun narrow-or-widen-dwim ()
"If the buffer is narrowed, it widens. Otherwise, it narrows to region, or Org subtree."
(interactive)
(cond ((buffer-narrowed-p) (widen))
((region-active-p) (narrow-to-region (region-beginning) (region-end)))
((equal major-mode 'org-mode) (org-narrow-to-subtree))
(t (error "Please select a region to narrow to"))))
;; I bind this key to C-c n, using the bind-key function that comes with use-package.
(bind-key "C-c n" 'narrow-or-widen-dwim)
@mwfogleman
mwfogleman / org-go-speed.el
Last active January 30, 2019 09:09
Org-Mode: Go to the heading of an element, so you can use speed commands
; Speed commands are really useful, but I often want to make use of
; them when I'm not at the beginning of a header. This command brings
; you back to the beginning of an item's header, so that you can do
; speed commands.
(defun org-go-speed ()
"Goes to the beginning of an element's header, so that you can
execute speed commands."
(interactive)
(when (equal major-mode 'org-mode)
@mwfogleman
mwfogleman / anagram.clj
Created August 25, 2014 18:17
anagram?
(defn anagram?
[s1 s2]
(let [c1 (clojure.string/lower-case s1)
c2 (clojure.string/lower-case s2)]
(and (= (count c1) (count c2))
(= (set c1) (set c2)))))
(anagram? "Mathematical Games" "Metamagical Themas")
; => true
@mwfogleman
mwfogleman / self-referential-sentences.clj
Last active August 29, 2015 14:06
"Ee' e i:", "Hr's th gst:"
(def vowels "aeiouyAEIOUY")
(def consonants "bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ")
(defn alph-filter [sub srn] (clojure.string/capitalize (apply str (remove (set sub) srn))))
(defn self-alph-filter [sub srn] (alph-filter sub (concat "This " srn)))
(def init-one "sentence contains no consonants and the following sentence no vowels.")
(def init-two "sentence contains no vowels and the preceding sentence no consonants.")
@mwfogleman
mwfogleman / sample_aggressive.clj
Created October 23, 2014 17:18
sample_aggressive
(facts "about aggressive-indent"
(fact "this is a different fact"
"I have my own things going on")
(fact "this function has a trailing parens"
)) ;; if you do a hungry ctrl-d (:D) on the previous line, everything in the "facts" tests will indent.
;; ideally it'd just indent the local "defun", in this case, the local fact
(dolist (hook '(mode1-mode-hook mode2-mode-hook mode3-mode-hook))
(add-hook hook #'something-mode))
// solution to https://tour.golang.org/methods/7
package main
import "fmt"
type IPAddr [4]byte
func (i IPAddr) String() string {
return fmt.Sprintf("%d.%d.%d.%d", i[0], i[1], i[2], i[3])

Keybase proof

I hereby claim:

  • I am mwfogleman on github.
  • I am mwfogleman (https://keybase.io/mwfogleman) on keybase.
  • I have a public key ASAzj5bCoksTYGXxRsc2Tv22cxobyRQwVvkAY0ma6QnFqQo

To claim this, I am signing this object:

@mwfogleman
mwfogleman / weeklyreviewtemplate.org
Last active December 14, 2023 19:50
Weekly Review Template

Weekly Review

Get Clear [0/5]

  • [ ] Collect Loose Papers and Materials
  • [ ] Get “IN” to Zero
    • [ ] Papers
    • [ ] Physical Notebook
    • [ ] Physical Objects
    • [ ] Text Messages
    • [ ] Voice Mail
    • [ ] Email Inboxes
@mwfogleman
mwfogleman / agame.edn
Last active June 4, 2017 01:15
A starter game of CODENAMES.
#<Atom@65413b0a:
{:starting-team :blue,
:current-team :blue,
:winning-team nil,
:id "G__739",
:created-at
#object[org.joda.time.DateTime 0x54b2a516 "2017-06-04T01:05:32.915Z"],
:round 0,
:words
({:word "GREECE", :identity :blue, :revealed? false}