Saturday, April 28, 2018

Track

iOS - 10
https://docs.microsoft.com/en-gb/xamarin/ios/get-started/hello-ios-multiscreen/hello-ios-multiscreen-quickstart?tabs=vsmac

Ruby, RoR - 0.5

React -

Vue - 4
https://www.vuemastery.com/courses/intro-to-vue-js/vue-instance

Electron - 4
- have to check how notifications are shown (which are notifications and which are just toastr messages; where is notification manager?)
- faye code to show notifications?
- rules engine
- how to submit an Electron app to Windows Store & Mac App Store
  -- can we submit a sample app
- prevent session timeout so that user stays logged-in
--- if user stays logged-in, then things that happen at login time (like Login Interrupts) need to be triggered when user launches app
- can we write code to distinguish whether user is using browser or Electron app ?
- look at Google Analytics for different clients to see usage on Windows and MacOS
- on Macs we can show Notifications that stay on the screen; can we do the same on Windows? 

Monday, April 16, 2018

Mongodb related

1) Export
mongodump
Above command will export everything (all databases) into a folder called 'dump'

2) Import
mongorestore dump

Sunday, April 8, 2018

Rails: How to chain scope queries with OR instead of AND?

Internal Side Projects

I wrote the below comment in reddit.com/r/programming in response to a medium.com post about Hype Driven Development

There is a solution in my opinion: Internal-Side-Projects.

The only way, for a team to choose/decide in an informed manner, is to do some Internal-Side-Projects using the said framework/stack. Internal-side-projects = something non-critical but useful that everyone can work on, and should work on.

At the minimum, all senior-developers in the team/company should do be indulging in this. If we do this, when the time comes to make a decision, the team will actually have meaningful discussions. Sometimes decisions become obvious when people actually know what they are talking about. (The happy side-effect is that developers remain happy as they get to learn new things.)

However, for this to be practically possible, the company's culture should plan for & encourage such internal-side-projects.

This is absolutely essential for a company/team to remain competitive in the long-run.

Saturday, March 24, 2018

Rails: Full-Text Search related

Pg_Search & SearchKick are gems 

Pg_Search vs SearchKick
https://www.webascender.com/blog/rails-search-gems-searchkick-vs-pg_search/

Pg_Search

One of the best features of Postgres is the built-in, full-text search capabilities. The pg_search gem helps maximize these capabilities by providing a powerful, yet simple, search capability. pg_search is great for a basic search that will search multiple models, associations, and is able to hook into advanced Postgres features in the optional contrib package. This contrib package allows fuzzy and trigram searching.

ElasticSearch & SearchKick in Depth
https://www.webascender.com/blog/rails-elasticsearch-searchkick-depth/

SearchKick:
Github: https://github.com/ankane/searchkick
GoRails video: https://gorails.com/episodes/elasticsearch-with-searckick
DriftingRuby video: https://www.driftingruby.com/episodes/searchkick-and-elasticsearch

Other videos related to Search:
- Ruby on Rails - Railscasts #278 Search With Sunspot - https://www.youtube.com/watch?v=6ub9OYNvHZk
- Ruby on Rails - Railscasts PRO #343 Full-Text Search in PostgreSQL (pro) - https://www.youtube.com/watch?v=n41F29Qln5E
- RailsConf 2016 - Multi-table Full Text Search with Postgres By Caleb Thompson - https://www.youtube.com/watch?v=OzHhJPlgZaw


Rails: Best practices for running Rails in production

ActiveRecord related: marginalia gem - for adding comments to ActiveRecord queries

https://signalvnoise.com/posts/3130-tech-note-mysql-query-comments-in-rails
From https://github.com/basecamp/marginalia:
Attach comments to your ActiveRecord queries. By default, it adds the application, controller, and action names as a comment at the end of each query.
This helps when searching log files for queries, and seeing where slow queries came from.
For example, once enabled, your logs will look like:
Account Load (0.3ms)  SELECT `accounts`.* FROM `accounts` 
WHERE `accounts`.`queenbee_id` = 1234567890 
LIMIT 1 
/*application:BCX,controller:project_imports,action:show*/
You can also use these query comments along with a tool like pt-query-digest to automate identification of controllers and actions that are hotspots for slow queries.
......
.......
Marginalia ships with :application, :controller, and :action enabled by default. In addition, implementation is provided for:
  • :line (for file and line number calling query). :line supports a configuration by setting a regexp in Marginalia::Comment.lines_to_ignore to exclude parts of the stacktrace from inclusion in the line comment.
  • :controller_with_namespace to include the full classname (including namespace) of the controller.
  • :job to include the classname of the ActiveJob being performed.
  • :hostname to include Socket.gethostname.
  • :pid to include current process id.

