Skip to content

Instantly share code, notes, and snippets.

View svlasov's full-sized avatar

Sergey Vlasov svlasov

  • Israel
View GitHub Profile
  1. General Background and Overview
@svlasov
svlasov / decorator.py
Created May 18, 2014 11:44
Parameterized decorator
def decoratorFunctionWithArguments(arg1, arg2, arg3):
def wrap(f):
print "Inside wrap()"
def wrapped_f(*args):
print "Inside wrapped_f()"
print "Decorator arguments:", arg1, arg2, arg3
f(*args)
print "After f(*args)"
return wrapped_f
return wrap
@svlasov
svlasov / gist:e9933a6316b2672cfe16
Created May 18, 2014 11:35
check if a directory exists and create it if necessary
if not os.path.exists(directory):
os.makedirs(directory)
@svlasov
svlasov / .railsrc
Created March 22, 2014 10:29
New Rails 4 application setup
# ~/.bashrc
--skip-bundle
--skip-test
--database postgresql
@svlasov
svlasov / Gemfile
Created October 25, 2013 07:34 — forked from flomotlik/Gemfile
gem 'foreman'
gem 'puma'
@svlasov
svlasov / users.yml
Created September 4, 2013 12:46 — forked from henrydjacob/users.yml
user1:
email: [email protected]
encrypted_password: <%= User.new.send(:password_digest, "user123") %>
confirmed_at: <%= Time.now %>
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@svlasov
svlasov / Gemfile
Created March 8, 2013 23:53
Setup database cleaner in Rails app
group :test do
gem 'rspec-rails'
gem 'shoulda-matchers'
gem 'capybara'
gem 'factory_girl_rails'
gem 'database_cleaner'
gem 'jasmine'
end
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
@svlasov
svlasov / _login_items.html.erb
Last active December 12, 2015 09:19
Devise menu items
<% if user_signed_in? %>
<li>
<%= link_to('Logout', destroy_user_session_path, :method => :delete) %>
</li>
<% else %>
<li>
<%= link_to('Login', new_user_session_path) %>
</li>
<% end %>