This file contains hidden or 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
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(query_start, clock_timestamp()), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(query_start, clock_timestamp()), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
This file contains hidden or 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
| module ActiveRecord | |
| class Base | |
| class << self | |
| # | |
| # SELECT "payments".* | |
| # FROM "payments" | |
| # WHERE "payments"."id" = <id> | |
| # AND ("payments"."created_at" BETWEEN '<start month>' AND '<end month>') | |
| # ORDER BY "payments"."id" ASC LIMIT 1 | |
| # |
When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
Please note we have a code of conduct, please follow it in all your interactions with the project.
- Ensure any install or build dependencies are removed before the end of the layer when doing a
This file contains hidden or 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
| AppBarLayout appBar = (AppBarLayout) rootView.findViewById(R.id.app_bar); | |
| appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { | |
| @Override | |
| public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { | |
| } | |
| }); |
http://guides.rubyonrails.org/migrations.html
- add_column
- add_index
- change_column
- change_table
- create_table
- drop_table
This file contains hidden or 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
| class Person | |
| has_many :accounts | |
| has_many :computers, through: :accounts | |
| end | |
| class Account | |
| belongs_to :person | |
| belongs_to :computer | |
| scope :administrators, -> { where(role: 'administrator') } |
This file contains hidden or 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
| module Validate | |
| class Activity | |
| include ActiveModel::Validations | |
| attr_accessor :latitude, :longitude | |
| validates :latitude, presence: true, numericality: true | |
| validates :longitude, presence: true, numericality: true | |
| def initialize(params={}) |
This file contains hidden or 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
| def self.escape_characters_in_string(string) | |
| pattern = /(\'|\"|\.|\*|\/|\-|\\|\)|\$|\+|\(|\^|\?|\!|\~|\`)/ | |
| string.gsub(pattern){|match|"\\" + match} | |
| end |