Sunday, February 25, 2018

Turbolinks related: InstantClick

InstantClick library -
http://instantclick.io/click-test 

Discussion in Turbolinks related to idea established in InstantClick library:
Prefetch Loading - https://github.com/turbolinks/turbolinks/issues/84
turbolinks "instantclick" - https://github.com/turbolinks/turbolinks/issues/313 

Barba.js - barba.js is a small (4.4kb minified and gzipped), flexible and dependency free library that helps you creating fluid and smooth transitions between your website's pages.
http://barbajs.org/index.html
https://www.smashingmagazine.com/2016/07/improving-user-flow-through-page-transitions/

Other related links:
https://news.ycombinator.com/item?id=12481969
https://github.com/Easyfood/pageAccelerator

https://caniuse.com/#feat=link-rel-preload
https://css-tricks.com/prefetching-preloading-prebrowsing/ 

Sunday, February 4, 2018

Ruby Metaprogramming related

Instance Methods, Class Methods, Singleton Methods.......
https://stackoverflow.com/questions/212407/what-exactly-is-the-singleton-class-in-ruby

Great video on Ruby Metaprogramming - multiple viewings essential
https://youtu.be/7D9wwPniszY

Saturday, February 3, 2018

Difference between Couchbase & Mongo

 https://blog.couchbase.com/data-modeling-nosql-documents-mongodb-vs-couchbase-server/
The referred documents in Couchbase can be joined in a single server side operation through N1QL rather than forcing the application layer to take care of it.
 ......
.......

The core differences come in regards to how you query the documents. It is much easier to query for data in Couchbase through N1QL and the other query strategies, regardless how you’ve chosen to model your documents.
If you’re interested in seeing a modeling and querying video I recorded, check it out here.


Monday, January 15, 2018

Sunday, October 22, 2017

headless-chrome - getting started in ruby

headless-chrome

- Install Chrome 59 or later from google.com/chrome

- download chromedriver and put in a new folder called 'chromedriver'; so the path to the binary is similar to - /home/sai/chromedriver/chromedriver

- now we have to add the above binary's path to PATH 
-- Open the below file in nano editor
nano ~/.bash_profile
-- add the below line
PATH=$PATH:/home/sai/chromedriver export PATH

- gem install selenium-webdriver

- gem install chromedriver-helper

- Now we can start executing the scripts found in -  https://readysteadycode.com/howto-scrape-websites-with-ruby-and-headless-chrome

Wednesday, September 27, 2017

Git related: DeepGit - tool to investigate the history of source code

https://www.syntevo.com/deepgit/

DeepGit is a tool to investigate the history of source code. It is based on git blame and makes it easy to trace changes to a line or block of code. DeepGit will detect code movements, even if lines are not identical.

Thursday, September 7, 2017

Rails debugging related

Use sth similar to below alongwith binding.pry

caller.select{|c| c.include? "rails-project-folder-name"}

This will give the list of callers (methods) that are your code.


Wednesday, August 30, 2017

Try Ruby in the browser

The software engineering rule of 3

https://erikbern.com/amp/2017/08/29/the-software-engineering-rule-of-3.html

Excerpts:
 first rule of 3. Don’t worry so much about code duplication if you only have two classes or two functions or whatever. When you see a pattern in three different places, it’s worth thinking about how to factor it out.
...
...
 second rule of 3 — you’re not going to get the system design right until the third time you build it. 

Sunday, August 27, 2017

Kibana related: Searching in Kibana

https://lucene.apache.org/core/2_9_4/queryparsersyntax.html

Search for 2 strings using AND operator:
"15-0001" AND "10-0005"

Choosing a frontend JS framework

https://medium.com/front-end-hacking/how-it-feels-to-learn-javascript-in-2017-a934b801fbe

