Skip to content

Instantly share code, notes, and snippets.

@d4be4st
d4be4st / test_session.rb
Created February 19, 2018 09:58
manually set Rails 5 session cookie
class TestSession
def create_session_cookie(user_id:, csrf_token: nil, flash: {}, session_id: nil, last_request_at: nil)
hash = {
session_id: (session_id || "73b9eb8e8f265c5672ed2135a2d518f7"),
flashes: flash,
"warden.user.user.key" => [[user_id],"$2a$10$dIKBfN/6tcQsjDAAubmNDu"],
"warden.user.user.session" => {"last_request_at": (last_request_at || Time.current).to_i},
_csrf_token: (csrf_token || "n01FGBu5O2RGf7MaB3L0DrcmeMySJhqIP/Q7dDV37Vg=")
}

Keybase proof

I hereby claim:

  • I am d4be4st on github.
  • I am hadjic (https://keybase.io/hadjic) on keybase.
  • I have a public key ASDaKvB_BPN94Zj_QQEkiUgQqKYye27UY7chqgSM1ARlWQo

To claim this, I am signing this object:

@d4be4st
d4be4st / deploy.rb
Last active August 29, 2015 14:24
mina 0.3.6 deploy script
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
set :repository, "git@bitbucket.org:infinum_hr/web_app.git"
set :user, 'staging'
set :port, 22220
set :domain, 'app.infinum.co'
set :deploy_to, '/home/staging/www/a/app.infinum.co'
set :rails_env, 'production'
@d4be4st
d4be4st / .rubocop.yml
Last active August 29, 2015 14:16
sublime liter settings
LineLength:
Max: 120
Documentation:
Enabled: False
NegatedIf:
Enabled: False
SignalException:

Keybase proof

I hereby claim:

  • I am d4be4st on github.
  • I am hadjic (https://keybase.io/hadjic) on keybase.
  • I have a public key whose fingerprint is 7F9F 7A44 E603 987E 233D 8598 01D9 42CC 8367 3DEA

To claim this, I am signing this object:

route = xRoute.get_route(params[:reference_latitude], params[:reference_longitude], params[:finish_latitude], params[:finish_longitude]) # call to xRoute /xroute/rs/XRoute/calculateRoute
standard_distance = route['info']['distance'].to_i
reachable_objects = xRoute.get_reachable_objects(route) # call to xRoute /xroute/rs/XRoute/searchForReachableObjects
parking_places = ParkingPlace.where(deleted: 0, id: reachable_objects.keys) # We get for our own database parking places
parking_places.each do |parking_place|
parking_place.detour_distance = reachable_objects[parking_place.id.to_s][:detour_time]) #Assign detour distance to parking places
end
parking_places = xRoute.get_driving_distance(parking_places, params[:reference_latitude], params[:reference_longitude]) # Get driving distances for all parking places
parking_places = remove_out_of_reach(params[:driving_time]) # We remove all parking places that are out of reach
@d4be4st
d4be4st / gist:10851549
Created April 16, 2014 10:50
bootstrap fecny buttons
@import 'bootstrap';
.btn-info{
background-color: #fff;
color: $brand-info;
}
.btn-success{
background-color: #fff;
color: $brand-success;
}