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 User < ActiveRecord::Base | |
| has_many :cars | |
| end | |
| class Car < ActiveRecord::Base | |
| belongs_to :user | |
| end | |
| User.first.cars.build([{}, {}]) |
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
| From 6cbc591a18d322e40994b50c8bb8161de4f38ca9 Mon Sep 17 00:00:00 2001 | |
| From: Michael Nikitochkin <miry.sof@gmail.com> | |
| Date: Sat, 18 Jun 2011 17:48:50 +0300 | |
| Subject: [PATCH 166/166] fix includin jansson lib | |
| --- | |
| Makefile.am | 8 ++++---- | |
| compat/Makefile.am | 8 ++++---- | |
| configure.ac | 14 +++++++------- | |
| 3 files changed, 15 insertions(+), 15 deletions(-) |
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
| current_branch() { | |
| git_branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` | |
| if [ $git_branch ]; then | |
| echo "$git_branch" | |
| fi | |
| } | |
| gitissue() { | |
| github_issue=`echo $(current_branch) | sed -e 's/\([0-9]*\).*/\1/'` | |
| if [ $github_issue ]; then |
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
| diff --git a/app/models/rb_sprint_burndown.rb b/app/models/rb_sprint_burndown.rb | |
| index d505f37..7027656 100644 | |
| --- a/app/models/rb_sprint_burndown.rb | |
| +++ b/app/models/rb_sprint_burndown.rb | |
| @@ -43,19 +43,19 @@ class RbSprintBurndown < ActiveRecord::Base | |
| @series ||= {} | |
| key = "#{@direction}_#{remove_empty ? 'filled' : 'all'}" | |
| if @series[key].nil? | |
| - @series[key] = self.burndown[@direction].keys.collect{|k| k.to_s}.sort | |
| + @series[key] = self.burndown.nil? ? [] : self.burndown[@direction].keys.collect{|k| k.to_s}.sort |
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
| # Git | |
| alias g="git" | |
| # If your branch named like [issue_number]_some_description | |
| gh_issue() { | |
| ghissue=`echo $(current_branch) | sed -e 's/\([0-9]*\).*/\1/'` | |
| if [ $ghissue ]; then | |
| echo "$ghissue" | |
| fi | |
| } |
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
| alias pp_json='ruby -e "require \"json\"; require \"yaml\"; puts JSON.parse(STDIN.read).to_yaml"' |
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 TireSearch | |
| class Setup | |
| class << self | |
| def settings_options | |
| { | |
| number_of_shards: 1, | |
| number_of_replicas: 0, | |
| analysis: { | |
| char_filter: { |
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 insertionSort(ar) | |
| j = 1 | |
| while j < ar.size | |
| i = j - 1 | |
| key = ar[j] | |
| while i >= 0 && key < ar[i] | |
| ar[i+1]=ar[i] | |
| puts ar.join(" ") | |
| i -= 1 | |
| end |
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 partition(ar) | |
| p = ar[0] | |
| i = 1 | |
| j = ar.size - 1 | |
| while i<j | |
| i+=1 while i < j && ar[i]<p | |
| j-=1 while j>=i && ar[j]>p | |
| swap(ar,i,j) if i < j | |
| end |
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 pairs(numbers, diff) | |
| counter = 0 | |
| numbers.sort! | |
| n = numbers.length | |
| numbers.each_with_index do |val, i| | |
| j = i + 1 | |
| subject = val + diff | |
| j += 1 while j < n && numbers[j] < subject | |
| while numbers[j] == subject |
OlderNewer