Skip to content

Instantly share code, notes, and snippets.

@DmytroVasin
DmytroVasin / Answers
Last active December 20, 2015 04:08
Anadea
# ActiveRecord
1)
В фрагменте кода показано два класса: Listing и Category
У Listing есть много Category ( в обратку должно быть belongs_to - но тут вроде как не обязательно)
Listing содержит поля "published", "name" ( не очень понял зачем поле name )
Category содержит поля "top_rated", "title" и должно содержать "listing_id" ( но можно и без него )
Метод класса "categories":
1. создает два пустых массива ( с их помощью, в дальнейшем, делается сортировка по полю top_rated )
2. выбирает все обьекты Listing ( все строки из таблици Listing ), у которых поле 'published' равно
@DmytroVasin
DmytroVasin / Custom.css
Last active December 20, 2015 05:28
Linux: ~./config/google-chrome/Default/User_StyleScheets/Custom.css; Mac: ~/Library/Application\ Support/Google/Chrome/Default/User\ StyleSheets/Custom.css
#console-messages .console-group-messages .section .header::before,
#console-messages .properties-tree li.parent::before
{
content: url(chrome-devtools://devtools/Images/treeRightTriangleWhite.png) !important;
}
#console-messages .console-group-messages .section.expanded .header::before,
#console-messages .properties-tree li.parent.expanded::before
{
content: url(chrome-devtools://devtools/Images/treeDownTriangleWhite.png) !important;
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@DmytroVasin
DmytroVasin / pre-push
Last active August 29, 2015 14:16
GIT: .git/hooks/pre-push (executive permitions)
#!/usr/bin/env ruby
current_branch = `git symbolic-ref --short HEAD`.to_s.strip!
first_preproduction_sha = `git merge-base #{current_branch} preproduction`
first_master_sha = `git merge-base #{current_branch} master`
preproduction_timestamp = `git show -s --format=%ci #{first_preproduction_sha}`
master_timestamp = `git show -s --format=%ci #{first_master_sha}`
@DmytroVasin
DmytroVasin / OSX default keymap:
Created August 7, 2015 19:00
Sublime .dot files
[
{ "keys": ["f9"], "command": "reindent"},
{ "keys": ["alt+down"], "command": "paste_from_history" },
{ "keys": ["shift+ctrl+g"], "command": "grep_file" },
{ "keys": ["super+'"], "command": "change_quotes" },
{ "keys": ["shift+super+r"], "command": "reveal_in_side_bar" }
]
import sublime, sublime_plugin
import os, re
def is_folder(path, action):
regex = re.compile(action)
return regex.findall(path)
def generate_prefix(path, folder_name):
if folder_name == 'controller':
return path.rstrip('_controller.rb').split('/controllers/')[1] + '/'
@DmytroVasin
DmytroVasin / Sublime Macros
Created August 7, 2015 19:12
Allow by inseting "z + tab" generate "<%= | %>" message
<snippet>
<content><![CDATA[
<%= ${1} %>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>z</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
source ~/.profile
source ~/.git-libs/git-completion.bash
source ~/.git-libs/git-prompt.sh
export PATH=/usr/local/bin:$PATH
export EDITOR='subl -w'
alias ns='cd ~/Dropbox/ror/anadea/nowshop'
alias jw='cd ~/Dropbox/ror/junior_way'
alias cl='cd ~/Dropbox/ror/anadea/clique'
angular.module("Meek").controller "RadioStationsController", (
$sce
$rootScope
$scope
$stateParams
Category
RadioStation
ApplicationService
RankService
) ->