04 December 2022

Why is web programming looked down amongst programmers?

 Why is web programming looked down amongst programmers?

 

Web programming is awful. Hear me out:

  • You’re usually forced to code in multiple languages
  • Many of those languages have serious flaws and limitations
  • The sands are constantly shifting as browsers, libraries, etc. change, often without discernible improvement
  • Mysterious problems caused by near-invisible factors, sometimes outside your control, are frequent (e.g. strange proxy behaviour; caches)
  • Very basic things arrive late and broken (I remember web developer friends’ excitement about finally getting sockets and a canvas to paint on)

When I meet a developer who likes web development, I assume that’s the only kind of development they do and they’re probably inexperienced. This could be my prejudice, of course; maybe client-side web development is better these days (I wouldn’t know; I’ve been avoiding it for years).

Web development is also a bit like Visual Basic programming in the 90s in that the bar to entry is very low (it’s easy to build something), but the standard of developer required to produce a really good result is extremely high (it’s very difficult to build something good). As a result, there’s an awful lot of really terrible code out there, written and maintained by developers who have no idea what good software design looks like. Software built for the web is not often built for a long life, and there’s a worryingly high tolerance for:

  • Poor user experience (making things look great rather than making them work well)
  • Poor stability (just hit refresh; don’t use the back button; clear your cache and try again)
  • Poor performance (I swear, some web developers have no idea what ‘fast’ really means on a modern computer, and never test on a machine over 5 years old)
  • High resource consumption (never mind, it’s just the client machine’s resources being wasted)
  • Very poor maintainability (we’ll build a whole new one before we make significant changes to this one anyway)

I try not to look down on anyone though. Anyone can learn any kind of development, and getting tribal about technologies and disrespecting people who like things we don’t isn’t productive.

03 December 2022

Advantages of map function in Python

 Does Python still need the map() function?

 

In the following situation, i.e. working with multiple itarables (lists, etc.), using map function may be the best approach. It is both the most readable and the most efficient.

 ...

Above, we applied map() for a single iterable, but we can use as many of them. The function will use them based on their index, that is, first, it will call the callable for the first elements of the iterables (at index 0); then for the second; and so on.

A simple example for this:

>>> def sum_of_squares(x, y, z):
... return x**2 + y**2 + z**2
>>> x = range(5)
>>> y = [1, 1, 1, 2, 2]
>>> z = (10, 10, 5, 5, 5)
>>> SoS = map(sum_of_squares, x, y, z)
>>> list(SoS)
[101, 102, 30, 38, 45]
>>> list(map(sum_of_squares, x, x, x))
[0, 3, 12, 27, 48]
...

26 November 2022

If a software developer didn't meet the deadline, how should a good manager respond?

https://www.quora.com/

If a software developer didn't meet the deadline, how should a good manager respond? Is pushing developers to work for long hours the right thing to do?

Originally Answered: If a software developer didn't meet the deadline how should a good manager respond? Does pushing developer to work For long hours a right thing to do?

There are some managers who like to put schedule risk off onto the dev team. If the team gets behind, make them work more hours until they catch up. This practice is E.V.I.L. It is like if your director asked you, as manager, to pay the company back from your own paycheck if your team goes over budget. The budget is the same kind of prediction of the future as a software schedule is. And as manager you are just as responsible.

Estimating schedules is hard, because it is predicting the future. There is a school of thought that this practice is so hard that teams ought to refuse to do it.

How should you handle a developer who is not good at predicting the future? Should you punish them by making them work more hours? Or should you get them a better crystal ball in the form of some kind of class on scheduling?

If you have a developer who is wasting time, always has facebook open, spends all afternoon yakking with the other devs, takes extended smoking breaks, etc., you should definitely push them to work harder. (I mean, duh.) If your developers are at their desks doing the job of developing software, punishing them for being late is both cruel and counterproductive.

05 October 2022

My vim plugin bible - How to Make Vim a Python IDE - Best IDE for Python.

https://dev.to/shahinsha/how-to-make-vim-a-python-ide-best-ide-for-python-23e1

 

I revised it a little bit as -


set nocompatible              " required
filetype off                  " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'

" All Plugins

