This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dataURLToBlob(dataURL) { | |
var BASE64_MARKER = ';base64,'; | |
if (dataURL.indexOf(BASE64_MARKER) == -1) { | |
var parts = dataURL.split(','); | |
var contentType = parts[0].split(':')[1]; | |
var raw = decodeURIComponent(parts[1]); | |
return new Blob([raw], {type: contentType}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Load Zepto as module */ | |
module.exports = { | |
entry: "./app.js", | |
output: { | |
path: __dirname, | |
filename: "bundle.js" | |
}, | |
module: { | |
loaders: [ | |
{ test: /zepto(\.min)?\.js$/, loader: "exports?Zepto; delete window.$; delete window.Zepto;" }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
manifest.json: | |
"permissions": [ | |
"management" | |
] | |
*/ | |
var link = document.createElement('a'); | |
link.appendChild(document.createTextNode('Create Yandex shortcut')); | |
document.body.appendChild(link); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -w | |
# for passenger 3.0 | |
# | |
# cron | |
# */15 * * * * root /root/bin/kill-frozen-passenger-instances | |
require 'rubygems' | |
require 'net/http' | |
require 'uri' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActsAsFerret | |
class SearchResults | |
# To prevent WillPaginate warning | |
attr_reader :total_pages | |
end | |
module ClassMethods | |
def paginate_search(query, options = {}, find_options = {}) | |
page, per_page = wp_parse_options(options) | |
offset = (page.to_i - 1) * per_page |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module WillPaginate | |
module ViewHelpers | |
# Настройки WillPaginate | |
pagination_options[:class] = 'g-pager' | |
pagination_options[:previous_label] = '← предыдущая' | |
pagination_options[:next_label] = 'следующая →' | |
# Поддержка TableView | |
def will_paginate_with_table_view(collection = nil, options = {}) | |
collection = collection.data if TableView === collection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Преобразует PDF-документ в текст | |
def attachment2text(attach) | |
content = '' | |
if attach.content_type == 'application/pdf' | |
command = "pdftotext -q -eol unix -enc UTF-8 -nopgbrk \"#{attach.full_filename}\" -" | |
content = `#{command}` | |
end | |
content |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RussianStemmingAnalyzer < Ferret::Analysis::Analyzer | |
include Ferret::Analysis | |
include ActionView::Helpers::SanitizeHelper | |
def initialize(stop_words = FULL_RUSSIAN_STOP_WORDS) | |
@stop_words = stop_words | |
@full_sanitizer = HTML::FullSanitizer.new | |
end | |
def token_stream(field, str) |