Skip to content

Instantly share code, notes, and snippets.

View jonian's full-sized avatar
🏠
Working from home

Jonian Guveli jonian

🏠
Working from home
View GitHub Profile
@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active October 16, 2025 04:30
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

@jmcabandara
jmcabandara / readme.md
Created June 14, 2019 06:22 — forked from maxivak/readme.md
Integrating Gem/Engine and Main Rails App
@kytulendu
kytulendu / install-opencl-amd.sh
Last active August 12, 2025 01:32
A shell script to install AMDGPU-PRO OpenCL driver.
#!/bin/bash
# This script will install AMDGPU-PRO OpenCL and Vulkan support.
#
# For Ubuntu and it's flavor, just install the package using this command
# in extracted driver directory instread.
#
# ./amdgpu-pro-install --opencl=legacy,pal --headless --no-dkms
#
# For Arch Linux or Manjaro, use the opencl-amd or rocm-opencl-runtime on AUR instread.
@danieldraper
danieldraper / application_form.rb
Last active September 10, 2020 06:17
Service object and form object using ActiveModel and dry-rb
require "dry/monads/result"
class ApplicationForm
include Dry::Monads::Result::Mixin
include ActiveModel::Model
def self.attribute(name, options = {})
self.send(:attr_accessor, name)
_attributes << Attribute.new(name, options)
end
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active August 28, 2025 15:49
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@robsontenorio
robsontenorio / auth-refresh-token.js
Last active February 3, 2023 14:02
[OAUTH2][KEYCLOAK] Auto refresh token for @nuxtjs/auth module
const strategy = 'keycloak'
export default function ({ app }) {
const { $axios, $auth } = app
if (!$auth.loggedIn || !$auth.strategies[strategy])
return
const options = $auth.strategies.keycloak.options
class ApplicationController
before_action :authenticate_user
def authenticate_user
response = TokenAuthService.call(token: request.headers['Api-Token'] || params[:api_token])
if response.failure?
render json: {
error: 'Not Authorized',
message: response.error
@simenbrekken
simenbrekken / README.md
Last active August 7, 2019 15:01
Apollo Client 2.0 withFragments

This HoC gives you a way to work with co-located fragments that is similar to Relay's FragmentContainer

It supports both fragment maps extrapolation of prop names from fragment definitions.

Fragment map

export default withFragments({
  price: gql`
 fragment ProductDetails_price on Product {
@fmuellner
fmuellner / adjust-to-tray-removal.patch
Last active August 23, 2017 21:29
Adjust topIcons extension to the legacy tray removal in GNOME 3.26
From 03b014746fa67bb76d73d9ff5274dce461fa413b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Sat, 19 Aug 2017 14:34:00 +0200
Subject: [PATCH 1/2] Adjust to tray removal in gnome-shell
GNOME 3.26 will no longer display status icons by default, so there is
no system tray we can take over. Take this case into account to avoid
errors, although this alone doesn't give us back status icons - we will
do that in a second step by starting to manage our own tray.
---
@theorygeek
theorygeek / association_loader.rb
Last active June 6, 2025 19:25
Preloading Associations with graphql-batch
# frozen_string_literal: true
class AssociationLoader < GraphQL::Batch::Loader
attr_reader :klass, :association
def initialize(klass, association)
raise ArgumentError, "association to load must be a symbol (got #{association.inspect})" unless association.is_a?(Symbol)
raise ArgumentError, "cannot load associations for class #{klass.name}" unless klass < ActiveRecord::Base
raise TypeError, "association #{association} does not exist on #{klass.name}" unless klass.reflect_on_association(association)
@klass = klass