Excerpt:
Interesting. Which one should I use? The big ones are React, Angular and Ember, right?
-They’re all good. If you want to write your front-end logic in Handlebars use Ember. If you want to write your front-end logic with HTML attributes use Angular or Vue. If you want to write your front-end logic with JavaScript use React, Mithril or Inferno.

Tuesday, July 25, 2017

redbus move to .Net Core & their blog

imba.io

Imba is a new programming language for the web that compiles to highly performant and readable JavaScript. It has language level support for defining, extending, subclassing, instantiating and rendering dom nodes. For a simple application like TodoMVC, it is more than 10 times faster than React with less code, and a much smaller library.


Saturday, July 22, 2017

Blockchain related: A hacker stole $31M of Ether—how it happened and what it means for Ethereum

Advice from Claude Shannon

10,000 Hours With Claude Shannon: How A Genius Thinks, Works, and Lives:
https://medium.com/the-mission/10-000-hours-with-claude-shannon-12-lessons-on-life-and-learning-from-a-genius-e8b9297bee8f

Excerpts from the above article:

1) Cull your inputs.
2) Big picture first. Details later.
3) Don’t just find a mentor. Allow yourself to be mentored.
4) You don’t have to ship everything you make.
Vannevar Bush left his imprint on Shannon in another way: he defended the value of generalizing over specializing. As he told a group of MIT professors:
“In these days, when there is a tendency to specialize so closely, it is well for us to be reminded that the possibilities of being at once broad and deep did not pass with Leonardo da Vinci or even Benjamin Franklin. Men of our profession — we teachers — are bound to be impressed with the tendency of youths of strikingly capable minds to become interested in one small corner of science and uninterested in the rest of the world. . . . It is unfortunate when a brilliant and creative mind insists upon living in a modern monastic cell.”
Bush encouraged Shannon to avoid cells of all kinds
5) Chaos is okay.
6) Time is the soil in which great ideas grow.
7) Consider the the content of your friendships.
8) Put money in its place.
9) Fancy is easy. Simple is hard.
“Almost every problem that you come across is befuddled with all kinds of extraneous data of one sort or another,” Shannon said, “and if you can bring this problem down into the main issues, you can see more clearly what you’re trying to do.”
10) The less marketing you need, the better your idea or product probably is.
11) Value freedom over status.
12) Don’t look for inspiration. Look for irritation.
Shannon’s most evocative formulation of that elusive quality put it like this: it was “a slight irritation when things don’t look quite right,” or a “constructive dissatisfaction.” In the end, Shannon’s account of genius was a refreshingly unsentimental one: A genius is simply someone who is usefully irritated. 
 

Wednesday, July 19, 2017

http client - Requester


Steps for developing a React app from scratch

Excerpt from the book FullStack React (Chapter 2 - Components)

In fact, this follows from a handy framework for developing a React app from scratch:
1. Break the app into components
2. Build a static version of the app  
3. Determine what should be stateful
4. Determine in which component each piece of state should live
5. Hard-code initial states
6. Add inverse data flow
7. Add server communication

Chrome Dev Tools related

Sunday, July 9, 2017

Jonathan Blow talk - shares some hard-earned wisdom about programming & projects



His talk is about 38 minutes long.

Alexander Pope: A little learning is a dangerous thing

From http://norvig.com/21-days.html
Above link is already part of a previous blogpost, but the below quote is worth a new blogpost by itself.
As Alexander Pope said, a little learning is a dangerous thing.

Peter Norving: Teach Yourself Programming in Ten Years

Peter Norvig is a director of research at Google Inc.

He wrote way back in 2001 - Teach Yourself Programming in Ten Years -
http://norvig.com/21-days.html

Peter Norvig: Being good at programming competitions correlates negatively with being good on the job

Peter Norvig is a director of research at Google Inc.

http://www.catonmat.net/blog/programming-competitions-work-performance/
"Being good at programming competitions correlates negatively with being good on the job"


Broad generalizations will not stand up in a court of law, but they do point towards things to ponder.

My takeaway from the above video - Trying to get things done quickly, all the time, can be a Negative thing.

Thursday, June 29, 2017

Java EE -- The Competitive Advantage For Startups


