Skip to content

Instantly share code, notes, and snippets.

View chanakasan's full-sized avatar

Chanaka Abeysinghe chanakasan

View GitHub Profile
@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 git@github.com: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)
@chanakasan
chanakasan / angular-jqueryui-dnd.html
Created April 1, 2016 13:17 — forked from codef0rmer/angular-jqueryui-dnd.html
AngularJS + jQueryUI Drag & Drop
<!DOCTYPE html>
<html ng-app="App">
<head>
<meta name="description" content="AngularJS + jQuery UI Drag-n-Drop" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.0.1/angular.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<meta charset=utf-8 />
@chanakasan
chanakasan / tasks_controller_refactoring.rb
Created February 5, 2016 05:04 — forked from ryanb/tasks_controller_refactoring.rb
Variation of RubyTapas episode "021 Domain Model Events" without using callbacks
class TasksController < ApplicationController
def update
tracker = TaskTracker.new(@task)
if @task.update_attributes(params[:task])
TaskPusher.new(tracker, socket_id).push_changes
TaskMailSender.new(tracker, current_user).deliver_email
# success response
else
# failure respond
end