Skip to content

Instantly share code, notes, and snippets.

View pocke's full-sized avatar
⌨️
Pocke is typing...

Masataka Pocke Kuwabara pocke

⌨️
Pocke is typing...
View GitHub Profile
// Sync personal calendar to work calendar
function syncCalendar() {
var FROM_EMAIL = '[email protected]';
var TO_EMAIL = '[email protected]';
var HUB_CALENDAR_ID = '[email protected]'
var from_events = getEvents(FROM_EMAIL);
var hub_events = getEvents(HUB_CALENDAR_ID);
var hub_cal = CalendarApp.getCalendarById(HUB_CALENDAR_ID);
# ref: https://tama-san.com/kanji-regex/
kanji = [
*("\u{2E80}".."\u{2FDF}").to_a,
"\u{3005}",
"\u{3007}",
"\u{303B}",
*("\u{3400}".."\u{4DBF}").to_a,
*("\u{4E00}".."\u{9FFF}").to_a,
*("\u{F900}".."\u{FAFF}").to_a,
*("\u{20000}".."\u{2FFFF}").to_a,
module Cacheable
def cache(method_name)
orig_name = :"__orig__#{method_name}"
alias_method orig_name, method_name
define_method method_name do
__send__(orig_name).tap do |res|
self.class.class_eval do
undef_method method_name
undef_method orig_name
define_method method_name do
function! Rainbow(_) abort
let colors = ['Blue', "Green", "Cyan", "Red", "Magenta", "Yellow"]
let groups = ['Normal', 'Constant', 'Identifier', 'Statement', 'Special']
let offset = g:rainbow_idx % len(colors)
let idx = 0
for g in groups
let color = colors[(idx + offset) % len(colors)]
execute "hi " . g . " ctermfg=" . color
let idx += 1
rules:
- id: sample.abc
pattern:
subject: a.b.'c
where:
c: /.+/
message: a
examples:
- before: 'a.b.c'
after: 'a.b'
@pocke
pocke / test.md
Created April 27, 2019 11:23
RubyVM::ASTハマりどころ

returnが消える

# return 1のreturnはあってもなくても変わらないので、消える。 def foo() return 1 if cond; something end なら消えない。
pp RubyVM::AbstractSyntaxTree.parse("def foo() return 1 end")
(SCOPE@1:0-1:27
 tbl: []
@pocke
pocke / hello.ws
Last active April 28, 2019 09:32
For akaza blog
@pocke
pocke / hello.rb
Created April 28, 2019 09:32
For akaza blog
# Hello, world!を出力するプログラム
require 'akaza'
Akaza.eval("
@pocke
pocke / sum1.rb
Last active April 30, 2019 16:16
For akaza blog
require 'akaza'
class A
extend Akaza::Annotation
whitespace def sum(input, output)
This code is never evaluated.
@pocke
pocke / sum2.rb
Last active April 30, 2019 16:16
For akaza blog
require 'akaza'
class A
extend Akaza::Annotation
whitespace def sum(a, b)
input=StringIO.new("#{a}\n#{b}\n")
output=StringIO.new