From Adam Bien's blog:
"At the infoshare.pl 2017 conference in Gdansk I got 30 minutes time to explain why Java EE is happily used by startups with live hacking. Deployment to Amazon Cloud (AWS) included:"
Java EE -- The Competitive Advantage For Startups
http://adambien.blog/roller/abien/entry/java_ee_the_competitive_advantage

Friday, June 16, 2017

Instagram Makes a Smooth Move to Python 3

https://thenewstack.io/instagram-makes-smooth-move-python-3
By all reports, things went really smoothly — how did the team make it happen so seamlessly?
Guo: An important factor was, if you look at how we were migrating, we would constantly check in small changes into the master branch, so we were never merging major diffs. Getting the most bugs fixed, with a smaller audience iterating in small steps: that was the key approach to maintaining stability while still moving quickly.

Wednesday, June 14, 2017

Hard work

A reminder of how hard one should be working.. in any field..

https://www.reddit.com/r/movies/comments/67qzrx/hello_reddit_i_am_actor_and_artist_val_kilmer_i/
CatchMeKillMe 243 points244 points  (23 children)
Val, any advice for someone attempting to break into the business?
[–]OfficialValKilmerVal Kilmer[S] 1413 points1414 points  (22 children)
work till you cry yourself to sleep every night for months on end. work so hard you pass out and wake up crying. become a world class athlete. Read Shakespeare every day to learn about human nature. EVERY DAY. FOR DECADES. never ever ever ever ever take a day off. And never complain. Its the best job on earth and worth it when you break thru. Dustin Hoffman they say couldn't act his way out of a paper bag, and I knew Kevin Spacey since he was like 15 and he was sooooooooooo bad it used to hurt my eyes. But boy did he work hard and deserves all his awards.

Saturday, June 10, 2017

A Dive into Ruby’s Rack

Thought 4: 2 step Code Review - 1) Solution Review 2) Final Code Review

As a software developer, we are expected to tackle problems of all sizes - minor bug-fixes to developing new features, i.e. we are expected to come up with Solutions and then write Code for them.

It is important to note that this is a 2 step process -
1) come up with a Solution
2) write code

Code Reviews have become an established step in software development, but they cover mostly the 2nd step. Reviewers usually find it very difficult to suggest wholesale changes like suggesting a different solution because of the risk of coming across as a 'bad guy'.

There is no concept of a Review for the 1st step i.e. no Solution Review at present.

It is assumed that a developer will come up with the correct Solution. Herein lies the problem.

First and foremost, most problems, even minor ones, have Multiple Solutions, and the Developer has to choose the best amongst them. Sometimes the Developer working on the problem might not be aware of other Solutions.

Hence I believe that a Solution Review will help with non-trivial bug-fixes/features. The greater the impact of a problem/solution, the more number of senior people that have to review the solution.

Solution Reviews can probably take place in either of the following 2 ways:

1) via Discussions
  • a developer discusses with one or more team-members and/or team-lead, his/her solution to a given problem
  • effort is made to arrive at a consensus amongst max people in the team as possible
  • if Jira or another project-management tool is being used, a simple Comment is added that says that 'ABC has reviewed the solution'.
OR
2) via a 2 step Code Review process
  • these days Code Reviews happen via pull-requests similar to those used when using GitHub 
  • 1st step: "Initial/Solution Review" - When a Pull Request is submitted, it can be labelled as "Initial/Solution Review"
    • Such a label can serve as an indicator that the pull-request is in the 1st stage of Review
    • This sets the expectation to everyone, i.e. the Developer as well as the Reviewers, that the solution that has been implemented, is up for debate
      • traditional code-reviews can be painful when the Developer and the Reviewer have different expectations of the Code Review's outcome, so this setting of expectation, is very important
    • More people are likely to review/discuss when there is less chance of hurting the confidence of the Developer
  • 2nd step: "Final Code Review" - After 'Initial Review' has taken place, the Developer submits a pull-request again that is labelled with "Final Code Review"
  • Note that both the steps of the 2 step process have to be Mandatory - Otherwise, as time goes by, it could morph/devolve into a single-step traditional Code Review process.

Note: Both of the above solutions can be used together too.

Thought 3: Defining characteristic of a team - how they discuss

Note 1: I wrote the below from the perspective of a team of software developers, but a team could also be a couple, or a family, or a group of friends, actually any group that has to make decisions on a regular basis.


