Skip to content

Instantly share code, notes, and snippets.

View mhinz's full-sized avatar

Marco Hinz mhinz

View GitHub Profile
@mhinz
mhinz / day5.exs
Last active December 5, 2019 22:24
#!/usr/bin/env elixir
defmodule Day5 do
def run(), do: run(mem(), 0)
defp run(mem, ip) do
ins = parse_instruction(mem[ip])
a1 = if ins[:m1] == 1, do: ip+1, else: mem[ip+1]
a2 = if ins[:m2] == 1, do: ip+2, else: mem[ip+2]
a3 = if ins[:m3] == 1, do: ip+3, else: mem[ip+3]

Either in init.vim:

lua require 'colorizer'.setup()
lua << EOF
require 'colorizer'.setup {
  '*'; -- Highlight all files, but customize some others.
  css = { rgb_fn = true; }; -- Enable parsing rgb(...) functions in css.
function! g:FoldLispTopForm(lnum)
let curr = getline(a:lnum)
let next = getline(a:lnum+1)
if next[0] == '('
return 0
elseif curr[0] == '('
return 1
endif
return '='
endfunction
command! -nargs=* -range=% F
\ let lines = getline(<line1>, <line2>) |
\ enew |
\ call setline(1, lines) |
\ %!<args>
diff --git i/src/nvim/eval.c w/src/nvim/eval.c
index 28c590c0b..c60ec7b03 100644
--- i/src/nvim/eval.c
+++ w/src/nvim/eval.c
@@ -22538,3 +22538,50 @@ void ex_checkhealth(exarg_T *eap)
xfree(buf);
}
+
+/// Function given to ExpandGeneric() to obtain expansion specific
#!/usr/bin/env zsh
# Emulate Vim executable that simply returns its arguments.
> /tmp/vim.rb <<EOF
#!/usr/bin/env ruby
p ARGV
EOF
chmod 700 /tmp/vim.rb
VISUAL="/tmp/vim.rb -c 'first arg'"
" Changing the defaults arguments:
let grepper = {
\ 'grep': {
\ 'grepprg': 'grep -rn --include=\*.rb $* .'
\ }}
" Set the command on the fly (useful for commands):
command! RubyGrep Grepper -grepprg grep -rn --include=\*.rb $* .
function! RandNum() abort
return str2nr(matchstr(reltimestr(reltime()), '\.\zs\d*'))
endfunction
function! RandChar() abort
return nr2char((RandNum() % 93) + 33)
endfunction
function! Password() abort
return join(map(range(8), 'RandChar()'), '')
void socket_watcher_init(Loop *loop, SocketWatcher *watcher, const char *endpoint,
void *data)
FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_NONNULL_ARG(2) FUNC_ATTR_NONNULL_ARG(3)
{
xstrlcpy(watcher->addr, endpoint, sizeof(watcher->addr));
char *addr = xstrdup(endpoint);
char *host_end = strrchr(addr, ':');
if (host_end && addr != host_end) {
:edit ~/.vim/vimrc
:cd
:echo expand('%:.')    ->  .vim/vimrc
:echo expand('%:~')    ->  ~/.vim/vimrc
:echo expand('%:~:.')  ->  .vim/vimrc