Skip to content

Instantly share code, notes, and snippets.

View ujihisa's full-sized avatar

ujihisa ujihisa

View GitHub Profile
https://www.nenkin.go.jp/shinsei/kokunen.html
https://www.nenkin.go.jp/shinsei/kokunen.files/654-1credit.pdf
function! s:flatten(xss) abort
let memo = []
for xs in a:xss
for x in xs
call add(memo, x)
endfor
endfor
return memo
endfunction
$ d
diff --git a/vm_backtrace.c b/vm_backtrace.c
index bb01983a7c..de7b961174 100644
--- a/vm_backtrace.c
+++ b/vm_backtrace.c
@@ -47,6 +47,28 @@ calc_lineno(const rb_iseq_t *iseq, const VALUE *pc)
return rb_iseq_line_no(iseq, pos);
}
+inline static int

Play with local vars

While waiting for my talk, guess what does it output without actually running it.

def put_in_f(hash, keys, value)
if keys.empty?
value
else
car, cdr = [keys[0], keys[1..]]
hash.merge(car => put_in_f(hash[car], cdr, value))
end
end
def extract(binding, ast)
let s:S = vital#vital#import('Data.String')
let s:L = vital#vital#import('Data.List')
function! s:count_words(text) abort
let F = { memo, x -> has_key(memo, x)
\ ? extend(memo, {x: memo[x] + 1})
\ : extend(memo, {x: 1})}
return s:L.foldl(F, {}, s:S.scan(a:text, '\w\+'))
endfunction
def give_ujihisa_money(users, value)
# users[:ujihisa][:money] = 24
update_in2(-> { users[:ujihisa][:money] }, 24)
# put_in(users[:ujihisa][:money], 24)
# dig <-> bury
end
def update_in2(f, value)
pp RubyVM::InstructionSequence.of(f).to_a
nil
@ujihisa
ujihisa / wip.rb
Last active January 19, 2019 02:13
#!ruby -v
ALL_PERKS = {
PER: ['Gunslinger', 'Shotgun Messiah', 'Automatic Weapons', 'Dead Eye', 'Archery', 'Explosive Weapons', 'Boom! Headshot!', 'Run And Gun', 'Lucky Looter', 'Salvage Operations'],
STR: ['Wrecking Crew', 'Sexual Tyrannosaurus', 'Flurry of Blows', 'Deep Cuts', 'Stay Down!', 'Heavy Metal', 'Skull Crusher', 'Miner 69\'er', 'Pack Mule', 'Mother Lode'],
FRT: ['Heavy Armor', 'The Huntsman', 'Intrinsic Immunity', 'Well Insulated', 'Living Off The Land', 'Pain Tolerance', 'Healing Factor', 'Fully Hydrated', 'Slow Metabolism', 'Self Medicated'],
AGI: ['Rule 1: Cardio', 'Light Armor', 'Charging Bull', 'Parkour', 'Olympic Swimmer', 'Ninja Movement', 'Hidden Strike', 'From Shadows'],
INT: ['Better Barter', 'The Daring Adventurer', 'Charismatic Nature', 'Hammer & Forge', 'Grease Monkey', 'Advanced Engineering', 'Yeah, Science!', 'Physician', 'Master Chef']
}
@ujihisa
ujihisa / version
Last active January 3, 2019 08:09
VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 8 2018 11:23:48)
Included patches: 1-570
Compiled by Arch Linux
Huge version with GTK3 GUI. Features included (+) or not (-):
+acl +clientserver +diff +folding +libcall +mouse_gpm +packages +ruby/dyn +termguicolors +visual +xsmp_interact
+arabic +clipboard +digraphs -footer +linebreak -mouse_jsbterm +path_extra +scrollbind +terminal +visualextra +xterm_clipboard
+autocmd +cmdline_compl +dnd +fork() +lispindent +mouse_netterm +perl/dyn +signs +terminfo +viminfo -xterm_save
+autochdir +cmdline_hist -ebcdic +gettext +listcmds +mouse_sgr +persistent_undo +smartindent +termresponse +vreplace
-autoservername +cmdline_info +emacs_tags
2019-01-03 16:20:44,037 [DEBUG @ msgpack_stream.py:send:34] 22202 - sent [0, 1, b'vim_get_api_info', ()]
2019-01-03 16:20:44,038 [DEBUG @ base.py:send:117] 22202 - Sending 'b'\x94\x00\x01\xb0vim_get_api_info\x90''
2019-01-03 16:20:44,038 [DEBUG @ base.py:run:142] 22202 - Entering event loop
2019-01-03 16:20:44,042 [DEBUG @ msgpack_stream.py:_on_data:59] 22202 - waiting for message...
2019-01-03 16:20:44,042 [DEBUG @ msgpack_stream.py:_on_data:61] 22202 - received message: [1, 1, None, [1, {b'version': {b'major': 0, b'api_level': 1, b'api_prerelease': False, b'patch': 7, b'api_compatible': 0, b'minor': 1}, b'types': {b'Window': {b'id': 1, b'prefix': b'nvim_win_'}, b'Tabpage': {b'id': 2, b'prefix': b'nvim_tabpage_'}, b'Buffer': {b'id': 0, b'prefix': b'nvim_buf_'}}, b'functions': [{b'method': True, b'name': b'nvim_buf_line_count', b'return_type': b'Integer', b'parameters': [[b'Buffer', b'buffer']], b'since': 1}, {b'method': False, b'deprecated_since': 1, b'name': b'buffer_get_line', b'return_type': b'String', b'