Tuesday, January 29, 2019

Rails - ActiveRecord related


Monday, January 28, 2019

Distributed Phoenix Chat using Redis PubSub

Elixir OTP Stock Quotes App (IEX Group)

Developing a Slack Bot in Elixir Phoenix

Whistle - a web framework based on Elixir

https://github.com/boudra/whistle

What problems does Whistle address?

Whistle is a web framework that works a bit differently than normal MVC web frameworks. It is composed of stateful long-running components, allowing you to create interactive applications entirely in Elixir via WebSockets, while being also able to render an HTML page like any other web framework.
It aims to provide a more functional approach to building web apps in Elixir, while also taking more advantage of Erlang's actor model.
It also provides an extensive Javascript API for when Elixir alone doesn't cut it and interop with existing front-end libraries like React is needed.

Avoid these OTP Supervision performance pitfalls

Processing Large CSV files with Elixir Streams

ecommerce - Elixir

Building a new MySQL adapter for Ecto - Plataformatec blog

Elixir Interview Questions

Sunday, January 6, 2019

With Rails UJS, how to submit a remote form from a function

tail + grep (multiple patterns)

https://stackoverflow.com/questions/23395665/tail-f-grep
https://unix.stackexchange.com/questions/37313/how-do-i-grep-for-multiple-patterns-with-pattern-having-a-pipe-character
https://stackoverflow.com/questions/7161821/how-to-grep-a-continuous-stream/7162898#7162898

Example: To grep for "Processing by" & "Parameters:" -
tail -f log/development.log | grep -E "Processing by|Parameters:"

Output:
2019-01-06 14:24:20.030 [INFO ] [30600:1788] Processing by Spree::ProductsController#index as JS

2019-01-06 14:24:20.031 [INFO ] [30600:1788]   Parameters: {"sort_scope"=>"default", "page"=>"12", "infiniteScroll"=>"true"}

Thursday, December 27, 2018

Linux: Prevent SSH timeout

https://bjornjohansen.no/ssh-timeout

In ~/.ssh/config add the following line:

     ServerAliveInterval 30

This will send a “null packet” every 30 seconds on your SSH connections to keep them alive.




Monday, December 17, 2018

ES6 - list of some of the new things

Some of the new things in ES6: 
destructuring, default parameter values, symbols, concise methods, computed properties, arrow functions, block scoping, promises, generators, iterators, modules, proxies, weakmaps, etc

Friday, December 14, 2018

Javascript - this, bind, call

// this , bind, call

var msg = "global";

function f(x){
  console.log(this.msg + "," + x);
}

var obj1 = {
  msg: "obj1",
  f: f
}

var obj2 = {
  msg: "obj2"
}

f(10);
obj1.f(10);
f.call(obj2, 10);

// f.call(window, 10);
// f.call(obj1, 10);
// f.call(obj2, 10);

// f.bind(obj1)(10)
// f.bind(obj2)(10)
// f.bind(window)(10)

Sunday, December 9, 2018

Config in Elixir projects

Excerpt from Elixir Cookbook -
The configuration from the imported files will override any existing configuration (with the same key) in the config.exs file. In fact, Configuration values are merged recursively. See the example at https://github.com/alco/mix-config-example.
To access configuration values, we use Application.get_env(:app, :key)

Friday, November 9, 2018

MySQL Slow Queries

SELECT * FROM `mysql`.slow_log ORDER BY query_time DESC;

Wednesday, November 7, 2018

Database related - Composite Indexes

How do composite indexes work - https://stackoverflow.com/questions/795031/how-do-composite-indexes-work


https://stackoverflow.com/a/795068

Composite indexes work just like regular indexes, except they have multi-values keys.
If you define an index on the fields (a,b,c) , the records are sorted first on a, then b, then c.
Example:
| A | B | C |
-------------
| 1 | 2 | 3 |
| 1 | 4 | 2 |
| 1 | 4 | 4 |
| 2 | 3 | 5 |
| 2 | 4 | 4 |
| 2 | 4 | 5 |
  • 12 Please note also that indexes are stored as Btree, so an (a,b,c) index will help on a search on (a) and on (a, b),
     but not on other searches like (b) or (b,c). – aexl Apr 30 '16 at 17:53




"MySQL can use multiple-column indexes for queries that test all the columns in the index, or queries that test just the first column, the first two columns, the first three columns, and so on. If you specify the columns in the right order in the index definition, a single composite index can speed up several kinds of queries on the same table." - Multiple-Column Indexes – AlikElzin-kilaka Sep 9 at 4:46


https://stackoverflow.com/questions/2349817/two-single-column-indexes-vs-one-two-column-index-in-mysql
https://stackoverflow.com/questions/179085/multiple-indexes-vs-multi-column-indexes?rq=1

Followers

Blog Archive