Skip to content

Instantly share code, notes, and snippets.

test_data = <<eof
do not match this line
match this as event 1
and this a as 1
and this b as 1
do not match this line
match this as event 2
and this x as 2
and this y as 2
and this z as 2
(defun indent-buffer ()
(interactive)
(indent-region (point-min) (point-max)))
(defun indent-region-or-buffer ()
(interactive)
(if (use-region-p) (indent-region (region-beginning) (region-end))
(indent-buffer)))
(global-set-key (kbd "C-M-/") 'indent-region-or-buffer)
class Foo
def initialize(n)
@n = n
end
attr_reader :n
def abracadabra_alakazam(x)
Foo.new(n + x.n)
end
(defun indent-buffer ()
(interactive)
(indent-region (point-min) (point-max)))
(defun indent-region-or-buffer ()
(interactive)
(if (use-region-p) (indent-region (region-beginning) (region-end))
(indent-buffer)))
class Array
def merge_sort(&block)
return self if size < 2
block ||= lambda { |a, b| a <=> b }
half_size = size / 2
first_ary = self[0, half_size].merge_sort(&block)
second_ary = self[half_size, size].merge_sort(&block)
(defun tmp-function (argument)
(interactive (list (read-string "enter: " "default")))
(message "the argument was %s" argument))
class Module
def around_module
unless defined? @around_module
prepend (@around_module = Module.new)
end
@around_module
end
def around(&block)
10
10 30
60 50 50
10
20 10
10 10 80
class A
Con = 42
class B
A = 32
Con #=> 42
A #=> 32
A::Con #=> Error
end
;; Won't be the file where I will put 99% percent of my config, this time.
(setq-default fill-column 80)
(fset 'yes-or-no-p 'y-or-n-p)
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq require-final-newline t)