Skip to content

Instantly share code, notes, and snippets.

View the-teacher's full-sized avatar
💻
Working remotely

Ilya N. Zykin the-teacher

💻
Working remotely
View GitHub Profile
@the-teacher
the-teacher / Fixing Capistrano 3 deployments after a repository change
Created July 27, 2015 15:27
Fixing Capistrano 3 deployments after a repository change
Fixing Capistrano 3 deployments after a repository change
https://coderwall.com/p/4k1lja/fixing-capistrano-3-deployments-after-a-repository-change
vim DEPLOY-FOLDER/repo/config
```
[core]
repositoryformatversion = 0
filemode = true
@the-teacher
the-teacher / svg.text
Created May 25, 2015 11:40
svg pattern aspect ratio
<svg>
<defs>
<!-- pattern1 - no aspect ratio control -->
<pattern id="pattern1" height="100%" width="100%"
patternContentUnits="objectBoundingBox">
<image height="1" width="1" preserveAspectRatio="none" xlink:href="http://upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Gl%C3%BChwendel_brennt_durch.jpg/399px-Gl%C3%BChwendel_brennt_durch.jpg" />
</pattern>
<!-- pattern2 - aspect ratio control on the image only -->
<pattern id="pattern2" height="100%" width="100%"
class Recipe {
var name: String?
init(name:String?) {
self.name = name
}
}
for index in 1...15 {
var recipe = Recipe(name: "Test Recipe \(index)")
@the-teacher
the-teacher / vagrant.notes.md
Last active September 23, 2015 09:50
vagrant
brew cask install virtualbox
brew cask install vagrant
brew cask install vagrant-manager

vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-librarian-chef-nochef

cd MY_RAILS_PROJECT
@the-teacher
the-teacher / multiline.rb
Created March 8, 2015 19:07
ruby multiline
(<<-MSG.squish)
text
MSG
@the-teacher
the-teacher / locale.rb
Created January 30, 2015 09:20
HTTP_ACCEPT_LANGUAGE, set locale, locale
def set_locale_variables locale
I18n.locale = @request.session[:locale] = @request.cookies[:locale] = locale.to_s
end
def acceptable?(locale)
I18n.available_locales.map(&:to_s).include?(locale.to_s)
end
def set_locale(route_request = nil)
@request = try(:request) || route_request
@the-teacher
the-teacher / user_settings.json
Created January 12, 2015 15:21
sublime settings
{
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme",
"default_line_ending": "system",
"ensure_newline_at_eof_on_save": true,
"font_size": 18,
"ignored_packages":
[
"Better CoffeeScript",
"Ruby Slim",
"Vintage"
@the-teacher
the-teacher / migration.md
Last active August 29, 2015 14:13
StateMachine => AASM
included do
  # STATES: :draft | :published | :deleted
  
  state_machine :state, initial: TheCommentsBase.config.default_state do
    # events
    event :to_draft do
      transition all - :draft => :draft
    end
var React = require('react/addons');
var ReactIgnore = {
displayName: 'ReactIgnore',
shouldComponentUpdate (){
return false;
},
render (){
return React.Children.only(this.props.children);
}
@the-teacher
the-teacher / throttle.coffee
Last active August 29, 2015 14:11
throttle for js / by underscore.js
# Сколько бы событий не произошло
# Обработчик будет выполнен только 1 раз
# после завершения событий через N ms
@debounce = (func, wait, immediate) ->
timeout = undefined
result = undefined
->
context = this
args = arguments