Time Running Up

Render - New default language versions

  • Node.js: 14.17.0 → 20.9.0
  • Ruby: 2.6.8 → 3.2.2
  • Elixir: 1.9.4 → 1.15.6
  • Python: 3.7.10 → 3.11.6

FrontEnd Interview Question

qPortal API development - Developers survey



RedisLabs Free Plan

The Free plan lets you run a single non-highly available Redis database with up to 30MB and 30 connections, forever (or as long as you use it)! It lets you run Redis Enterprise Cloud in a selected region across all three major public clouds (Amazon Web Services, Microsoft Azure, and Google Cloud). You can use  all available Redis modules: RediSearch, RedisJSON, RedisGraph, RedisTimeSeries, and RedisBloom. Best of all, it’s totally free, no credit card required. 

 

https://redis.com/blog/new-pricing-for-redis-enterprise-cloud/

 

 

Markdown Editor

Heroku vs Render

 HerokuRender
Sleeps after 30 minutes of inactivity15 minutes of inactivity
Free Tier550 dyno hours/month750 hours of running time
No of apps/services in free tier5no limitations

Firebase Rtdb Rules Example

{
    "rules": {
        "coaches": {
            ".read": true,
            ".write": "auth != null"
        },
        "requests" : {
            "•read": "auth != null",
            ".write": true
        }
    }
}

Setting up Drupal 9

Create a project:

$ composer create-project drupal/recommended-project:9.3.1 my_site_name_dir
 

This will create a project in 'my_site_name_dir' and automatically executes composer install to download the latest stable version of Drupal and all its dependencies.

Your 'my_site_name_dir' will contain files that should be outside of your web root and not  accessible by the web server. The web root will be 'my_site_name_dir/web'.

Install Php Filter:

$ composer require.  drupal/php
 

Alternate Installation:

Clone the below repo

https://github.com/apfromiit/drupal9

and run $ composer install

 

Add File Permissions:

$ sudo chmod +777 web/sites/default/files

Copy default.settings.php to settings.php

$ sudo chmod +777 web/sites/default/settings.php
 

Open in browser to complete the setup.

 

Remove File Permissions:

$ sudo chmod 755 web/sites/default/settings.php

 

Add new item to Main Navigation Menu:

Step 1: Create a tagname in Taxonomy:

 

1. Goto Manage → Structure → Taxonomy → VOCABULARY NAME: Tags →

 

 

2. Click

 

 

3. Enter tagname and click

 

 

 

Step 2: Create a page view for new menu item:

 

1. Goto Manage → Structure → Views and click
2. Enter View name
3. Under VIEW SETTINGS, Enter as below.
Show: of type: tagged with: Sorted by:

 

 

4. Enter PAGE SETTINGS and Menu Link details as shown below and click

 

 

5. Click

 

Now, adding tags to article will render the article in corresponding page.

 

We can remove the unwanted blocks by deleting them on the context menu provided on top right corner of every blocks.

Git Commands


  • git status - list untracked/modified/deleted files
  • git diff - To show line by line uncommitted local code changes
  • git show - To show diff of last commit
  • git add <filename> - To add file to be commit
  • git rm <filename> - To remove deleted file from git tracking
  • git commit - To commit the changes in local branch
  • git commit --amend - To append changes to peviously made commit
  • git push origin <branchname> - To push commit to remote (github)
  • git push origin HEAD - To push current branch to remote (github)
  • git pull origin <branchname> - To pull latest commits from remote branch (github)
  • git branch - To see current branch
  • git checkout <branchname> - To switch to another branch
  • git checkout -b <branchname> - To create and switch to new branch
  • git branch -D <branchname> - To delete a branch locally
  • git reset --hard - To clear local changes
  • git reset --hard HEAD^ - To delete last commit
  • git revert <commit-id> - To revert commit
  • git rebase -i HEAD~5 - To squash last 5 commits into single commit
  • git rebase -i --root - To squash all commits into root commit


Http Status Codes

Temp Mail

Code Prettify Demo

Heroku Static Website Hosting

How to deploy static website to Heroku?

  • git clone https://github.com/heroku/php-getting-started.git
  • Replace contents of web/ with your static website.
  • Replace contents of composer.json with {}
  • Remove composer.lock
  • Save changes and do git commit.
  • heroku login -i
  • heroku create <app-name>
  • git push heroku main
  • heroku open

CodeChef

Category Problems
Peer 13053
Beginner 434
Easy 1359
Medium 1057
Hard 469
Challenge 147
Total 16519

Schedule jobs with crontab on macOS

Running scripts on your computer is great. Running them automatically is even greater. If you are on a Mac (or Linux), you can use our good friend crontab, which is a scheduling tool that will run jobs (scripts) at regular intervals.

crontab

You add a job to crontab by editing the job list. A job is specified in the following format (first line):

* * * * *  command to execute
│ │ │ │ │
│ │ │ │ └─── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
│ │ │ └──────── month (1 - 12)
│ │ └───────────── day of month (1 - 31)
│ └────────────────── hour (0 - 23)
└─────────────────────── min (0 - 59)

Example

Let's make an example job. I personally use cronjobs to make regular backups of my MySQL databases, so I will show how to set this up to run once a day.

My script is called backup.sh, and will dump my MySQL database to a zip file. We'll set it to run as a cronjob by editing the job list (with the nano editor):

env EDITOR=nano crontab -e

Now enter the following and press CTRL+O and CTRL+X to save and exit.

0 12 * * *  cd ~/my/backup/folder && ./backup.sh

