Skip to content

Instantly share code, notes, and snippets.

@fabianuribe
fabianuribe / .vimrc
Created Apr 1, 2016
Development environment
View .vimrc
execute pathogen#infect()
" don't bother with vi compatibility
set nocompatible
" enable syntax highlighting
syntax enable
" configure Vundle
filetype on " without this vim emits a zero exit status, later, because of :ft off
filetype off
@fabianuribe
fabianuribe / heap.js
Last active Apr 17, 2020
The Heap Data Structure in Javascript
View heap.js
/**
* heap.js
* A module that implements a Doubly Linked List data Structure
* @module LinkedList
*/
module.exports = Heap;
var TYPE_MIN = 'min';
var TYPE_MAX = 'max';
/**
@fabianuribe
fabianuribe / linked-list.js
Last active Apr 10, 2016
The Doubly Linked List Data Structure in Javascript
View linked-list.js
/**
* linked-list.js
* A module that implements a Doubly Linked List data Structure
* @module LinkedList
*/
module.exports = LinkedList;
/**
* Represents a Linked List Node.
* @param {Object} data
View lucky_ajax.md
View scrapper_test.rb
require 'nokogiri'
doc = Nokogiri::HTML(File.open('post.html'))
def extract_usernames(doc)
doc.search('.comhead > a:first-child').map do |element|
p element.inner_text
end
View P5: OO Inheritance.rb
class Vehicle
attr_reader :status, :wheels
def initialize(args)
@color = args[:color]
@wheels = args[:wheels]
@status = :stopped
end
View rpn.rb
# Create an RPNCalculator class which can evaluate expressions written in Reverse Polish notation.
# It should have an evaluate instance method which takes as its input a valid RPN expression and returns its evaluation. Your calculator only needs to handle addition, multiplication, and subtraction (not division).
# Operators and numbers should be separated by a single space.
# For example,
# calc = RPNCalculator.new
@fabianuribe
fabianuribe / sudoku.rb
Last active Dec 20, 2015
Sudoku solver version 1
View sudoku.rb
sudoku_string = "003020600900305001001806400008102900700000008006708200002609500800203009005010300"
sudoku_array = sudoku_string.split('')
rows_array = Array.new(9){ sudoku_array.shift(9) }
rows_array.each{|row| p row}
box_rows_array = []
# p rows_array
View gist:6041795
sudoku_string = "003020600900305001001806400008102900700000008006708200002609500800203009005010300"
sudoku_array = sudoku_string.split('')
rows_array = Array.new(9){ sudoku_array.shift(9) }
rows_array.each{|row| p row}
box_rows_array = []
# p rows_array
@fabianuribe
fabianuribe / gist:5988845
Last active Dec 19, 2015
Number to English Number
View gist:5988845
#Returns a number in english language
def english_number (number)
raise ArgumentError.new("Argument must be a positive integer") if !(number.is_a? Integer) || number < 0
return 'zero' if number == 0
result = ""