Skip to content

Instantly share code, notes, and snippets.

@AlexanderZaytsev
AlexanderZaytsev / stripe_tax_rates.rb
Created September 24, 2020 10:45
VAT Tax rates for stripe.rb 2020
tax_rates = [
{ country: 'BE', percentage: 21 },
{ country: 'BG', percentage: 20 },
{ country: 'CZ', percentage: 21 },
{ country: 'DK', percentage: 25 },
{ country: 'DE', percentage: 19 },
{ country: 'EE', percentage: 20 },
{ country: 'IE', percentage: 23 },
{ country: 'GR', percentage: 24 },
{ country: 'ES', percentage: 21 },
<silence>0.5</silence>
App.CurrentUserController = Ember.ObjectController.extend
init: ->
@setCurrentUserFromDom()
setCurrentUserFromDom: ->
attributes = $('meta[name="current-user"]').attr('content')
if attributes
attributes = JSON.parse(attributes)
App.store.load App.User, attributes
user = App.User.find attributes.id
!!!
%html
%head
%title
= 'Title'
%meta{charset: 'utf-8'}
- if user_signed_in?
%meta{name: 'current-user', content: current_user.to_json}
= stylesheet_link_tag 'application'
scope '/api' do
resources :users, except: [:edit]
end
root to: 'ember#index'
get '*path' => 'ember#index'
class MessagesController < ActionController::Base
def create
@message = Message.create! message_params
MessageTranslator.new(@message).translate! # Sends a request to Google Translate API
MessagePusher.new(@message).push! # Pushes to Pusher.com
end
def update
@AlexanderZaytsev
AlexanderZaytsev / gist:4276274
Created December 13, 2012 13:04
'Set shared record' pattern in Rails 4.0
class PostController < ActionController::Base
before_action :set_post, except: [:index, :new, :create]
def show
# do something with @post
end
private
def set_post
@post = Post.find(params[:id])