Skip to content

Instantly share code, notes, and snippets.

View kamilhism's full-sized avatar

Kamil Hismatullin kamilhism

View GitHub Profile
@kamilhism
kamilhism / gist:3919832
Created October 19, 2012 18:29
test task solve
str = "111222333" * 1000000
a = Time.now
str.scan(/(0+|1+|2+|3+|4+|5+|6+|7+|8+|9+)/).map { |i| "#{i[0].size}#{i[0][0]}" }.join
puts Time.now - a
a = Time.now
str.scan(/((\d)\2*)/).map { |i| "#{i[0].size}#{i[1]}"}.join
puts Time.now - a
@kamilhism
kamilhism / readme.md
Last active October 13, 2015 16:27
Refinery new engine guide

How to create new engine in RefineryCMS

Create empty engine & migrate

rails g refinery:engine project title:string description:text
bundle install
rails generate refinery:projects
rake db:migrate
rake db:seed
#!/usr/bin/env ruby
#
# Proof-of-Concept exploit for Rails SQL Injection (CVE-2013-0156)
#
# ## Advisory
#
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
#
# ## Caveats
#
## The quick-and-nasty CVE-2013-0156 Heroku inspector!
## Originally brought to you by @elliottkember with changes by @markpundsack @ Heroku
## Download and run using:
## ruby heroku-CVE-2013-0156.rb
`heroku list`.split("\n").each do |app|
app = app.strip
# Some "heroku apps" lines have === formatting for grouping. They're not apps.
next if app[0..2] == "==="
@kamilhism
kamilhism / .gitignore
Created January 18, 2013 17:26 — forked from don/.gitignore
.gitignore for visual studio's projects
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
# use: git lg
RAILS_ENV=production rake db:setup
# produces the error below.....hmmm.....it's a no-worky
psql:/yourprojectpath/yourproject/db/structure.sql:29: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory
# hstore postgresql extension needs to be installed, so....
sudo apt-get install postgresql-contrib
# now your extension should be available to enable so log in with psql
psql -d yourproject_production -U yourdbuser -W
def select_from_chosen(item_text, options)
field_id = find_field(options[:from])[:id]
within "##{field_id}_chzn" do
find('a.chzn-single').click
input = find("div.chzn-search input")
item_text.each_char do |char|
input.base.invoke('keypress', false, false, false, false, char.ord, nil);
end
find('ul.chzn-results').click
input.base.invoke('keypress', false, false, false, false, 40, nil); # down arrow
@kamilhism
kamilhism / schema.md
Last active August 29, 2015 14:06
schema
require 'rails_helper'
describe Job do
let(:job) { create(:job) }
let(:mailshop) { create(:mailshop, name: 'Sisk Mailshop') }
let(:version_params) do
{
name: 'U2',
mailshop: mailshop,
quantity: 100_500,