Skip to content

Instantly share code, notes, and snippets.

@DmytroVasin
DmytroVasin / MyHash
Last active February 20, 2017 16:44
require 'test/unit'
require 'benchmark'
# For Ruby 2.3
# user system total real
# Ruby Hash 0.030000 0.000000 0.030000 ( 0.033555)
# My Hash 0.360000 0.000000 0.360000 ( 0.367558)
# For Ruby 2.4
# user system total real
angular.module("Meek").controller "RadioStationsController", (
$sce
$rootScope
$scope
$stateParams
Category
RadioStation
ApplicationService
RankService
) ->
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'
@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>
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 / 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" }
]
@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}`
#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 / 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;