Skip to content

Instantly share code, notes, and snippets.

View gomes-work's full-sized avatar

João Gomes gomes-work

  • Work&Co
  • Brooklyn - NY
View GitHub Profile
# Macro Recording #
qx # start recording to register x
:%s/OldString/NewString/g
:wnext
q # stop recording
@x # playback to see if it works correctly
999@x # repeat 999 times to complete the job
# Copy Visual Block to OS Clipboard #
"*y
(defmacro aget2l [a i j]
`(aget ^"[J" (aget ~a ~i) ~j))
(defmacro aset2l [a i j v]
`(aset-long ^"[J" (aget ~a ~i) ~j ~v))
(defn distance [^String w1 ^String w2]
(let [c1 (.length w1) c2 (.length w2)
matrix ^"[[J" (make-array Long/TYPE (unchecked-inc-int c1) (unchecked-inc-int c2))]
(dotimes [n (unchecked-inc-int c1)] (aset2l matrix n 0 n))
!! # will expand to last command in history
!<n> # will expand to history command number 'n' (could be negative meaning most recent n)
!<word> # last comand in history starting with 'ssh'
!-1 # will expand to last command in history
^word^new # replace 'word' by 'new' in the last command in history
!!:s/word/new # same as above
!!:gs/word/new # global substitution
!:<n> # will expand to 'n'th word in the last command
!:^ and !:$ # will expand to first and last arguments
@gomes-work
gomes-work / multicast
Created February 14, 2018 23:55
Multicast Server Clojure
(ns demo.sample
(:require [clojure.core.async :as async])
(:import (java.net InetAddress DatagramPacket DatagramSocket MulticastSocket NetworkInterface InetSocketAddress)))
(defonce udp-server (atom nil))
(defonce udp-client (atom nil))
(def port 5555)
(comment defn server-host [] (InetAddress/getLocalHost))