Skip to content

Instantly share code, notes, and snippets.

View biske's full-sized avatar

Ivan Bisevac (Иван Бишевац) biske

View GitHub Profile
# Creat a PIT (Point in Time)
POST /auditbeat-8.0.0/_pit?keep_alive=10m

# First page of 2 items (no "search_after" specified)
GET /_search
{
  "size": 2, 
  "pit": {
 "id": "46ToAwEhYXVkaXRiZWF0LTguMC4wLTIwMjIuMDIuMTQtMDAwMDAxFmI2ZEk1NnMtUlZxM25hY3ZkeUVnN2cAFk0tblloZ2RYUjVDWUJLQUhYUHNmdHcAAAAAAAAEnSMWR0NfVWdlakZSSEszcGVzbXpfSTdoZwABFmI2ZEk1NnMtUlZxM25hY3ZkeUVnN2cAAA==",
@biske
biske / elasticsearch-setup-apple-macbook-pro-m1.md
Created April 25, 2023 13:13 — forked from todgru/elasticsearch-setup-apple-macbook-pro-m1.md
Install Elasticsearch 7.x on Apple Macbook Pro M1 Ventura 13.2

Elasticsearch Setup Apple MacBook Pro M1

Apple MacBook Pro M1, 32 GB, Ventura 13.2

Documentation based on comments in this Github Elasticsearch issue.

Install Homebrew

@biske
biske / time_vs_datatime.md
Created September 28, 2016 11:24 — forked from pixeltrix/time_vs_datatime.md
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@biske
biske / postforms.js
Created December 26, 2015 10:27 — forked from adactio/postforms.js
Show a progress bar when a form is submitted (and prevent more than one submission per document).
/*
Show a progress element for any form submission via POST.
Prevent the form element from being submitted twice.
*/
(function (win, doc) {
'use strict';
if (!doc.querySelectorAll || !win.addEventListener) {
// doesn't cut the mustard.
return;
}
class CompressedRequests
def initialize(app)
@app = app
end
def method_handled?(env)
!!(env['REQUEST_METHOD'] =~ /(POST|PUT)/)
end
def encoding_handled?(env)
http://blog.mattwynne.net/2012/04/09/hexagonal-rails-introduction/
http://darwinweb.net/articles/modular-development-on-rails
+-----------------------+------------------+-----------------+
|                       | eager load paths | auto load paths |
+-----------------------+------------------+-----------------+
| Rails 3 (development) | auto loaded      | auto loaded     |
| Rails 4 (development) | auto loaded      | auto loaded     |
| Rails 3 (production)  | eager loaded     | auto loaded     |
| Rails 4 (production)  | eager loaded     | eager loaded    |
+-----------------------+------------------+-----------------+
@biske
biske / user.rb
Created August 14, 2014 11:27 — forked from moeffju/user.rb
class User < ActiveRecord::Base
alias :devise_valid_password? :valid_password?
def valid_password?(password)
begin
devise_valid_password?(password)
rescue BCrypt::Errors::InvalidHash
return false unless Digest::SHA1.hexdigest(password) == encrypted_password
logger.info "User #{email} is using the old password hashing method, updating attribute."
self.password = password
class ControllerTestCase < ActionController::TestCase
include Devise::TestHelpers
include Warden::Test::Helpers
def setup
Warden.test_mode!
self.do_setup
end
@biske
biske / template.rb
Last active December 24, 2015 12:09 — forked from jnicklas/template.rb
require "capybara"
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
sess = Capybara::Session.new(:selenium, app)
sess.visit("/")
puts sess.find('#id1').text
__END__