Skip to content

Instantly share code, notes, and snippets.

View chanakasan's full-sized avatar

Chanaka Abeysinghe chanakasan

View GitHub Profile
@chanakasan
chanakasan / component_helper.rb
Created June 14, 2024 08:35
view component helper
# frozen_string_literal: true
module ComponentHelper
def component(name, *, **, &)
component_name = "#{name}_component".split('__').map(&:classify).join('::')
render(component_name.constantize.new(*, **), &)
end
def component_alt(name, *, **, &)
component_name = "#{name}__component".split('__').map(&:classify).join('::')
@chanakasan
chanakasan / controllers index.js
Last active May 27, 2024 05:03
Stimulus - integrate with popper.js
// app/javascript/controllers/index.js
import PopperController from "./popper_controller"
application.register("popper", PopperController)
@chanakasan
chanakasan / capybara-chrome-setup.md
Last active February 22, 2021 12:53 — forked from bbonamin/Brewfile
Capybara Selenium Webdriver: Headless Chrome (with file downloads!) & Headless Firefox

Blank

@chanakasan
chanakasan / DependencyInjectionInRuby.md
Created November 22, 2020 01:00 — forked from blairanderson/DependencyInjectionInRuby.md
Dependency Injection in Ruby. Originally from Jim Weirich’s blog which does not exist except for googles cache.

Dependency Injection in Ruby 07 Oct 04

Introduction

At the 2004 Ruby Conference, Jamis Buck had the unenviable task to explain Dependency Injection to a bunch of Ruby developers. First of all, Dependency Injection (DI) and Inversion of Control (IoC) is hard to explain, the benefits are subtle and the dynamic nature of Ruby make those benefits even more marginal. Furthermore examples using DI/IoC are either too simple (and don’t convey the usefulness) or too complex (and difficult to explain in the space of an article or presentation). I once attempted to explain DI/IoC to a room of Java programmers (see onestepback.org/articles/dependencyinjection/), so I can’t pass up trying to explain it to Ruby developers.

Thanks goes to Jamis Buck (the author of the Copland DI/IoC framework) who took the time to review this article and provide feedback.

What is Dependency Injection?

@chanakasan
chanakasan / phpenv-install.md
Created July 24, 2020 19:22 — forked from sergeyklay/phpenv-install.md
Multiple PHP versions using phpenv and php-build

Multiple PHP versions using phpenv and php-build

Install dependecies

Debian/Ubuntu users

sudo apt install \
  autoconf \
  bison \

react-boilerplate-1

#!/usr/bin/env osascript -l JavaScript
/**
* A JXA script to list all the fullscreen windows.
* Note: In macOS Mojave this method lists all the maximized windows as well.
* So we don't know which ones are fullscreen.
*/
ObjC.import('CoreGraphics');

react_component_lifecycle_example

cd ~
git clone [email protected]:vim/vim.git
cd vim
./configure --with-features=huge \
--disable-acl \
--disable-cscope \
--disable-netbeans \
--enable-gui=auto \
--enable-luainterp \

Stored format

Qty over Unit price
0 30
5 20
8 10

Display format

Quantity Unit price (each)