Skip to content

Instantly share code, notes, and snippets.

View marvinahv's full-sized avatar

Marvin Herrera marvinahv

View GitHub Profile
@marvinahv
marvinahv / lines.rb
Created October 6, 2020 23:36
Finished example
class Line
attr_accessor :startpoint
attr_accessor :endpoint
def initialize(startpoint, endpoint)
@startpoint = startpoint
@endpoint = endpoint
end
def to_s
@marvinahv
marvinahv / e.md
Created April 10, 2020 02:43
Tutorial with step-by-step execution for a recursive function that returns all keys of a deeply nested object in javascript
obj = {
  f: 'g'
}
function getAllObjectKeys(obj) {
  let keys = [];
 
@marvinahv
marvinahv / readme.md
Created March 12, 2019 02:07
setup environment cloud9 rails postgresql redis

Setup INTHOUGHT App on AWS Cloud9

Create cloud9 environment

  • From the AWS Console, go to Services > Cloud9.
  • In Cloud9, click Create New Environment.
  • Give it a name, description, and click Next step.
  • Select default Environment type (Create new instance in EC2).
  • Select an Instance type (I'm using a pretty big one, but you can test it out).
@marvinahv
marvinahv / Gemfile
Created November 11, 2016 01:45
Gemfile for stasis development
source 'http://rubygems.org'
gem 'stasis'
gem 'slim'
gem 'sass'
gem 'compass'
gem 'coffee-script', :require => 'coffee_script'
@marvinahv
marvinahv / csrf_ajax_setup.js
Created November 9, 2015 07:46
Javascript file for ajax sign in Ruby
$(window).load(function(){
(function(jQuery) {
$.ajaxSetup({
beforeSend: function(xhr) {
var token = jQuery('meta[name="_csrf"]').attr('content');
xhr.setRequestHeader('X-CSRF-Token', token);
}
});
}(jQuery));
});
### If you get an arbitrary number of numbers, sum them.
def sum_numbers(*args)
args.inject(:+)
end
# puts sum_numbers(1,4,3,2,5)
### If you get an array of numbers, sum its numbers.
def sum_array_numbers(numbers)
numbers.inject(:+)
end
sum_array_numbers([10, 24, 11, 3, 14, 24])
### If you get a really long list of IP addresses from a text file. Display the top 10 repeated IPs.
def top_10_ips(file)
# Select only the itmes that are repeated more than once
unique = []
repeated = []
File.open(file, 'r').each do |ip_line|
@marvinahv
marvinahv / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@marvinahv
marvinahv / Setup Instructions.md
Last active December 30, 2015 22:19
Setup Development Environment on Mac OSX

Local Development Environment

Download version depending on operating system.

Homebrew

  ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"