The goal: Upload several files (virtually big files) to a Rails application without compromising the user experience.
jQuery File Upload + Nginx + Rails (Carrierwave) + Sidekiq
- jQuery File Upload (http://blueimp.github.io/jQuery-File-Upload/)
| <script type="text/javascript"> | |
| (function () { | |
| "use strict"; | |
| // once cached, the css file is stored on the client forever unless | |
| // the URL below is changed. Any change will invalidate the cache | |
| var css_href = './index_files/web-fonts.css'; | |
| // a simple event handler wrapper | |
| function on(el, ev, callback) { | |
| if (el.addEventListener) { | |
| el.addEventListener(ev, callback, false); |
The goal: Upload several files (virtually big files) to a Rails application without compromising the user experience.
jQuery File Upload + Nginx + Rails (Carrierwave) + Sidekiq
| # ************************************** | |
| # XML パーステスト | |
| # ************************************** | |
| # | |
| require 'hpricot' | |
| require 'nokogiri' | |
| class TestXml | |
| FILE_XML = "sitemap.xml" | |
| N = 100 |
| namespace :deploy do | |
| before :updated, :setup_solr_data_dir do | |
| on roles(:app) do | |
| unless test "[ -d #{shared_path}/solr/data ]" | |
| execute :mkdir, "-p #{shared_path}/solr/data" | |
| end | |
| end | |
| end | |
| end |
This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.
The script is here:
#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"
#Getting Started
##Webpage:
<html>
<head>
<title>Testing with Ruby and Selenium WebDriver</title>
</head>
<body bgcolor="antiquewhite">
| Usage example: | |
| >> text = Morpher.new('Большой город') | |
| {:Р=>"Большого города", :Д=>"Большому городу", :В=>"Большой город", :Т=>"Большим городом", :П=>"Большом городе", :П_о=>"о Большом городе", :род=>"Мужской", :множественное=>{:И=>"Большие города", :Р=>"Больших городов", :Д=>"Большим городам", :В=>"Большие города", :Т=>"Большими городами", :П=>"Больших городах", :П_о=>"о Больших городах"}, :где=>"в Большом городе", :куда=>"в Большой город", :откуда=>"из Большого города"} | |
| >> text.singular('Д') | |
| "Большому городу" | |
| >> text.plural('Д') |
| require "awesome_print" | |
| module XmlParsing | |
| require "ox" | |
| class Reader < ::Ox::Sax | |
| def initialize file_path, target, target_handler | |
| @target_handler = target_handler | |
| @target = target | |
| @file_path = file_path |
Когда мы хотим скопировать данные из production окружения Ruby on Rails приложения в development или staging, обычно, нам нужно скопировать дамп базы данных и статические файлы (например, изображения загруженные пользователями). Копирование базы может не представляет проблем (например, ее можно копировать из бэкапов или резервных серверов БД). А вот копирование статических файлов занимает много времени и ресурсов сервера с которого копируют (и на который копируются) файлы.
В рассылке ror2ru Макс Лапшин предложил
| server { | |
| listen 443 ssl; | |
| server_name your-app.dev; | |
| root /path/to/your-app/public; | |
| index index.html index.htm; | |
| ### SSL log files ### | |
| access_log logs/your-app.dev-ssl-access.log; | |
| error_log logs/your-app.dev-ssl-error.log; |