Skip to content

Instantly share code, notes, and snippets.

View bsa7's full-sized avatar

Belevskij Sergeij bsa7

View GitHub Profile
@bsa7
bsa7 / trick.markdown
Created June 24, 2014 13:55
git stash some files

If you are changed some files, but won't include its in your commit, do next:

  1. include files only you need:

git add filename

  1. stash other files:

git stash --keep-index

@bsa7
bsa7 / tricks
Last active August 29, 2015 14:03
redmine textile formatting
url=http://www.redmine.org/projects/redmine/wiki/RedmineTextFormatting
Email addresses
Email addresses are automatically turned into clickable links:
"Email someone":mailto:someone@foo.bar -- Email link with different text: Email someone
More complex email instructions can be added to an email link. A default subject, default body and CC information can be defined. Note that spaces in any of these fields need to be replaced with the code %20.
"Email webmaster and admin":mailto:webmaster@foo.bar?cc=admin@foo.bar -- Email to webmaster, CC admin: Email webmaster and admin
"Email someone for help":mailto:someone@foo.bar?subject=Website%20Help -- Email link with the subject "Website Help": Email someone for help
@bsa7
bsa7 / application.js
Created June 29, 2014 11:55 — forked from lexmag/application.js
Rails 3,4 streaming
//= require jquery
//= require jquery_ujs
$(function() {
var source = new EventSource('/stream');
source.addEventListener('counter', function(e) {
$('body').after(e.data + '<br />');
});
});
@bsa7
bsa7 / hint.markdown
Created July 1, 2014 04:38
ubuntu - find files in directory recursive and delete thems. Symlinks also.
find -L . -name "*.png.webp" -exec rm {} \;
@bsa7
bsa7 / hint.rb
Last active August 29, 2015 14:03
ruby delete files recurcive by regexp
require 'colorize'
#
# параметр - регулярное выражение в кавычках.
#
# пример вызова:
#
# ruby delete_by_regexp.rb '^*.-[a-z0-9]{32}\..+?$'
def listdir(dirname, regexp, indent="")
dir_print = "#{indent}#{dirname}".green
@bsa7
bsa7 / README.md
Last active August 29, 2015 14:03
redis-colors table of 1300 color for use with redis (en-ru)

Example

In redis database after rake load_colors you must seen this:

Example of result in redis database

@bsa7
bsa7 / hint.rb
Created July 11, 2014 04:38
rails bulk insert
ActiveRecord::Base.transaction do
1000.times { Model.create(options) }
end
@bsa7
bsa7 / Readme.md
Last active August 29, 2015 14:04
ruby hash pretty print to console

my_pretty_print module

###example: ####0. Initialize your hash:

h = {some: 1, "the" => {subone: "true", subtwo: [1,2,"3333", {subsub: "one", nonenone: {twotwo: [{keyone: 1, keytwo: ["222","sdsd"]},1,2], some: "free"}}]}, ne: "xt"}

####1. simple:

=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@bsa7
bsa7 / xvfb and capybara on ubuntu server.markdown
Last active August 29, 2015 14:04
xvfb + capybara + webkit

####Install.

sudo apt-get install libqt4-dev
sudo apt-get install xvfb

Gemfile:

gem "capybara-webkit"