This will execute the command every day at 12:00, which changes to the folder of the script and runs it. The double ampersand && allows you to specify multiple commands that will run after each other.

Notice that if your computer is shut down or sleeping at the time, the script will not run until the next day at the specified time.

To see a list of your active crontab jobs, use the following command:

crontab -l

Environment

You might get a weird "command not found" error when running your crontab jobs for the first time, even though the script works fine when you run it yourself. That's because crontab executes commands without any of the normal environment variables set up.

To fix this, you can add the PATH in the beginning of your script, so it knows how to find programs like mysqldump:

#!/bin/sh
PATH=/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin

Disable mail alerts

So after you've set up your scripts and everything is honky dory, you might notice that the Terminal suddenly have started sending you e-mails.

If being pen pals with your Terminal isn't your thing, you can disable this behavior by inserting this line at the very top of your crontab file:

MAILTO=""

Presto. Now your jobs will run silent.

Tips

Here's a few small snippets which might come in handy:

Description Script
Execute on workdays 1AM 0 1 * * 1-5 /bin/execute/this/script.sh
Execute every 10 minutes */10 * * * * /bin/execute/this/script.sh
Log output to file */10 * * * * /bin/execute/this/script.sh >> /var/log/script_output.log 2>&1

Deploy Json Server to Heroku

  1. Clone json-server-heroku repo
  2. Place json data in db.json and commit
  3. heroku login
  4. heroku create
  5. git push heroku master

Note: Changes to db are non persistent. Heroku free dyno would become idle if no api request for 30 minutes. Heroku loads original db on next cold start.

{JSON} Placeholder

JSONPlaceholder is a free online REST API that you can use whenever you need some fake data. It can be in a README on GitHub, for a demo on CodeSandbox, in code examples on Stack Overflow, ...or simply to test things locally.

Resources

JSONPlaceholder comes with a set of 6 common resources:

/posts 100 posts
/comments 500 comments
/albums 100 albums
/photos 5000 photos
/todos 200 todos
/users 10 users

Note: resources have relations. For example: posts have many comments, albums have many photos, ... see guide for the full list.

Routes

All HTTP methods are supported. You can use http or https for your requests.

GET /posts
GET /posts/1
GET /posts/1/comments
GET /comments?postId=1
Ref: http://jsonplaceholder.typicode.com/


Firebase SDK

Requirements:

pip install firebase-admin
Goto Project Settings -> Service Accounts -> Click Generate new private key and save the file as credentials.json

Write to firebase RTDB:

import firebase_admin, json
from firebase_admin import credentials, db

cred = credentials.Certificate("credentials.json")
firebase_app = firebase_admin.initialize_app(cred, {
    'databaseURL': 'https://<projectid>-default-rtdb.firebaseio.com'
})
with open("data.json") as json_file:
    data = json.load(json_file)
    ref = db.reference("sample_key")
    ref.set(data)
firebase_admin.delete_app(firebase_app)

Read from firebase RTDB:

import firebase_admin
from firebase_admin import credentials, db

cred = credentials.Certificate("credentials.json")
firebase_app = firebase_admin.initialize_app(cred, {
    'databaseURL': 'https://<projectid>-default-rtdb.firebaseio.com'
})
ref = db.reference("sample_key")
data = ref.get()
firebase_admin.delete_app(firebase_app)

RTDB security rules:

{
  "rules": {
    ".read": false,
    ".write": false
  }
}

Granting Full Disk Access to cron

  1. Go to System Preferences > Security & Privacy > Privacy > Full Disk Access:

2. Click on the (+) icon to add an item to the list. Press command+shift+G to open the Go to Folder… dialog, type /usr/sbin/cron and press Enter:

3. Select the cron file and click Open:

That’s it!

Calculators

Code Prettify Snippets

declare const PR: any;

ngAfterViewChecked() {
    PR.prettyPrint();
}
Styles:
li.L0, li.L1, li.L2, li.L3,
li.L5, li.L6, li.L7, li.L8 {
    list-style-type: decimal !important;
}

pre.prettyprint {
    border-radius: 0;
    white-space: pre;
}
Template:
<pre class="prettyprint linenums lang-cpp">
...
Place the code here
...
</pre>

How to add labels in repo for Issue Tracker?

  • pip install labels
  • labels -u <username> -t <token> fetch -o <owner> -r <repo>
  • labels -u <username> -t <token> sync -o <owner> -r <repo> -f <path/to/labels.toml>

Reference: https://github.com/apfromiit/labels

LocalTunnel

$ npm install -g localtunnel
$ lt --port <port> --subdomain <subdomain>

Example:
$ lt --port 8000 --subdomain apdesk

Sample output url: https://apdesk.loca.lt

Reference: https://github.com/localtunnel/localtunnel

Some good themes

Some good looking themes

  1. bluegrasshopper ✅
  2. bold ✅
  3. bootstrap
  4. bootstrap2
  5. bootstrap2-dark ✅
  6. brownstone
  7. Flex ✅
  8. foundation-default-colors ✅
  9. franticworld
  10. fresh
  11. gum
  12. Just-Read
  13. lannisport ✅
  14. martyalchin
  15. materialistic
  16. mediumfox
  17. mg
  18. monospace
  19. nice-blog
  20. nmnlist ✅
  21. Nuja
  22. octopress ✅
  23. pelican-b-side
  24. pelican-cait
  25. pelican-twitchy ✅
  26. plumage
  27. relapse
  28. semantic-ui
  29. sneakyidea ✅
  30. subtle
  31. svbhack
  32. tuxlite_tbs
  33. w3-personal-blog

Population Chart

Loading...

Top most populated countries

Loading...