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
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: zykin_kupi_bilet_frontend_dev
pool: 5
username: zykin
password: zykin
socket: /var/lib/mysql/mysql.sock
@the-teacher
the-teacher / gist:3103066
Last active October 7, 2015 04:07
UBUNTU + RAILS
VBOX
C:\Users\USER\VirtualBox VMs\Ubuntu>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd Ubuntu.vdi --resize 10000
BUTTONS
gconftool-2 --set "/apps/metacity/general/button_layout" --type string "menu:minimize,maximize,close"
gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'
GNOME COMMANDER
sudo apt-get install gnome-commander -y
@the-teacher
the-teacher / gist:3104483
Created July 13, 2012 11:46
Coffee Script TagHelper Template
$ ->
class @TagHelper
constructor: (test_mode = false) ->
if test_mode
console.log "h = new document.TagHelper"
console.log @cdata_section('<hello world>')
console.log @tag('br')
console.log @tag('br', null, true)
console.log @tag('br', null, false)
@the-teacher
the-teacher / gist:3110116
Created July 14, 2012 09:02
EvilMartians First task
# encoding: utf-8
class EmailPatternValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if value.nil? || !value.match(/\b[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}\z/)
record.errors[attribute] << "HA HA! Not a valid email address"
end
end
end
@the-teacher
the-teacher / index.html
Created September 9, 2012 16:52
Example of building of custom clandars with TheTime.js framework. TheTime.js - Date object wrapper for Node.js and Browser JS. TheTime.js Makes work with JS Date object easier and more humane.
<div class='calendar_modern' id='calendar'></div>
<div class='time_list'>
<p>
<b>Click on day for select.</b>
</p>
<p>
<b>Second click for unselect.</b>
</p>
<p>List of selected days:</p>
@the-teacher
the-teacher / JS logger
Created October 18, 2012 07:13
JS/Coffee logger
@trace_mode = false
# _log - global log - выводит сообщения всегда
# log - выводит сообщения везде кроме production
# trace - выводит сообщения только если включен флаг trace_mode
# report - отправляет AJAX на сервер с сообщением
@_log = -> console.log.apply(console, arguments)
@log = -> _log.apply(console, arguments) unless env.production()
@trace = -> _log.apply(console, arguments) if trace_mode
@the-teacher
the-teacher / gist:4265679
Created December 12, 2012 07:01
Building Valid Rails Form with csrf token via JQuery (JavaScript, CoffeeScript)
$.rails.form_build = (url = '#', method = 'get', opts = {}) ->
_method = ''
method = method.toLowerCase()
# csrf
csrf_token = $('meta[name=csrf-token]').attr('content')
csrf_param = $('meta[name=csrf-param]').attr('content')
# build options
_opts = ''
_opts += " #{k}=#{v}" for k, v of opts
# method addons
@compactArray = (array) ->
array.filter (e) -> return e
class @OrderedHash
constructor: (array = []) ->
@data = []
@data = array if array.length > 0
get: -> @data
push: (obj) ->
@the-teacher
the-teacher / gist:5038123
Created February 26, 2013 12:34
some encoding magic for windows
#encoding:utf-8
gets.chomp.encode("utf-8", "cp866")
Iconv.iconv('utf8', 'cp866', "Привет!")
class ErbEngine < Haml::Engine
def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
escape_html = false, nuke_inner_whitespace = false)
push_text "<%= #{text.strip} %>"
end
def push_silent(text, can_suppress = false)
push_text "<% #{text.strip} %>"
end
end