Skip to content

Instantly share code, notes, and snippets.

View mazikwyry's full-sized avatar
🍔

Adam Mazur mazikwyry

🍔
  • Global App Testing
  • Wyry
View GitHub Profile
@mazikwyry
mazikwyry / rails console
Created January 30, 2014 07:23
Faker script
reload!
Profile.find(:all).each do |u|
u.update_attribute(:first_name, Faker::Name.first_name+" "+u.id.to_s)
u.update_attribute(:last_name, Faker::Name.last_name)
end
@mazikwyry
mazikwyry / gist:8111620
Created December 24, 2013 10:52
cancel transaction
def cancel
update_attribute(:status, "canceled")
if payment.is_a(GoCardless) && payment.status=="preauth"
pre_auth = GoCardless::PreAuthorization.find(payment.authorization)
pre_auth.cancel!
end
end
@mazikwyry
mazikwyry / gist:6078958
Created July 25, 2013 11:49
optymilzacja
@contacts = User.fetch_contacts("Linkedin", current_user) //lista kontaktw
@tmps = @contacts.map { |tmp| tmp[:id] } //wybieramy z nij liste idków
@registered = Authentication.where("uid IN (:uids)", :uids => @tmps) //szukamy userów o takich idkach w bazie (to chyba zajmuje najwięcej czasu)
@contacts.delete_if{|contact| @registered.pluck(:uid).include?(contact[:id])} // wyrzucamy z kontaktów te znalezione w bazie
@registered.map! { |auth| auth.user }
@registered = ContactsInviterController::remove_invited @registered, current_user
@mazikwyry
mazikwyry / Error and question
Last active December 16, 2015 02:29
Old reqest and new one
NoMethodError (undefined method `[]' for nil:NilClass):
app/controllers/payments/google_checkout_controller.rb:36:in `notifications'
36: payment = GoogleCheckout.find_by_authorization(notification.shopping_cart.private_data["token"])
# We send command with shopping_cart.private_data = {token: token}
# And never have problems with getting private_data["token"] from new_order_notification
# There is no private_data["token"] in new reqest that we receive since april and here is the problem
@mazikwyry
mazikwyry / emotka
Last active December 14, 2015 12:58
[:->]--)--{
@mazikwyry
mazikwyry / finish_algorythm.rb
Created October 25, 2012 11:14
Finish pitches algorythm
if cf_min_reached? and ci_min_reached?
if pitch_goal_reached?
#Combination is successful
else
if cf_goal_reached?
#CF is successful
elsif ci_goal_reached?
#CI is successful
else
#All fails