Skip to content

Instantly share code, notes, and snippets.

@dukeimg
dukeimg / routes.rb
Created April 19, 2016 16:52
controller_override
Rails.application.routes.draw do
mount_devise_token_auth_for 'User', at: 'auth', controllers: {
sessions: 'overrides/sessions'
}
root 'application#angular'
resource :messages
# Redirect anything to root
get '*path' => redirect('/')
until $c == num
find(c)
c += 1
end
# Тоже что и:
while $c < nume
find(c)
c += 1
@dukeimg
dukeimg / find.rb
Created February 28, 2016 11:07
Simple number finder
def find(n)
unless n < 2 || n % 2 == 0 && n != 2
arr = []
n.times do |a|
arr.push(a) if a < (Math.sqrt(n) + 1).floor && a > 1
end
@dukeimg
dukeimg / expectation_matchers_spec.rb
Created February 28, 2016 09:13
RSpec -- Expectation Matchers
describe 'Expectation Matchers' do
describe 'equivalence matchers' do
it 'will match loose equality with #eq' do
a = "2 cats"
b = "2 cats"
expect(a).to eq(b)
expect(a).to be == b # synonym for #eq
@dukeimg
dukeimg / directive.js
Last active February 24, 2016 19:05
Old editor directive
angular.module('filmer').directive 'document', ->
template = () ->
'<canvas id="editorWindow" style="background-color: rgba(255, 194, 93, 0.4)" width ="500px" height = "500px"></canvas>'
getMousePos = (canvas, evt) ->
rect = canvas.getBoundingClientRect()
return {
x: evt.clientX - rect.left
y: evt.clientY - rect.top
@dukeimg
dukeimg / arrsum.rb
Last active December 10, 2015 18:58
Sum of an array for @kimtoman
sum = 0
array = [1,2,3]
array.each {|a| sum+=a}
#array.each do |a|
# sum+=a
#end
puts sum #--> 6