Skip to content

Instantly share code, notes, and snippets.

View arkadiyk's full-sized avatar

arkadiy kraportov arkadiyk

  • CLSA
  • Tokyo, Japan
View GitHub Profile
@arkadiyk
arkadiyk / rich_text_component_for_surfaceui_phoenix_liveview.md
Last active April 18, 2023 07:19
Super simple Rich Text Editor SurfaceUI Component ( Elixir / Phoenix / LiveView )

Super simple Rich Text Editor SurfaceUI Component ( Elixir / Phoenix / LiveView )

I have created a library based on the below snippets: https://github.com/arkadiyk/surface_rich_components

Component

defmodule Components.TextEditor do
  use Surface.Component
@arkadiyk
arkadiyk / readme.md
Last active January 15, 2020 02:00
Compiled EmberJS in Docker

Compiled EmberJS App in Docker

The biggest problem deploying compiled EmberJS apps as a container is the configuration defined during compile time and becomes part of the image. Which is not ideal as you probably want to move the image between QA/UAT and prod without any modification.

The solution I will describe here looks like a hack but it's been working for me.

  1. I put config <meta> tag into index.html:
@arkadiyk
arkadiyk / Simple-I18n-for-Ember-app.md
Last active November 17, 2021 05:45
Quick'n'dirty i18n for Ember application. Allows to switch locales dynamically. Uses `i18n-js` library. Adds handlebars `t` helper and also attribute bindings `placeholderTranslation` to text input views and `promptTranslation` to select view.

Examples:

Literals:

{{t 'user.last_name'}}
{{t 'user.email' count=1}}

Placeholders:

@arkadiyk
arkadiyk / aprray-filter-vs-computed-filter.md
Last active January 2, 2016 13:29
Interesting observation on difference between `array.filterBy` and `Ember.Computed.filterBy`

Apparently array.filterBy creates a new array based on the filtered content, whether Ember.Computed.filterBy reuses the same array.

This difference can be very important when you display a filtered list with {{each}} helper.

For eaxample, if you define the propery like this:

  filteredArray: function(){
    return this.get('content').filterBy('isDone', false);
  }.property('content.@each.isDone')
@arkadiyk
arkadiyk / PoiWriteExcelFile.java
Created May 23, 2012 09:25
How do I write to an Excel file using JRuby and POI?
// source: http://www.avajava.com/tutorials/lessons/how-do-i-write-to-an-excel-file-using-poi.html
package test;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import org.apache.poi.hssf.usermodel.HSSFCell;
@arkadiyk
arkadiyk / sso_auth.rb
Created March 8, 2012 09:21
Pure Ruby OpenSSO client
require 'net/http'
require 'uri'
module SSOAuth
def opensso_location
'http://<SSO-SERVER.com>:8080/opensso'
end
# main method
def get_sso_user
@arkadiyk
arkadiyk / excel_controller.rb
Created February 29, 2012 12:45
Parse Excel with JRuby and POI
require "java"
class ExcelController < ApplicationController
# Controller method
def parse_uploaded_file
excel_file = params[:excel_file] # file input element
begin
parsed_data = parse_excel(excel_file[0].read)
render :json => {:result => "OK"}
@arkadiyk
arkadiyk / tibco.rb
Created January 19, 2012 04:09
Call tibco EMS from JRuby
include Java
require "#{ENV['TIB_LIBS']}/wljmsclient.jar"
require "#{ENV['TIB_LIBS']}/wlclient.jar"
require "#{ENV['TIB_LIBS']}/tibjms.jar"
PROVIDER_URL = 'tcp://JEUP-EQ-A.aaaaaa.com:42669,tcp://JEUP-EQ-B.aaaaaa.com:42669'
class MetreosJmsHandler
import java.util.Hashtable
@arkadiyk
arkadiyk / excel_dumper.rb
Created September 30, 2011 01:15
Export data to Excel. Nicely formatted, with correct datatypes, text wrap for long fields.
class ExcelDumper
def initialize(array)
@data = array
end
def to_xls(options = {})
output = %{<?xml version="1.0" encoding="UTF-8"?>
<Workbook xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40"