Skip to content

Instantly share code, notes, and snippets.

View herko's full-sized avatar
💭
I may be slow to respond.

Lubomir Herko herko

💭
I may be slow to respond.
View GitHub Profile
# This is an ExchangeRate model class. It is responsible for keeping local exchange rates up to date.
# Cron job trigger `ExchangeRate.update` to periodically refresh rates. This method also verifies if `auto` update is enabled. This gives admin ability to temporary disable refreshing.
# The update method fetches refresh rates and creates either direct conversion between two currencies, or indirect (through 3rd currency) if its not available.
# This implementation works as is, but can be better. Please refactor this class to extract and separate responsibilities and overall improve code quality.
require 'money/bank/open_exchange_rates_bank'
class ExchangeRate < ActiveRecord::Base
CURRENCIES = %w[usd eur aed] # and more
@herko
herko / route.tsx
Created April 11, 2023 19:55 — forked from rphlmr/route.tsx
Remix Supabase Upload
// if you don't plan to upload only images :
/*
async function convertToFile(data: AsyncIterable<Uint8Array>) {
const chunks = [];
for await (const chunk of data) {
chunks.push(chunk);
}
return chunks;
}
@herko
herko / github_ci.yml
Created May 20, 2021 08:11
Github CI
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
name: Ruby
@herko
herko / _seo.html.erb
Created February 1, 2021 12:39
Managing SEO tags in rails application
<%# app/views/layouts/shared/_seo.html.erb %>
<%
title = construct_title(yield(:title))
description = yield(:description)
og_image = yield(:og_image)
url = yield(:url).presence || request.original_url
%>
<title><%= title %></title>
<meta property="og:title" content="<%= title %>">
@herko
herko / application_form_builder.rb
Created December 14, 2020 19:56
Using custom form builder in rails.
# app/builders/application_form_builder.rb
class ApplicationFormBuilder < ActionView::Helpers::FormBuilder
def form_group(method, options = {}, &block)
content = @template.capture(&block)
content += help_block_with_errors(method) if object.errors[method].any?
options[:class] ||= ""
options[:class] += " form-group"
@template.content_tag :div, content, options
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "shift+cmd+.",
"command": "-breadcrumbs.focusAndSelect",
"when": "breadcrumbsPossible"
},
{
"key": "shift+cmd+.",
"command": "-breadcrumbs.toggleToOn",
class ApplicationFormBuilder < ActionView::Helpers::FormBuilder
def form_group(method, options = {}, &block)
content = @template.capture(&block)
content += help_block_with_errors(method) if object.errors[method].any?
options[:class] ||= ''
options[:class] += ' form-group'
options[:class] += ' has-error' if object.errors[method].any?
@template.content_tag :div, content, options

Keybase proof

I hereby claim:

  • I am herko on github.
  • I am herko (https://keybase.io/herko) on keybase.
  • I have a public key ASA_n9grWcButDu4kKnOkvtHjnl3V1sUvp4Fw4yoQotypQo

To claim this, I am signing this object:

export var structure = {
episodes: [
{
name: 'Planet Sandy',
levels: [
{
videoUrl: '/assets/videos/planet1_intro.mp4',
},
{
levelUrl: '/assets/levels/planet1/01.level',
export var structure = {
episodes: [
{
name: 'Planet Sandy',
levels: [
{
videoUrl: '/assets/videos/planet1_intro.mp4',
},
{
levelUrl: '/assets/levels/planet1/01.level',