Skip to content

Instantly share code, notes, and snippets.

View oddlyfunctional's full-sized avatar

Marcos Felipe Pimenta Rodrigues oddlyfunctional

View GitHub Profile
require 'spec_helper'
describe Api::V1::SessionsController do
let(:password) { '12345678' }
let(:student) { create(:student, password: password) }
describe "POST /api/v1/students/sign_in" do
before(:each) do
post "/api/v1/students/sign_in", { student: { email: student.email, password: password } }
end
@oddlyfunctional
oddlyfunctional / extract_and_sort_keys.rb
Created July 24, 2015 07:08
Extract and sort keys from hash
def extract_and_sort_keys(hash)
hash.keys.map(&:to_s).sort_by(&:length)
end
sql = 'user_id = ? OR (client_id IN (?) AND (category_id IS NULL AND category_id IN (?) OR scenario_id IS NULL AND scenario_id IN (?)))'
Submission.where(sql, current_user.id, current_user.client_ids, current_user.categories.pluck(:id), current_user.scenarios.pluck(:id))
/* Colors */
body {
background: url(http://i.imgur.com/aZty7Mq.png);
animation: mymove 3s linear infinite;
-webkit-animation: mymove 3s linear infinite;
-moz-animation: mymove 3s linear infinite;
}
@keyframes mymove {
0% { background-position: 0 0; }
50% { background-position: 100% 0; }
" Index:
" ==Vundle
" ==Syntax Highlighting
" ==Color schemes
" ==RSpec.vim mappings
" ==Preferences
" ==Syntastic
" ==RenameFile
" ==Vundle
require 'nokogiri'
require 'open-uri'
require 'elasticsearch'
college_doc = Nokogiri::HTML(open('http://www.example-college.com'))
college_course = college_doc.at_css('.course')
course_hash = {
title: college_course.at_css('h1').text,
start_date: college_course.at_css('.start-date').text
// Write a function named allEven that accepts an array of
// numbers and returns true if every number is even, false
// otherwise. Use the forEach method to solve
// this problem
function allEven(list) {
var result = true;
list.forEach(function(element) {
if (element % 2 != 0) {
result = false;
function isEmpty(array) {
return array.length == 0;
}
function mergeSortedArrays(array1, array2) {
result = [];
// If there's anything in any of the arrays...
while (!isEmpty(array1) && !isEmpty(array2)) {
// ...we'll compare which one has the smallest next element...
#!/bin/ruby
# https://www.hackerrank.com/contests/worldcodesprint/challenges/save-our-ship
S = gets.strip
wrong_letters = 0
SOS = "SOS"
S.each_char.each_slice(3) do |sos|
wrong_letters += sos.each_with_index.select { |char, i| char != SOS[i] }.length