In my opinion - A Team is Defined by HOW they Discuss.

I am not saying that, in order to be considered a 'good team', a team has to discuss a lot. How they discuss, whatever they discuss, and how decisions are made is what is important.

In general, today, there is a lot of emphasis on Productivity - a measurement of work done by a team.

In general, there has been a backlash against having too-many-Meetings.

In a continuous quest for Productivity, sometimes teams may sacrifice/forgo Discussions that actually need to happen. This can happen when there is a feeling that Discussions do not qualify as Work.

I have the opposite opinion. Discussions are needed to arrive at Solutions.

Discussions/Brainstorming/Solution-Reviews help in the following ways:
  • prevents the dreaded-feeling-of-exclusion - give everyone the opportunity to propose/debate/just-listen-to solutions Before a decision is made
    • when decisions are made without a discussion, a lot of times, people get angry/discouraged Not by the decision itself that has been taken, but by the fact that they were not considered important enough to be a part of that discussion (even as listeners).
  • prevent Blunders
    • when more than one person is involved in arriving at a Solution, the chances of making Blunders reduces
    • this increases developer's confidence & happiness
  • keeps everyone in the loop i.e. share information with everyone
    • On a daily basis, people work on code that others wrote, so sharing of information is very important
  • lets everyone know that they can influence decision-making, and in fact are expected to do so
  • levels the playing-field
    • gives the chance for talent/knowledge to come out
    • junior devs can debate with senior devs or the lead and get their solution accepted if it is the better one
A related problem is - a team has to decide how Information would flow within it:
- whether it will Pushed to everyone
OR
- if it will have to Pulled by each team-member.

Teams that have discussions involving everyone on a regular basis, would be following the Push strategy and I feel that, that is a better model to keep everyone motivated which is very important to achieve success as a team.

Note 2: Related: There is general consensus about the importance of 'etiquette of discussion' - http://www.exforsys.com/career-center/group-discussions/group-discussion-etiquette.html

Thought 2: Why software developers tend to move frequently between companies

Suppose that there is work to be done always.

Some developers are continuously working to get those things done. There are some developers who get some of those things done, and then spend some time learning - new stuff or old stuff.

There is no clear demarcation about when to do each of them - working & learning. From what I know, most companies, if not all, expect people to learn on their own time. Below I am going to try to explain why this is ultimately not beneficial to a company.

When there is always work to be done, it falls on the judgement of each developer to take the call on when to do work and when to learn.

Like everything, when something is left to the judgment of each individual, you will find that different individuals take vastly different decisions (as to when to work and when to learn).

Sometimes, the decision is taken out of their hands too. This happens when there is a lot of work always, which is mostly the case with software companies.

The logical conclusion to the above line of thinking would be - if left to their own judgement, in an environment where there is always work of some kind or the other to be done, developers will tend to just keep working all the time and will tend to postpone learning, waiting for the time when the workload would become less, which almost never happens.

Can we attribute fault to the people who do the above?

In a corporate world, the answer would be Yes.
In the engineering world, where a team is working for years together on building/maintaining one single product, I feel the answer is more complicated.
Irrespective of who is to blame, in a product-company, it is in the best-interests of the company to not allow the above to happen (as I will describe below).

If developers work in a company in the above fashion, then after a few years, the following will happen:
  • developers get bored with the work i.e. motivation starts to decrease
  • developers start to feel insecure if the skills that they are using daily are not what are in demand anymore (outside the company), and new skills are being sought after in the market
    • the software industry is an extremely fast-changing industry and today's-in-demand-skills go out-of-demand in a few years time
  • there is increased pressure to be successful in the current company due to the above insecurity; and this increased pressure tends to manifest itself in negative ways - people losing their cool with each other over minor things, office-politics, etc.
I think above are the reasons why most developers don't stay at any given company for more than a few years.

When people leave, they take with them a wealth of knowledge - informal training received over word-of-mouth, experience specific to company's problems, history of decisions made to get the product to where it is, etc, and not to mention, cause a loss in morale of the remaining team-members.

So what if people leave? Can't we hire new ones?

In the corporate world, I have heard this statement multiple times - "no one...no one is irreplaceable". That is how it is structured.
However in the engineering world, I feel there are 2 categories:
- A few brilliant Lead engineers form the backbone of the entire company. Such people are considered irreplaceable and that is straight-forward logic.
- the Rest

