Skip to content

Instantly share code, notes, and snippets.

View matugm's full-sized avatar

Jesus Castello matugm

View GitHub Profile
#coding: utf-8
class HighLine
module BuiltinStyles
def self.included(base)
base.extend ClassMethods
end
STYLES = {
erase_line: "\e[K",
require 'faker'
20.times do
post = Post.create!(title: Faker::Lorem.word, body: Faker::Lorem.paragraph)
puts "Created #{post.title}"
end
@matugm
matugm / refactor.js
Created July 14, 2015 02:10
javascript refactor
// Old
$(function() {
var flashCallback;
flashCallback = function() {
return $(".alert").fadeOut();
};
$(".flash-message").bind('click', (function(_this) {
return function(ev) {
return $(".alert").fadeOut();
};
class ListNode
attr_accessor :val, :next
def initialize(val)
@val = val
@next = nil
end
end
@carry = false
@matugm
matugm / max_subarray.rb
Created June 10, 2015 02:03
Max SubArray
#######################
# Version 1 - O(n^2)
#######################
def max_seq(chars, x = 0, y = 0)
return chars if chars.size < 2
combinations = {}
(0...chars.size).each do |x|
@matugm
matugm / dp-change.rb
Created June 8, 2015 18:02
Change problem solution
COINS = [1,3,6,10,15,20,30,50]
@cache = []
def min_change(amount)
return 0 if amount == 0
min = 9999999999
possible_coins = COINS.select { |n| n <= amount }