Skip to content

Instantly share code, notes, and snippets.

View voleoo's full-sized avatar
🏠
Working from home

Viktor Leonets voleoo

🏠
Working from home
View GitHub Profile
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@voleoo
voleoo / has_one или belongs_to
Created July 9, 2013 18:22
has_one или belongs_to
Все просто, объясню на примере:
Представим следующую ситуацию, у нас есть юзеры, а у каждого юзера есть 1 проект.
В бд это будет так:
таблица users ( id, ... )
таблица projects ( id, user_id, ... )
Нам надо написать такой код:
class Project < ActiveRecord::Base
belongs_to :user
validates :email, :password, presence: true
validates :password, length: { in: 6..20 }
validates :email, confirmation: true
validates :email, format: { with: /\A[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})\Z/, :message => "Only emails allowed" }
validates :email, uniqueness: true
validates :credit_card, length: { is: 16 }
validates :price, numericality: true

AngularJS best ressources

Following the AngularJS PARIS meetup (25/2 à 19h à Paris with @sampaccoud @dzen @_kemar @tchack13 @vinz et @revolunet)

Here's our best AngularJS ressources : twitter, github, articles & blogs. Please comment and add your good stuff !

mysql -u root -p -e "create database base_name"
mysqldump -h localhost -u root -p base_name > base_name_1378306025.sql
mysql --max-allowed-packet=500M -h localhost -u root -p base_name < base_name_1378306025.sql
-------
cd /Applications/XAMPP/xamppfiles/bin
./mysql
ls command options
ls command main options:
option description
ls -a list all files including hidden file starting with '.'
ls --color colored list [=always/never/auto]
ls -d list directories - with ' */'
ls -F add one char of */=>@| to enteries
ls -i list file's inode index number
ls -l list with long format - show permissions
rails g migration add_image_to_adf_special_offers image:string
rails g migration remove_image_from_adf_special_offers image:string
@voleoo
voleoo / deploy.rb
Created November 23, 2013 20:50 — forked from mm53bar/deploy.rb
require File.join(File.dirname(__FILE__), 'deploy/nginx')
require File.join(File.dirname(__FILE__), 'deploy/log')
default_run_options[:pty] = true
set :ssh_options, { :forward_agent => true }
set :application, "appname"
set :repository, "git@giturl"
set :scm, :git
Установка nodejs на debian
# echo deb http://ftp.us.debian.org/debian/ sid main > /etc/apt/sources.list.d/sid.list
# apt-get update
# apt-get install nodejs
deb http://apt.postgresql.org/pub/repos/apt/ squeeze-pgdg main
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3
http://wiki.postgresql.org/wiki/Apt