Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Fedorov waterlink

View GitHub Profile
@waterlink
waterlink / application.scss
Created Mar 12, 2014
Accordion without js
View application.scss
@mixin transition($x) {
transition: #{$x};
-o-transition: #{$x};
-moz-transition: #{$x};
-webkit-transition: #{$x};
}
ul.tabs {
list-style: none;
@waterlink
waterlink / rake.rb
Created Mar 18, 2014
RSpec setup for testing rake tasks
View rake.rb
# spec/support/rake.rb
require 'rake'
module Rake::TestHelpers
def run_task(name=subject)
Rake::Task[name].reenable
Rake.application.invoke_task name
end
end
@waterlink
waterlink / database_cleaner.rb
Last active Aug 29, 2015
database_cleaner support config file for RSpec
View database_cleaner.rb
# spec/support/database_cleaner.rb
# inspired by this article http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/
# and later edited according to thoughtbot/suspenders setup (truncation => deletion)
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:deletion)
end
View rspec_rails_cheetsheet.rb
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
View skype-on-docker.sh
# vi: syn=sh :
from ubuntu:12.04
run echo "deb http://archive.ubuntu.com/ubuntu precise main universe multiverse" > /etc/apt/sources.list
run echo "deb http://archive.canonical.com/ precise partner" >> /etc/apt/sources.list
run apt-get -qqyy update
run apt-get install -qqyy x11vnc xvfb skype pulseaudio pavucontrol openssh-server
View gist:1d03dffd6615a513bea8
# smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"
View output
target/john: error while loading shared libraries: libgenerator-e170cac01c08bdc6.so: cannot open shared object file: No such file or directory
@waterlink
waterlink / deriving.rs
Created Nov 4, 2014
Rust: Clone, Show, Send & friends
View deriving.rs
// Clone - for cloning non-owned resources to
// make actions that require ownership
// over them
// Show - if you ever want to log the value of
// this enum
// Send - if you ever want to send it over
// channel to a different task
// PartialEq - if you want to check if two instances
// of this enum are the same
@waterlink
waterlink / lib.rs
Last active Aug 29, 2015
Rust: How to get +50 to karma when implementing an Open Source library ?
View lib.rs
// Use these lines in your root crate source code
#![deny(missing_docs)]
#![deny(warnings)]
// This stuff really works. It adds +50 to karma.
// And frequency of trains being delayed when you want to get
// somewhere in hurry really drops :)
View tips.md
  • Use CONTRIBUTING.md for github to show a link when creating a pull request
  • http://tom.preston-werner.com/2010/08/23/readme-driven-development.html
  • git checkout - to switch to previous branch (that way you can switch between 2 branches forth and back)
  • The first commit of a repo, as the first commit cannot be rebased later: git commit -m "init repo" --allow-empty
  • git status -sb