Skip to content

Instantly share code, notes, and snippets.

PARAMS = [
{ word: 'amalgamation', card: '1.jpg', audio: '1.ogg', example: 'The company began as an *amalgamation* of small family firms', translation: 'скрещивание' },
{ word: 'allotment', card: '2.jpg', audio: '2.ogg', example: 'An amount *allotted* to a person', translation: 'доля' },
{ word: 'dumbfound', card: '3.jpg', audio: '3.ogg', example: 'She was *dumbfounded* at the sight that met her eyes', translation: 'ошарашить' },
{ word: 'booty call', card: '4.jpg', audio: '4.ogg', example: "My roomate doesn't have a boyfriend, but last night she got a *booty call* and came back an hour later with a smile on her face", translation: 'встреча для секса' },
{ word: 'exterminate', card: '5.jpg', audio: '5.ogg', example: "I believed that if I could find Dracula and *exterminate* him I might be completely well again, a good mother, a person with a new life.", translation: 'уничтожить' },
{ word: 'ex
@sharipov-ru
sharipov-ru / exceptions_handling.rb
Last active August 29, 2015 14:01
Exceptions handling with ruby 2.1
class ServiceException < StandardError; end
class RepositoryException < StandardError; end
class RethinkDBError < StandardError; end
class RecordsController
def self.update
RecordsService.update(@record)
rescue ServiceException => error
puts "Failure: #{error.inspect}"
puts "Original failure: #{error.cause.inspect}"
# MOVE
# depends on slice set, here is the best results:
# 10K records - 1.2 seconds
# 100K records - 12.0 seconds
db.table('groups').filter(test: 1).run(conn).each_slice(1000) do |group_set|
db.table('archived_groups').insert(group_set).run(conn)
end
# UPDATE
# 10K records - 7 seconds
@sharipov-ru
sharipov-ru / development.rb
Last active December 20, 2016 14:20 — forked from dhh/gist:2492118
config.middleware.use RoutesReloader

irb(main):029:0* GeoEntity.last

GeoEntity Load (0.5ms) SELECT geo_entities.* FROM geo_entities ORDER BY geo_entities.id DESC LIMIT 1

returns:

County id: 4, eid: nil, pid: nil, ename: nil, etype: 2, created_at: "2011-11-21 06:26:37", updated_at: "2011-11-21 06:26:37"

@sharipov-ru
sharipov-ru / rpi_stress.sh
Created June 9, 2013 16:33
Simple raspberry pi stress testing script
#!/bin/bash
while :
do
echo "Performing new stress testing cycle..."
stress --cpu 20 --io 20 --vm 6 --vm-bytes 25M --timeout 120s
echo "Timeout..."
sleep 3
done
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
100.times do
user = FactoryGirl.create(:user)
form = FactoryGirl.create(:form)
# Example usage of a Submissions-storage to read/write submissions (user answers)
# It let us don't care much in application how would storage work and which database it uses
# Write a value to storage
#
# user.storage_for(form.token).store(key, value)
100.times do
user = FactoryGirl.create(:user)
form = FactoryGirl.create(:form)
# Example usage of a Submissions-storage to read/write submissions (user answers)
# It let us don't care much in application how would storage work and which database it uses
# Write a value to storage
#
# user.storage_for(form.token).store(key, value)
ru:
errors:
messages:
expired: "устарела. Пожалуйста, запросите новую"
not_found: "не найдена"
already_confirmed: "уже подтверждена. Пожалуйста, попробуйте войти в систему"
not_locked: "не заблокирована"
not_saved:
one: "%{resource}: сохранение не удалось из-за %{count} ошибки"
few: "%{resource}: сохранение не удалось из-за %{count} ошибок"