Skip to content

Instantly share code, notes, and snippets.

View ivorpad's full-sized avatar
🇪🇸
Working from Spain

Ivor ivorpad

🇪🇸
Working from Spain
View GitHub Profile
@ivorpad
ivorpad / complicated_inheritance.rb
Last active August 29, 2015 14:24
More Complicated Inheritance: Bloc.io
class Shape
attr_accessor :color
def initialize(color = nil)
@color = color || 'Red'
end
def larger_than?(shapeType)
if self.area >= shapeType.area
true
@ivorpad
ivorpad / gist:74b6ed72839de9a0daea
Last active August 29, 2015 14:26 — forked from jrochkind/gist:2636355
reddit 'hot' algorithm, in ruby, with typo fixed
require 'date'
# Actually doesn't matter WHAT you choose as the epoch, it
# won't change the algorithm. Just don't change it after you
# have cached computed scores. Choose something before your first
# post to avoid annoying negative numbers. Choose something close
# to your first post to keep the numbers smaller. This is, I think,
# reddit's own epoch.
$our_epoch = Time.local(2005, 12, 8, 7, 46, 43).to_time
@ivorpad
ivorpad / capybara cheat sheet
Last active August 29, 2015 14:27 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@ivorpad
ivorpad / spec_helper.rb
Created August 11, 2015 23:32
Filter Gems backtrace from RSpec
# Filter backtrace from RSpec
config.backtrace_exclusion_patterns = [%r{\.rvm/gems/}]
<?php
/*
Register Fonts
*/
function studio_fonts_url() {
$font_url = '';
/*
Translators: If there are characters in your language that are not supported
by chosen font(s), translate this to 'off'. Do not translate into your own language.
@ivorpad
ivorpad / 0_reuse_code.js
Last active August 29, 2015 14:28
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
@ivorpad
ivorpad / The Technical Interview Cheat Sheet.md
Last active August 29, 2015 14:28 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
# Scope: http://guides.rubyonrails.org/active_record_querying.html#scopes
scope :visible_to, -> (user) { user ? all : where(private: false) }
# Using a Scope is fine and is actually encouraged, this is just to remember how to read it.
def self.visible_to(user)
if user
#Wiki.all
all
else
#Wiki.where(private: false)
@ivorpad
ivorpad / rails_server.bash
Created September 7, 2015 13:05
Rails Server with Daemon
# Run Rails Server Daemon
rails s -d
# Kill server
kill -INT ruby (tab)
@ivorpad
ivorpad / keymap.cson
Created September 24, 2015 15:44
Emmet Tab Expansion for ERB in Atom
# Expands Emmet with Tab in ERB files.
# Go to Atom/Open Your Keymap and paste this line.
'atom-text-editor[data-grammar="text html erb"]:not([mini])':
'tab': 'emmet:expand-abbreviation-with-tab'