Category: programming

ExtJs – Bindable allowBlank

ExtJs does have a attribute for required by the allowBlank configuration against fields.

However, this configuration doesn’t have a setAllowBlank or a getAllowBlank method, because of which, it is not possible to bind those fields via the viewModel. So, usually, those fields have to be somehow fetched in the Controller and then that attribute.

This situation can however be remedied very easily.

Continue reading

ExtJs – Monthfield Picker

ExtJs, by default, doesn’t provide a month picker.

A monthfield picker allows you to choose specific months only.

The customization that was required, was to have a start date and an end date for those months, so that at the end of the operation, those specific dates could be saved.

Continue reading

error while running rake task – “Don’t know how to build task”

The default method to pass arguments to Rake tasks is to give the parameters in square brackets –

desc 'Method #1: Use the default rake way to add two numbers and log the result'
task :add, [:num1, :num] do |t, args|
  puts args[:num1].to_i + args[:num].to_i
end

Reference: 4 ways to pass arguments to a Rake task

$ rake add[1,2]
# => 3

However, I would rather pass the arguments like this –

$ rake add 1 2
# => 3
Continue reading

Simplest JavaScript & CSS minifier – YUI Compressor

I was looking for a simple JavaScript / CSS minifier. Essentially, a program which will

  1. minify – remove empty lines
  2. obfuscate – shorten variable names

There are many online tools available of course. Of the new ones, Parcel was the best. However, the resulting files had some extraneous code which I could do without.

Then I remembered about YUI Compressor, which I think is one of the first ones introduced many, many years ago.

Continue reading

SQLite load test for concurrent transactions using JMeter and JDBC Connection

I came across this article via a Hacker News post. This mentioned that SQLite was able to handle –

400 write transactions per second, and thousands of reads

I’ve recently started implementing applications with SQLite and with journal_mode set to WAL so that multiple concurrent writes could be done. However, I was curious to confirm the concurrent transactions number.

Earlier, I have used SQLite for development but usually on production we would face challenges with the notorious Database is locked error, we would move to Postgres or MySQL. However, I’ve always felt that for 90% of the applications we create don’t require these and was keen to back it up with numbers.

So, I decided to use Apache JMeter to try load testing a sample application.

Continue reading

VSCode terminal tab completion issue

I had logged into my server using VSCode the Remote-SSH extension, and had opened the terminal.

When I enter the ls command and tab, the files and directories auto-complete. However, when I give the mv command, tab completion fails.

After some googling, this Stackoverflow answer helped.

In my .bashrc file, I had to add the following lines –

# enable bash completion in interactive shells
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

ruby – difference between system, exec and backticks

There are multiple ways to run system commands from Ruby.

They are system, using backticks (‵), using %x(), using exec, or the more advanced option of using Open3. All of them behave in different ways.

system

The system method calls a system program. You have to provide the command as a string argument to this method. For example:

>> system("date")
Sat  4/10/2021   9:11:38
=> true

Note: In Windows, the date command also takes the input to change the system date after displaying the current system date. Press Enter to continue

The invoked program will use the current STDIN, STDOUT and STDERR objects of your Ruby program. In fact, the actual return value is either true, false or nil. In the example the date was printed through the IO object of STDIN. The method will return true if the process exited with a zero status, false if the process exited with a non-zero status and nil if the execution failed.

Continue reading

ruby strftime options

Every time I need to format ruby’s strftime options, I need to search for it on the internet. Putting them down here so that I don’t have to do that again!

Date Formatting 1

%YYear with century (e.g. 2015, 1995, etc)
%mMonth of the year, zero-padded (01..12)
%BThe full month name (e.g. January)
%bThe abbreviated month name (e.g. Jan)
%dDay of the month, zero-padded (01..31)
%jDay of the year (001..366)

Flags

Don’t pad a numerical output
_Use spaced for padding
0Use zeros for padding
^Upcase the result string
#Change case
:Use colons for %z
Continue reading

Copyright © 2024 the möbius trip

Theme by Anders NorenUp ↑