Skip to content

Instantly share code, notes, and snippets.

View sebastjan-hribar's full-sized avatar

Sebastjan Hribar sebastjan-hribar

View GitHub Profile
@sebastjan-hribar
sebastjan-hribar / Dockerfile
Last active January 18, 2022 13:05
docker-compose up log
FROM ruby:2.7.5-bullseye
RUN apt-get update && apt-get install vim -y
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
RUN adduser --disabled-login app_owner
USER app_owner
# Aggregation
SELECT "id", "language_id", "content", "created_at", "updated_at",
SIMILARITY("content", 'I''m light as a frog') AS "similarity" FROM "segments"
WHERE (("language_id" = 5) AND (similarity("content", 'I''m light as a frog') > 0.45))
ORDER BY SIMILARITY("content", 'I''m light as a frog')
DESC
SELECT "translation_records"."id", "translation_records"."source_segment_id",
"translation_records"."target_segment_id", "translation_records"."domain_id",
"translation_records"."style_id", "translation_records"."project_name",
# segment repository
class SegmentRepository < Hanami::Repository
associations do
has_many :translation_records
has_many :segments, through: :translation_records, as: :target_segments
belongs_to :language
end
def find_by_segment_match(source_text_for_lookup, source_lang, target_lang, sim_score, max_results)
aggregate(:translation_records)
Views
tmsr/apps/godmode/views/contact_persons/edit.rb
module Godmode
module Views
module ContactPersons
class Edit
include Godmode::View
require 'ruby2d'
set( { :title => "Project", :background => "navy", :width => 640, :height => 640, } )
class Tank
attr_accessor :x, :y, :width, :height
def initialize
@x = (get :width) / 2
@y = (get :height) / 2
NoMethodError: undefined method `period' for #<Hanami::View::Rendering::Scope:0x007f4c29979510>
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-view-1.1.0/lib/hanami/view/rendering/layout_scope.rb:236:in `method_missing'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-view-1.1.0/lib/hanami/view/rendering/scope.rb:81:in `method_missing'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-helpers-1.1.1/lib/hanami/helpers/html_helper/html_builder.rb:383:in `method_missing'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-helpers-1.1.1/lib/hanami/helpers/html_helper/html_builder.rb:383:in `method_missing'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-helpers-1.1.1/lib/hanami/helpers/html_helper/html_builder.rb:383:in `method_missing'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-helpers-1.1.1/lib/hanami/helpers/html_helper/html_builder.rb:383:in `method_missing'
/home/seba/projekti/hanami/egu_1/egu_app/apps/web/templates/slots/edit.html.erb:17:in `block (5 levels) in singleton class'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-helpers-1
@sebastjan-hribar
sebastjan-hribar / edit.html.erb
Created October 1, 2017 18:27
Hanami 1.0 update action error
<h2>Update guild</h2>
<% unless params.valid? %>
<div class="errors">
<h3>Input error</h3>
<ul>
<% params.error_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
module Web
module Logging
def self.included(action)
action.class_eval do
unless ENV['HANAMI_ENV'] == "test"
before :write_to_log
end
end
end
server {
listen 80;
server_name domain_name.com;
return 301 https://$server_name$request_uri;
}
server {
@sebastjan-hribar
sebastjan-hribar / rake_error.rb
Created June 9, 2016 05:59
helpers rake test error
(eval):2: warning: method redefined; discarding old link
(eval):2: warning: previous definition of link was here
/home/sebastjan/.rvm/gems/ruby-2.2.1/bundler/gems/view-6a51e5cd3daf/lib/hanami/presenter.rb:1: warning: loading in progress, circular require considered harmful - /home/sebastjan/.rvm/gems/ruby-2.2.1/bundler/gems/view-6a51e5cd3daf/lib/hanami/view/escape.rb
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:4:in `<main>'
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:4:in `select'
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:9:in `each'
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:10:in `require'