Skip to content

Instantly share code, notes, and snippets.

@nichtich
nichtich / wiktionarylookup.html
Created November 12, 2010 19:10
Look up a word in Wiktionary via MediaWiki API and show the Wiktionary page
<html>
<head>
<script type="text/javascript" src="./jquery-1.4.3.min.js"></script>
<script type="text/javascript">
var baseURL = 'http://en.wiktionary.org';
function showPage(page,text) {
var sourceurl = baseURL + '/wiki/' + page;
$('#pagetitle').text(page);
$('#wikiInfo').html(text);
$('#sourceurl').attr('href',sourceurl);
@marcinbunsch
marcinbunsch / profiling_tool.rb
Created December 29, 2011 14:22 — forked from ksarna/profiling_tool.rb
Profiling rails requests with ruby-prof
# You can use this class in your console. For example
# p = ProfilingTools.new
# p.profiled_request(:controller => :welcome, :action => :index)
# this will profile whole application stack and save file in your tmp/profiler folder
# You can also use +request+ method just to see the output for example:
#
# p.request(:controller => :offers, :action => :index)
#
# p.response.body
# p.response.cookies # and so on
@danmartens
danmartens / ember.array_extensions.js.coffee
Created June 8, 2012 19:21
Ember.js Array Extensions
# Sorts an array based on a property of each object within the array
#
# Examples:
#
# [Em.Object.create(a: 1), Em.Object.create(a: 5), Em.Object.create(a: 3)].sortProperty('a')
# > [{a: 1}, {a: 3}, {a: 5}]
#
# As a computed property:
#
# AC = Em.ArrayController.extend
@mikhailov
mikhailov / 0. nginx_setup.sh
Last active June 29, 2024 23:43
NGINX+SPDY with Unicorn. True Zero-Downtime unless migrations. Best practices.
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@zinkkrysty
zinkkrysty / padded_box_helper.rb
Created December 18, 2012 10:35
Automatic padding of bounding box in Prawn, and allows for filling in the background color. Currently only when specifying height, but I'm open to suggestions.
require 'prawn'
module PaddedBoxHelper
#
# Fills the background of the box you're in
#
def fill_bg_color color
float do
fill_color color
@zeroDivisible
zeroDivisible / gist:5936526
Last active January 6, 2024 20:14
Learning Japanease, taken from http://pastebin.com/w0gRFM0c
Resources marked with > are used, have been used, or are actively advocated in the threads. This applies for everything in the [Necessities] section.
[Necessities]
Hiragana & Katakana: http://www.realkana.com/
Kanji: http://kanjidamage.com/
Japanese IME: http://www.google.com/intl/ja/ime/
Anki Flashcards: http://ankisrs.net/
Genki (↓Bottom↓)
Tae Kim Japanese: http://www.guidetojapanese.org/learn/grammar
@ryrych
ryrych / computed_property_builder.js.coffee
Created February 18, 2014 20:23
Ember.js Dynamic Computed Property Builder (based on http://www.thesoftwaresimpleton.com/blog/2013/08/11/dyanamic-cp/ by Paul Cowan)
Em.computedPropertyBuilder = (that, name, key, fn) ->
Em.defineProperty that, name, Em.computed(->
fn
).property "#{key}"
@pixelhandler
pixelhandler / transforms.js
Last active October 3, 2016 06:54
Raw object and array tranforms for Ember Data
/*
DS.attr('object')
*/
App.ObjectTransform = DS.Transform.extend({
deserialize: function(value) {
if (!$.isPlainObject(value)) {
return {};
} else {
return value;
}
@dragolabs
dragolabs / ubunru-rsyslog-hack.sh
Last active August 18, 2017 16:35
Hack to repair 100% CPU load by rsyslog on ubuntu 12.04 in openvz
#!/bin/sh
service rsyslog stop
sed -i -e 's/^\$ModLoad imklog/#\$ModLoad imklog/g' /etc/rsyslog.conf
service rsyslog start

Elasticsearch - поисковый движок с json rest api, использующий Lucene и написанный на Java. Описание всех преимуществ этого движка доступно на официальном сайте. Далее по тексту будем называть Elasticsearch как ES.

Подобные движки используются при сложном поиске по базе документов. Например, поиск с учетом морфологии языка или поиск по geo координатам.

В этом уроке я расскажу про основы ES на примере индексации постов блога. Покажу как фильтровать, сортировать и искать документы.

Что бы урок был максимально кроссплатформенным все запросы к ES я буду делать с помощью CURL. Так же есть плагин для google chrome.

По тексту урока расставлены ссылки на другие источники. В конце урока размещены ссылки для быстрого доступа к документации. Определения незнакомых терминов можно прочитать в [глоссарии](http://www.elasticsearch.org/guide/en/elasticsearch/reference/curre