Plugin 'mhartington/oceanic-next'
Plugin 'tmhedberg/SimpylFold'      "<space>
Plugin 'vim-scripts/indentpython.vim'
Plugin 'vim-syntastic/syntastic'
" Plugin 'nvie/vim-flake8' (pip3 install flake8) <F7>
Plugin 'scrooloose/nerdtree'       ":nerd
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'kien/ctrlp.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'zxqfl/tabnine-vim'
Plugin 'frazrepo/vim-rainbow'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'davidhalter/jedi-vim'       "Auto complete. Ctrl+<space>
Plugin 'ycm-core/YouCompleteMe'     "Automatic, or Ctrl-n


call vundle#end()            " required
filetype plugin indent on    " required


" setting horizontal and vertical splits
set splitbelow
set splitright

"split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

" Enable folding
set foldmethod=indent
set foldlevel=99

" Enable folding with the spacebar
" nnoremap <space> za


" Setting up indendation

au BufNewFile, BufRead *.py
    \ set tabstop=4 |
    \ set softtabstop=4 |
    \ set shiftwidth=4 |
    \ set textwidth=79 |
    \ set expandtab |
    \ set autoindent |
    \ set fileformat=unix

au BufNewFile, BufRead *.js, *.html, *.css
    \ set tabstop=2 |
    \ set softtabstop=2 |
    \ set shiftwidth=2

highlight BadWhitespace ctermbg=red guibg=darkred
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/

let g:ycm_autoclose_preview_window_after_completion=1
map <leader>g  :YcmCompleter GoToDefinitionElseDeclaration<CR>

" setting up pyflakes

let python_highlight_all=1
syntax on

" nerd tree settings
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
nnoremap <leader>nerd :NERDTreeToggle      "by Sherman Chen

" setting up line numbering
set nu

" not break a word when newline
:set linebreak

" Max. row length 78
:set textwidth=78

" Rainbow bracket settings
let g:rainbow_active = 1

Vim plugin manager - Vim Pathogen

 I'd highly recommend installing vim pathogen if you want to see the universe of vim plugins.  

It's a package manager of sorts. Once you install it, you can git clone packages to your ~/.vim/bundle directory and they're auto-installed. No more plugin installation, maintenance, or uninstall headaches! 

 You can run the following script from the GitHub page to install pathogen:  

mkdir -p ~/.vim/autoload ~/.vim/bundle; \ 
curl -so ~/.vim/autoload/pathogen.vim \     
    https://raw.github.com/tpope/vim-pathogen/HEAD/autoload/pathogen.vim

01 October 2022

speedtest error on ubuntu terminal

When I ran 

$ speedtest

I got 

Retrieving speedtest.net configuration...
Cannot retrieve speedtest configuration
ERROR: HTTP Error 403: Forbidden

Solution:


Hi, @fixit7 .

I've never ran speedtest-cli but, after a web search, I've found the following Reddit post (in the subreddit "r/Linux4noobs 10") that was posted 23 days ago:

In that Reddit post, the original poster ("u/CryPTuuNe 3") wrote the following:

"(...) I just setup Ubuntu on my new PC. For testing purposes I installed the speedtest-cli and with the command Speedtest everything worked fine. I don't know what I did then, but now I am getting an http error 403 forbidden. But when doing speedtest --secure everything works fine again. (...)"

According to the "speedtest-cli" manpage - Ubuntu Manpage: speedtest-cli - Command line interface for testing internet bandwidth using speedtest.net 81 - the "--secure" switch has the following meaning:

--secure
Use HTTPS instead of HTTP when communicating with speedtest.net 28 operated servers

I hope this helps.

18 August 2022

15 July 2022

How to measure Internet speed on Ubuntu?

Using pip install --user speedtest-cli gets you a version that is probably newer than the one available from your distribution's repositories.

10 July 2022

How to limit width of table to within screen width with html and css?

How to limit width of a wide table to within screen width with html and css?

Solution: Do the following 2 things

1. <table style='table-layout: fixed'>

2. Set width for every columns in the first row (you can leave the last column, or any one column of all)

<thead>
  <tr>
    <th style='width: 5%; >blah...</th>
    <th style='width: 10%; >blah...</th>
    <th style='width: 25%; >blah...</th>
    <th style='width: 25%; >blah...</th>
    <th>blah...</th>
  </tr>
