Skip to content

Instantly share code, notes, and snippets.

View amiralles's full-sized avatar
🏠
Working from home

Ale Miralles amiralles

🏠
Working from home
View GitHub Profile
@amiralles
amiralles / plist.rb
Created December 11, 2018 12:12
Persistent list implemented in Ruby.
require_relative "./linked_list.rb"
class LinkedList
# Reuses list nodes from the specified node
# to the end of the list.
# The complexity of this method is O(n) where n
# is the distance from the target node to the
# end of the list.
def reuse_from_node node
@amiralles
amiralles / linked_list.rb
Last active June 10, 2020 09:07
Singly linked list implemented in ruby
class LinkedList
class Node
attr_accessor :next, :data
def initialize data
self.data = data
self.next = nil
end
end
attr_accessor :head, :tail, :length
@amiralles
amiralles / katrina.vim
Created June 18, 2020 23:57
Vim dark colorscheme
hi clear
if &t_Co > 255
" hi Normal ctermbg=234
hi CursorLine ctermbg=235 cterm=none
hi CursorLineNr ctermfg=208 cterm=none
hi Boolean ctermfg=135
hi Character ctermfg=144
hi Number ctermfg=135
hi String ctermfg=156
@amiralles
amiralles / stack.rb
Created November 5, 2018 13:05
Stack implemented in Ruby.
class Stack
class Node
attr_accessor :next, :data
def initialize data
self.data = data
self.next = nil
end
end
attr_accessor :head, :tail, :length
// All of this sortcuts are ergonomic if you remap
// CAPS -> Ctrl
// Right Opt -> Esc
//(I use Karabiner-Elements for that.)
[
{ "keys": [",", "/"],
"context": [
{ "key": "setting.command_mode", "operand": true },
{ "key": "setting.is_widget", "operand": false }
],
#!/bin/bash
# This is a wraper around the standard find command that excludes directories
# we typically want to ignore while working with source code.
# This function is handy when we are trying to fuzzy find files using tools like
# *selecta*
find * -type f \
-not -path "_build/**" \
-not -path "bin/**" \
-not -path "deps/**" \
-not -path "doc/**" \
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>github.com&#x2f;jzelenkov</string>
<key>colorSpaceName</key>
<string>sRGB</string>
<key>gutterSettings</key>
<dict>
@amiralles
amiralles / doubly_linked_list.rb
Last active November 6, 2021 09:29
Doubly linked lists implemented in ruby
require_relative "./linked_list.rb"
class DoublyLinkedList < LinkedList
class Node < LinkedList::Node
attr_accessor :prev
end
# Inserts a new item into the list.
# Complexity: O(1).
def insert data
@amiralles
amiralles / Default.sublime-theme
Created November 20, 2021 02:39
Customizations for Sublime Text 4 default theme.
{
// http://www.sublimetext.com/docs/3/themes.html
"variables": {
"quick_panel_path_label_color":"#222",
"quick_panel_matched_label_color": "#022FDF",
"quick_panel_matched_path_label_color":"#111",
"quick_panel_selected_path_label_color": "#222",
"quick_panel_selected_matched_label_color": "#022FDF",
#!/bin/bash
# Converts camelCased words into snake_cased ones.
# (This might be seful when you have to convert a JS object into an Elixir one.)
# TODO: Ignore quoted strings.
function camel_to_snake_case {
while read -r line; do
echo $line | sed 's/\(.\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]'
done
}