This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import all Java utils. | |
import java.util.*; | |
// Improt java lang. | |
import java.lang.*; | |
// Excercises. | |
public class App { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assigning multiple attributes to an object at once. | |
@thing.assign_attributes( | |
:created_by => current_user, | |
:period_template => period_template | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Resource without certain actions. | |
resources :users, :except => :show | |
# Specify routes and add new ones. | |
resources :sessions, :only => [:new, :create, :destroy] do | |
get :recovery, :on => :member | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ordering records in descending order | |
User.order(email: :desc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Configure permitted parameters for a devise action. | |
# This can be done in several ways on which this two are | |
# the most used. | |
# | |
def configure_permitted_parameters | |
# Usign a `do` block. | |
devise_parameter_sanitizer.for(:sign_up) do |u| | |
u.permit(:name, :heard_how, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Autoload `lib` directory. | |
# Inside config/application.rb | |
config.autoload_paths << Rails.root.join('lib') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adding a column to users model. | |
rails g migration add_email_to_users email:string | |
# Reverting a migration. | |
rake db:migrate:down VERSION=3846656238 | |
# Drop a table. | |
rails g migration DropProducts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[base(this, '${1:method}'${2});${0}]]></content> | |
<tabTrigger>base</tabTrigger> | |
<scope>source.js</scope> | |
<description>Base method call</description> | |
</snippet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# views.py | |
class UserProfileUpdate(LoginRequiredMixin, UpdateView): | |
# ... | |
# Pass current user to form through `initial` | |
def get_form_kwargs(self, **kwargs): | |
kwargs = super(UserProfileUpdate, self).get_form_kwargs(**kwargs) | |
kwargs['initial']['user']=self.request.user | |
return kwargs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django import forms | |
from crispy_forms.helper import FormHelper | |
from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field | |
from crispy_forms.bootstrap import AppendedText, PrependedText, FormActions | |
class MessageForm(forms.Form): | |
text_input = forms.CharField() |
NewerOlder