What about 'the Rest' ? Are they replaceable or not?

In my opinion, the ideal team is a set of brilliant Lead engineers who are supported by an ever-improving team of senior/mid-level/junior engineers. If there is churn within the team of senior/mid-level/junior engineers, the Lead engineers will have to take the time to train the new hires, and you can tell that if it happens a lot, it is not good.

In the above sense, every team-member is important.

So my opinion is - a small product-company, should not have its hiring/retaining policy built similar to a corporate-company. People do leave due to one reason or another, but the core policy should be to try super-hard to retain everyone it hires and trains.

Super-hard? How?

As outlined in a different post (http://psjp-learn.blogspot.in/2017/06/building-machine-that-makes-machine.html), I think, unless a company considers that continuous-training of each developer is an integral part of its philosophy (and somehow incorporates continuous-training in its software-engineering-process), the above negative phenomenon cannot be stopped.  

Note: Above, I have not mentioned the monetary aspect, which I do think, plays a huge role in a person's decision whether to stay or move. But I think as developers tend to become more senior (in experience and age), their salaries tend to stabilize, people start to have a family of their own, and the family's needs get tied to a location and a routine, and hence this factor almost ceases to have any impact many times.

Friday, June 9, 2017

Thought 1: Training Software Teams - Building the machine that makes the machine


Elon Musk at an annual meeting:
The most important point I want to make is [that] the true problem, the true difficulty, and where the greatest potential lies is building the machine that makes the machine. In other words, building the factory … like a product,” said Musk at the annual meeting (starting at 2:20), predicting a new factory would deliver a “ten-fold improvement” in productivity.
As a software developer, I felt that we can discuss, in the same way, about software-teams that are building software-products.

A Software-Team can be thought of as the 'machine that makes the machine', and itself should be treated as a 'product'.

If the software-team is the machine that makes the machine, then how should a company take care of it?

When you talk about a Machine, the aspects of Maintaining it, Making it Better, come into the picture.

What steps can a company take towards a software-team to 'Maintain it & Make it Better' ?
One step a company can take is taking the responsibility of Continuous Training.

How is this different from current thinking?

Current thinking seems to be:
  • Hiring the right people = Building the machine that makes the machine
  • Continuous Training is the responsibility of the Software Engineer and not the company
However, with the new perspective of a software-team itself being a 'product' and being a 'machine that makes the machine', it is very clear to us that hiring good people is only half the job. Maintenance is the other half, and it is in the best interests of a company to take care of Maintenance too.

My personal opinion is that a lot of software developers move between companies at a frequent rate due to situations/problems/environments that arise as side-effects of lack of this Maintenance.

Current processes like Scrum are all about Project Management. But Project Management is just one aspect of Software Engineering. Perhaps something similar to Scrum has to come along to take care of the importance of Continuous Training.


Blockchain explained nicely

A very basic visual introduction to the concepts behind a blockchain.
Introduces the idea of an immutable ledger using an interactive web demo.
If you are interested in playing with this on your own, it is available online at:
https://anders.com/blockchain/

The code that runs this demo is also on GitHub: https://github.com/anders94/blockchain-demo

Sunday, June 4, 2017

Markojs

Elixir related: GenStage and Flow - José Valim (Lambda Days 2017)

GenStage and Flow - José Valim (Lambda Days 2017)  

José will explore the rationale and design decisions behind GenStage and Flow, two abstractions that have been researched and now implemented in the Elixir programming with a focus on back-pressure, concurrency and data processing.

Friday, June 2, 2017

Electron related: Electrino

https://medium.com/dailyjs/put-your-electron-app-on-a-diet-with-electrino-c7ffdf1d6297

Excerpt:
For small apps, there would be another way. Instead of bundling the web runtime with each app, they could use the system-provided web runtime instead. Both macOS and Windows contain a competent modern browser engine (WebKit on Mac, Edge on Windows). This engine is typically already loaded in memory. By using the system-provided runtime, Electron-style apps could become much slimmer both in terms of on-disk footprint and RAM usage.
I’ve just released the first version of a runtime named Electrino which does exactly this.

Ruby related

Followers

Blog Archive