Skip to content

Instantly share code, notes, and snippets.

@robbiev
robbiev / hello_vertx.clj
Created September 8, 2013 16:34
Example Vert.x Clojure verticle
(ns hello
(:require [vertx.http :as http]))
(-> (http/server)
(http/on-request
#(-> %
(http/server-response)
(http/add-header "Content-Type" "text/html")
(http/end "<html><head/><body></body><h1>Clojure + Vert.x</h1></html>")))
(http/listen 8080 "0.0.0.0"))
@robbiev
robbiev / priority_select.go
Last active January 21, 2023 18:27
select with priority in go
// SOLUTION 1
// see https://groups.google.com/forum/#!topic/golang-nuts/ChPxr_h8kUM
func maybe(b bool, c chan int) chan int {
if !b {
return nil
}
return c
}
select {
@robbiev
robbiev / go-playground-vim.md
Last active July 26, 2021 14:55
vim keybindings for the Go Playground at https://play.golang.org

Wasavi is some sort of vim implementation for browser text fields.

Once installed go to https://play.golang.org, you can use INSERT or CTRL+ENTER to enter the vim mode. To quit use the usual vim commands.

Tips:

  • The default keybinding to enter vim mode, CTRL+ENTER, conflicts with the standard playground shortcuts (CTRL+ENTER to format, SHIFT+ENTER to run). I recommend configuring wasavi to not enter vim mode on CTRL+ENTER (just use INSERT or configure something else)
  • Once you remapped CTRL+ENTER, you can have the following workflow:
@robbiev
robbiev / clipboard.md
Created April 14, 2017 16:22
clipboard access for WSL / bash on Windows

For those who want to go the X server route, let me leave my notes here.

  1. Install VcXsrv (I found that Xming is outdated on sourceforge and the new version is donationware)
  2. If it starts after installing, stop it
  3. Start it using XLaunch (search in the start menu), go with all the defaults (ensure the clipboard options are checked)
  4. At the end, save the configuration to a file (use that to start it from now on)
  5. Put export DISPLAY=localhost:0.0 in your .bashrc in bash for Windows (and run the command in any open bash windows). The reason I explicitly say localhost is that this makes SSH X forwarding work, see below.
  6. Ensure vim is installed using clipboard support. vim --version | grep clipboard should say +clipboard, not -clipboard. Also if you run the ex command :echo has('clipboard') in vim and it says 0 it does not have clipboard support compiled in. If you don't have clipboard support, install the vim-gtk package (`apt-get install vi
@robbiev
robbiev / tmux.md
Created April 17, 2017 15:41
tmux shortcuts

Use C-b ' to select a multi-digit window index

@robbiev
robbiev / keybase.md
Created October 15, 2017 15:39
keybase.md

Keybase proof

I hereby claim:

  • I am robbiev on github.
  • I am robbiev (https://keybase.io/robbiev) on keybase.
  • I have a public key ASDB0xogAyXD74C-obC6GYD-p2Scye0aOKOXUhbG88JQQAo

To claim this, I am signing this object:

#include <stdio.h>
struct vec4_a {
union { float x, r; } a;
union { float y, g; } b;
union { float z, b; } c;
union { float w, a; } d;
};
union vec4_b {