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
class Page < ActiveRecord::Base | |
before_save :parameterize_name | |
validates :name, uniqueness: { scope: :locale } | |
validates :name, :locale, presence: true | |
scope :by_name, lambda { |name| where(name: name) } | |
def self.get_by_name! name | |
page ||= self.find_by(name: name, locale: I18n.locale) |
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
class OmniauthProviderDecorator | |
@@decorations = | |
{ | |
linkedin: { icon: 'linkedin-square', class: 'primary' }, | |
twitter: { icon: 'twitter-square', class: 'info' }, | |
github: { icon: 'github', class: 'default' }, | |
google_oauth2: { icon: 'google-plus-square', class: 'danger' } | |
} | |
def initialize(provider) |
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
package main | |
import "code.google.com/p/go-tour/tree" | |
import "fmt" | |
func DoWalk(t *tree.Tree, ch chan int) { | |
if t.Left != nil { | |
DoWalk(t.Left, ch) | |
} | |
ch <- t.Value |
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
class User < ActiveRecord::Base | |
validates :admin, last_stays: true | |
end | |
class LastStaysValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
value_was = record.send("#{attribute}_was") | |
# If last record with attribute was equal to true | |
# it can't change this attribute value to false |
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
param := "stop" | |
if api.APIVERSION.LessThan("1.14") { | |
param = "force" | |
} | |
var param string | |
if api.APIVERSION.LessThan("1.14") { | |
param = "force" | |
} else { | |
param = "stop" |
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
func main() { | |
cmd := exec.Command(“stuff”) | |
chan := make(chan int, 1) | |
go func() { | |
cmd.Run() | |
chan <- STOP | |
} | |
go func() { | |
sleep(5) |
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
.ground-button { | |
@extend .button.secondary; | |
@include ground-border; | |
&:hover { | |
background-color: adjust-color($ground-primary-color, $lightness: -15%) | |
} | |
&:focus { | |
background-color: adjust-color($ground-primary-color, $lightness: -25%) | |
} |
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
link_to(theme[:label], grounds_switch_editor_theme_path(theme[:code]), method: :patch, remote: true) |
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
match 'grounds/', to: 'grounds#run', as: 'grounds_run', via: :put | |
match 'grounds/:theme', to: 'grounds#switch_editor_theme', as: 'grounds_switch_editor_theme', via: :patch | |
Prefix Verb URI Pattern Controller#Action | |
root GET / grounds#show | |
grounds_run PUT /grounds(.:format) grounds#run | |
grounds_switch_editor_theme PATCH /grounds/:theme(.:format) grounds#switch_editor_theme |
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
module CodeEditor | |
extend self | |
def use_soft_tabs? | |
evaluate_script("ground.editor.getSession().getUseSoftTabs();") | |
end | |
end |
OlderNewer