</thead>

That is all.

05 July 2022

How to give author, editor, viewer permissions to room calendars?

On exchange server 2010, Exchange Management Console, mailbox > 'new mailbox' > 'room mailbox' > 'new user' 

On active directory, you will see the new room mailbox, disabled. Enable it. Create a password.


On EMC, 'distribution group' > 'new distribution group', create groups to be given (author, edit, review) permission to the new room mailbox.

Add users to each distribution group.

Log on any computer with the new room user. Open MS Outlook > new room mailbox calendar, grant each group permission to the new room mailbox calendar. (After a user is migrated to Office 365, we then can not add remote user to room calendars)

Sharing Office 365 Room's availability to external users

https://techcommunity.microsoft.com/t5/outlook-blog/sharing-office-365-room-s-availability-to-external-users/ba-p/178054

18 June 2022

pandas - how to group by multiple columns and get sums of multiple other columns

https://stackoverflow.com/questions/46431243/pandas-dataframe-groupby-how-to-get-sum-of-multiple-columns


Question:

I have a pandas dataframe which looks like this:

index col1   col2   col3   col4   col5
0     a      c      1      2      f 
1     a      c      1      2      f
2     a      d      1      2      f
3     b      d      1      2      g
4     b      e      1      2      g
5     b      e      1      2      g

I want to group by col1 and col2 and get the sum() of col3 and col4. col5 can be dropped since the data can not be aggregated.

Here is what the output should look like. I am interested in having both col3 and col4 in the resulting dataframe. It doesn't really matter if col1 and col2 are part of the index or not.

index col1   col2   col3   col4   
0     a      c      2      4          
1     a      d      1      2      
2     b      d      1      2      
3     b      e      2      4 


Solution:

df.groupby(['col1','col2']).agg(
     sum_col3 = ('col3','sum'),
     sum_col4 = ('col4','sum'),
     ).reset_index()



12 June 2022

04 June 2022

How to Scrape Everything From Instagram Using Python




Django app hosting free of charge

https://heroku.com




How to find the differences between two similar html (or other) code?

https://diffchecker.com

How to automatically format html code which was not indent properly and new line properly, or validate html code with some missing elements?

https://freeformatter.com

Seeing the web page at once, after you copy html, css, javascript there

https://codepen.io

23 May 2022

How to find a pattern in lines and append something to those lines?

https://unix.stackexchange.com/questions/543451/vi-finding-a-pattern-in-lines-and-add-at-the-end-of-those-lines


How to delete all the lines which contain a pattern in vim?

https://vim.fandom.com/wiki/Delete_all_lines_containing_a_pattern



The ex command g is very useful for acting on lines that match a pattern. You can use it with the d command, to delete all lines that contain a particular pattern, or all lines that do not contain a pattern.

For example, to delete all lines containing "profile" (remove the /d to show the lines that the command will delete):

:g/profile/d

More complex patterns can be used, such as deleting all lines that are empty or that contain only whitespace:

:g/^\s*$/d

To delete all lines that do not contain a pattern, use g!, like this command to delete all lines that are not comment lines in a Vim script:

:g!/^\s*"/d

Note that g! is equivalent to v, so you could also do the above with:

:v/^\s*"/d

The next example shows use of \| ("or") to delete all lines except those that contain "error" or "warn" or "fail" (:help pattern):

:v/error\|warn\|fail/d

22 May 2022

How to pass args to a Python program when running it?

To learn how, find the Python Doc/howto/ directory and open the file 'argparse.rst', e.g. 

~/Downloads/Python-3.10.0/Doc/howto/argparse.rst

14 May 2022

How to get a list of the members of an email distribution list, and a list of the members of an office 365 team?


(1) Email distribution list

Go to office.com > 9 dots > admin > show all > exchange > dashboard_recipients_groups.

Click to select a group, e.g. cics.staff. Click 'Edit' > membership. Ctrl-a Ctrl-c

Ctrl-v in a text editor.

(2) Team

Go to the team, e.g. team_staff. Wait for quite a while, and need repeat scrolling up and down, until all the members are displayed, before mouse-dragging all the members, and Ctrl-c

Ctrl-v in a text editor.