ruby migrate.rb create
ruby migrate.rb drop
$ irb
require_relative 'sequel'
user = User.first
user.send_welcome_email
" Call DotnetRunAndShowVirtualText on file open & save | |
autocmd BufReadPost,BufWritePost *.cs | call DotnetRunAndShowVirtualText() | |
" Delete virtual text on a buffer when it is modified | |
autocmd TextChanged,TextChangedI *.cs lua vim.api.nvim_buf_clear_namespace(0, -1, vim.fn.line(".") - 1, vim.fn.line(".")) | |
highlight MyWarningVirtualText guifg=orange | |
highlight MyErrorVirtualText guifg=red | |
function! DotnetRunAndShowVirtualText() | |
lua << EOF |
pub fn transpose(matrix: [[i32; 3]; 3]) -> [[i32; 3]; 3] { | |
let mut transposed: [[i32; 3]; 3] = [[0; 3]; 3]; | |
for i in 0..matrix.len() { | |
for j in 0..matrix[i].len() { | |
transposed[i][j] = matrix[j][i]; | |
} | |
} | |
transposed |
ruby migrate.rb create
ruby migrate.rb drop
$ irb
require_relative 'sequel'
user = User.first
user.send_welcome_email
class LuckyNumbers | |
attr_accessor :lucky_number | |
LUCKY_NUMBER = 7 | |
INTERVAL = 9 | |
def initialize(min = 0) | |
@lucky_number = min.to_i - 1 | |
end | |
def lucky?(number) |
class ColorsEnum | |
include Enumerable | |
def initialize(colors) | |
@colors = colors | |
end | |
def each(&block) | |
block.call(@colors[0]) | |
@colors.shift |
require 'erb' | |
class BasicErb | |
def initialize(template) | |
@template = template | |
end | |
def greeting | |
"Hello World!" | |
end |
module AbstractInterface | |
class InterfaceNotImplementedError < NoMethodError | |
end | |
def self.included(base) | |
base.send(:include, AbstractInterface::Methods) | |
base.send(:extend, AbstractInterface::Methods) | |
base.send(:extend, AbstractInterface::ClassMethods) | |
end |
O(1) = Immediately know exactly which element to visit (array by index, hash table lookup) | |
O(n) = Visit element once (find something in a list of unique values) | |
O(log n) = Loop the whole list multiple times but reduce its size each iteration roughly by half (sorting algorithms like quick sort [or is it merge sort]?) | |
O(n^2) = Loop the whole list for each element in the list (nested loops) (edited) |
# "In order to have a near-zero default footprint, Active Support does not | |
# load anything by default. It is broken in small pieces so that you can | |
# load just what you need, and also has some convenience entry points to | |
# load related extensions in one shot, even everything." | |
require 'active_support' | |
# https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/blank.rb | |
require 'active_support/core_ext/object/blank' | |
# https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/inclusion.rb |
Concerns: modules that you mixin to the classes where they are needed