Skip to content

Instantly share code, notes, and snippets.

View dzaporozhets's full-sized avatar

Dmitriy Zaporozhets dzaporozhets

View GitHub Profile
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@dzaporozhets
dzaporozhets / gist:3696927
Created September 11, 2012 08:35
seed data
# Seed cucumber data
require 'seed-fu'
SeedFu.quiet = true
puts "Seeding data...(checkout db/fixtures/test)"
SeedFu.seed(Rails.root.join('db/fixtures/test'
sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \
git
# ubuntu/debian
sudo adduser --disabled-login --gecos 'gitlab system' gitlab
sudo gem install charlock_holmes --version '0.6.8'
sudo pip install pygments
sudo gem install bundler
cd /home/gitlab
# Skip this for stable setup.
# Master branch (recent changes, less stable)
sudo -H -u gitlab git clone -b master https://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip libyaml-dev postfix
# If you want to use MySQL:
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar xfvz ruby-1.9.3-p194.tar.gz
@dzaporozhets
dzaporozhets / gist:3826391
Created October 3, 2012 10:57
Disable form buttons while a form is submitting
$ ->
# Disable form buttons while a form is submitting
$('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) ->
buttons = $('[type="submit"]', this)
switch e.type
when 'ajax:beforeSend', 'submit'
buttons.disable()
else
buttons.enable()
@dzaporozhets
dzaporozhets / gist:3826869
Created October 3, 2012 13:21
disable button
(($) ->
# Disable an element and add the 'disabled' Bootstrap class
$.fn.extend disable: ->
$(this).attr('disabled', 'disabled').addClass('disabled')
# Enable an element and remove the 'disabled' Bootstrap class
$.fn.extend enable: ->
$(this).removeAttr('disabled').removeClass('disabled')
)(jQuery)
@dzaporozhets
dzaporozhets / console
Created October 11, 2012 08:00 — forked from dmitriy-kiriyenko/console
Init.d to start/stop xvfb. Put it into /etc/init.d and chmod it to 755
apt-get install xvfb
apt-get install firefox
@dzaporozhets
dzaporozhets / gitlab_gitolite.sh
Created October 24, 2012 13:58
Fix gitolite for gitlab 3
# GITOLITE 3
sudo -u git -H sed -i "s/\(GIT_CONFIG_KEYS\s*=>*\s*\).\{2\}/\1'\.\*'/g" /home/git/.gitolite.rc
# GITOLITE 2
sudo -u git -H sed -i 's/\(GL_GITCONFIG_KEYS\s*=>*\s*\).\{2\}/\1"\.\*"/g' /home/git/.gitolite.rc
@dzaporozhets
dzaporozhets / gist:3981157
Created October 30, 2012 15:59 — forked from thijsc/gist:1391107
Select item from chosen js select with Capybara and Selenium
def select_from_chosen(item_text, options)
field = find_field(options[:from])
option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()")
page.execute_script("$('##{field[:id]}').val('#{option_value}')")
end