teleren/devto huggingface dataset:
How to create read-only user in PostgreSQL DB?
Tags: postgres, database, devops, sql
Published: 2023-09-11 05:08:19

How to create read-only user in PostgreSQL DB?

```
CREATE ROLE postgres_my_ro_group;
 
GRANT USAGE ON SCHEMA public TO postgres_my_ro_group;
 
GRANT SELECT ON ALL TABLES IN SCHEMA public TO postgres_my_ro_group;
 
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO postgres_my_ro_group;
 
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO postgres_my_ro_group;
 
CREATE USER my_dbuser_readonly WITH PASSWORD '***************';
 
GRANT postgres_my_ro_group TO my_dbuser_readonly;
 
--- To grant connect to specific DB:
 
GRANT CONNECT ON DATABASE cloud_usage TO my_dbuser_readonly;
 
--- To grant connect to all DBs on this DB instance:
 
SELECT format('GRANT CONNECT ON DATABASE %I TO my_dbuser_readonly;', datname) FROM pg_database; \gexec
 
--- Repeat code below for each database
 
\c foo
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO my_dbuser_readonly; --- this grants privileges on new tables generated in new database "foo"
GRANT USAGE ON SCHEMA public to my_dbuser_readonly;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO my_dbuser_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO my_dbuser_readonly;
```
AntDB-Oracle Compatibility Developer’s Manual P3–41
Published: 2023-09-11 05:03:23

##### MONTHS\_BETWEEN

The MONTHS\_BETWEEN function returns the number of months between 2 dates. If the first date is greater than the second date, then the return result is a positive value, otherwise the return result is a negative number.

If all date arguments have the same date in the month, or if all date arguments are the last day of the month respectively, then the result is the whole number of months.

**Example:**

```
SELECT MONTHS_BETWEEN('15-DEC-06','15-OCT-06') FROM DUAL;

MONTHS_BETWEEN('15-DEC-06','15-OCT-06')  
------------------------------------------
                                        2
(1 row)


SELECT MONTHS_BETWEEN('15-OCT-06','15-DEC-06') FROM DUAL;

MONTHS_BETWEEN('15-OCT-06','15-DEC-06')  
------------------------------------------
                                       -2
(1 row)


SELECT MONTHS_BETWEEN('31-JUL-00','01-JUL-00') FROM DUAL;

MONTHS_BETWEEN('31-JUL-00','01-JUL-00')  
------------------------------------------
                        0.967741935483871
(1 row)


SELECT MONTHS_BETWEEN('01-JAN-07','01-JAN-06') FROM DUAL;

MONTHS_BETWEEN('01-JAN-07','01-JAN-06')  
------------------------------------------
                                       12
(1 row)
```
AntDB-Oracle Compatibility Developer’s Manual P3–40
Published: 2023-09-11 04:55:17

##### SYS\_EXTRACT\_UTC

SYS\_EXTRACT\_UTC function is to return the standard UTC time that corresponds to the specified time.

SYS\_EXTRACT\_UTC (datetime\_with\_timezone)

**Example:**

```
SELECT SYS_EXTRACT_UTC(TIMESTAMP '2020-03-28 11:30:00.00 -08:00') FROM DUAL;

SYS_EXTRACT_UTC(TIMESTAMP '2020-03-28 11:30:00.00 -08:00')  
-------------------------------------------------------------
 2020-03-28 03:30:00
(1 row)
```
jq在区块链开发中的使用
Tags: jq
Published: 2023-09-11 04:23:59

最近在弄一些l2方面的开发,发现jq是一个使用比较广泛的工具,下面写个简单的教程.

jq是一个用来快速读写 json文件的工具,而我们写合约常用的hardhat,forge等工具都广泛运用json文件,
使用jq就可以做到和json相关的都自动化,免得自己老是vi编辑,手动编辑容易错.


## 安装 jq
```
# Debian系，如 Ubuntu
sudo apt-get install jq

# RedHat系, 如 CentOS
yum install jq

# npm 安装,不建议这种,环境问题很不好搞
npm install -g jq
```
工具太简单,随便学学就会了,我直接写两个例子.

## 一些例子

1、根据hardhat 的部署文件生成地址json
```
genAddr:
  #!/bin/bash
  cd ./packages/contracts-bedrock/deployments/getting-started
  addrtext="{}"
  for file in ./*
  do
      if test -f $file
      then
        addr=$(jq -r ".address" $file)
        filename=$(basename $file .json)
        addrtext=$(echo $addrtext |jq ".+{\"$filename\":\"$addr\"}")
      fi
  done
  echo "$addrtext">../../../../addresses.json
```

这里是结合 bash的写法,核心就两句
```
jq -r ".address" $file //获取json文件中的address
``` 
``` 
jq ".+{\"$filename\":\"$addr\"}" //根据上面获取的地址在json文件中写一个键值
```
2、修改创世文件给自己加点钱

```
#!/bin/bash
DUMP=$(cat $GENESIS_FILE |jq '.alloc += {"0x2BBBBBBBBBBBBBBBBBBBBBBBBB": {balance: "10000000000000000000"}}')
echo "$DUMP" | jq . > $GENESIS_FILE
```

想要更深入的学习,直接看官方文档

https://jqlang.github.io/jq/
Zagg Warranty Registration
Tags: dyrect, zaggwarrantyregistration, procuctregistrationsoftware, warrantyregistrationsoftware
Published: 2023-09-11 04:04:23

Since its establishment in 2005, ZAGG has built a solid reputation as a high-caliber inventor with a focus on mobile accessories and protective products. The company's solutions are designed to make mobile devices more functional while also protecting them and improving user experience. ZAGG's commitment to guaranteeing customer happiness is reflected in their warranty coverage programme and great customer service, making them a widely recognised brand for mobile accessories. 
For more visit : [Zagg Warranty Registration](https://www.dyrect.co/company/zagg-warranty)
Dirty JavaScript? Clean It Up with These Proven Techniques 😅
Tags: javascript, programming, typescript, coding
Published: 2023-09-11 03:58:01

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cyu0y1jv5odt84d4korx.png)
JavaScript, the dynamic and versatile programming language of the web, is a powerhouse for creating interactive and engaging web applications. But like any other language, JavaScript can get a little messy at times. 😬 Fear not, for in this article, we'll dive into the art of cleaning up your JavaScript code with some proven techniques. 💻✨

**The Dirt on Dirty JavaScript** 😕
Before we unveil our cleaning arsenal, let's take a look at what makes JavaScript code dirty:

**1. Spaghetti Code 🍝:** When your code becomes a tangled mess of unstructured functions and variables, it's like trying to eat spaghetti with a spoon – messy and frustrating!

**2. Global Variables 🌐:** Overuse of global variables can lead to conflicts and unintended side effects. Your code turns into a chaotic playground.

**3. Poor Naming Conventions 🐒:** Naming your variables and functions unclearly is like hiding the cleaning supplies – you'll never find what you need!

**4. No Comments 😶:** Imagine your code is a mysterious box, and you've forgotten the key. Comments are the key, and without them, your code remains a puzzle.

**Cleaning Techniques 🧽**
**1. Embrace Modularity 📦**
Break your code into smaller, reusable modules. This makes it easier to understand and maintain. Here's a simple example:
read my full article [here ](https://jtsofttech.com/post/dirty-javascript-clean-it-up-with-these-proven-techniques)
Need an Emergency Locksmith in Birmingham? Call the Birmingham Locks 24/7
Tags: webdev
Published: 2023-09-11 03:43:19

Rapid Response Emergency Locksmith: When you're in a jam, our [emergency locksmith service Birmingham](https://thebirminghamlocks.co.uk/)  is here to swiftly resolve your lock and key crises.

24/7 Birmingham Locksmith: We're available around the clock, ready to tackle any lockout or security emergency, ensuring your safety and peace of mind.

Locked Out? We've Got You Covered: Our emergency locksmiths specialize in getting you back inside your home, car, or office when you've been locked out.

Emergency Residential Locksmith: We provide immediate assistance for homeowners facing unexpected lock and key issues, ensuring your home's security.

Commercial Lockout Experts: Don't let a lockout disrupt your business operations. Our emergency locksmiths in Birmingham will have you back in business in no time.

Vehicle Locksmith Services: Locked out of your car? Our skilled Birmingham locksmiths are ready to help, no matter the time or place.

Quick and Reliable Emergency Locksmith: Count on us for rapid response times and reliable service when you need it most.

Lock Repairs in a Pinch: If your lock is malfunctioning or damaged, our emergency locksmiths will quickly assess and repair the issue.

Key Replacement on the Spot: Lost your keys? Our Birmingham emergency locksmiths can cut and program replacements on-site.

Emergency Rekeying Services: Ensure your property's security with our emergency rekeying services, available 24/7.
https://thebirminghamlocks.co.uk/
Things you need to know before learning django.
Tags: tutorial, python
Published: 2023-09-11 02:05:19

The django framework is a web framework used to build web applications.It is also known as the framework for perfectionist with a deadline.The most trendy and popular python framework for web development.
You might be wondering what are the topics or things you should know before learning django.
First you must know the python programming language fundamentals.
what are these fundamentals?

1. variables
2. list, tuples and dictionary
3. functions
4. class especially how to inherit from another class properly
5. Understand object oriented programming 
6. You should also have a basic understanding of html, css and javascript it will come handy when you are writing your models that will be translated to an html element.
7. know the GET and POST request what they mean and when to use them.
8. You also need to understand database and sql like foreignkeys, relationship between tables and how they map to your python model.
9. what a virtual environment is.
10. why django is called an MVT framework.
11. learn to use git and the django documentation.
The Ease of Force-Pushing and GitHub's Safety Net
Tags: git, webdev, programming, beginners
Published: 2023-09-11 01:46:47

Last night, I made an intriguing discovery about the intricacies of `git commit` amending that, I believe, is worth sharing.

It turns out that once you've amended a `git commit`, the conventional `git pull` and `git push` commands won't work as expected. This quirk arises due to the inherent discrepancy between the local and the remote repositories once a commit has been amended. In most cases, the local repository is regarded as the source of truth, requiring the remote repository to align with it.

To illustrate this concept, consider a recent real-world scenario: I decided to remove three commits from my pull request. As anticipated, a divergence emerged between my local and remote repositories. Typically, I would have instinctively used `git push -f` to forcefully push these changes to the remote. However, I received advice against following my muscle memory and instead opted for the traditional approach of executing `git pull`, followed by `git push`. To my astonishment, the remote repository still retained the three commits I had removed.

![The example of force records](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kq2g1inkpccfa3jyfy85.png)

Now, I couldn't help but reflect on why my previous teams resorted to using force-pushes so frequently. However, it's important to note that there's no need for concern regarding the potential loss of tracking before and after a force-push. GitHub has an effective record-keeping system that ensures your repository's history remains intact.
Introducing tml: Your Text to HTML Command-line Companion
Published: 2023-09-11 00:14:33

In the world of text and web, a bridge is often needed. Enter tml, a straightforward command-line tool designed to swiftly convert your .txt files into clean HTML documents. Let's dive briefly into its magic.

## **Getting Started with tml**

# Installation:
`git clone https://github.com/mnajibi/tml.git
cd tml
chmod +x main.py
`

# **Usage:**
`./main.py <path-to-txt-file>
`
Example:
`python main.py examples/sample3.txt`

# **Key Features**

- **Batch Conversion:** 
Hand over a directory, and tml will process all .txt files within.
- **Automatic Formatting:** 
Your text paragraphs? They'll be neatly wrapped in `<p>...</p>` tags.
- **Title Recognition:** 
A title followed by two blank lines in your `.txt`? `tml` sets it as the HTML `<title>` and creates a bold `<h1>` tag in the body.
- **Custom Output Directory:** 
Specify where you want your .html files with:
`./main.py <path-to-txt-file> --output <path-to-output-directory>
`
Example:
`python main.py examples/sample3.txt --output ./custom`

## **Wrap Up**
`tml` brings simplicity and efficiency to your text-to-HTML needs. No fuss, no clutter, just pure conversion. Curious? Dive into the [project on GitHub](https://github.com/mnajibi/tml) for more.
Different ways to invoke AWS Lambda Functions
Tags: aws, lambda, serverless, awscommunitybuilder
Published: 2023-09-10 22:36:07

---
title: Different ways to invoke AWS Lambda Functions
published: true
description: Different ways to invoke AWS Lambda Functions including AWS CLI and Lambda function URL
tags: AWS, Lambda, Serverless, AWSCommunityBuilder

cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mqcftceylhvde43ak7fs.png
# published_at: 2023-09-10 22:20 +0000
---

[AWS Lambda](https://aws.amazon.com/lambda/) is a Serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers. You can trigger Lambda from over 200 AWS services and software-as-a-service (SaaS) applications and only pay for what you use.

Check out my previous posts on [how to create a Lambda function and deploy it the CI/CD way](https://dev.to/aws-builders/setup-cicd-for-your-aws-lambda-with-serverless-framework-and-github-actions-4f12).

AWS Lambda can be invoked in several ways which include through the Lambda console, a function URL HTTP(S) endpoint, the Lambda API, Amazon API Gateway, an AWS SDK, the AWS Command Line Interface (AWS CLI), and AWS toolkits. You can also configure other AWS services to invoke your function, or you can configure Lambda to read from a stream or queue and invoke your function.

In this tutorial, we will be covering how to invoke using the Lambda console, function URL, AWS SDK and the AWS Command Line Interface (AWS CLI).

###Invoking your Lambda function through the Lambda console
- Go to the Lambda function
- Click on Test
- Input an Event Name and click on Invoke, this will invoke the function

![Lambda Console](https://miro.medium.com/v2/resize:fit:4800/1*BIz1M0n4qo9c0tzdjzCT_g.gif)


###Invoking your Lambda function through the function URL
> Function URLs are not supported in the following regions: Asia Pacific (Hyderabad) (ap-south-2), Asia Pacific (Melbourne) (ap-southeast-4), Europe (Spain) (eu-south-2), Europe (Zurich) (eu-central-2), Israel (Tel Aviv) (il-central-1), and Middle East (UAE) (me-central-1)

Follow these steps to create a function URL for your Lambda function
- Go to the Lambda console
- Click on the Configuration tab
- Click on Function URL
- Click on Create Function URL
- Select None and click on Save
- Open the link on your browser

![Lambda Function URL](https://miro.medium.com/v2/resize:fit:4800/1*BIz1M0n4qo9c0tzdjzCT_g.gif)



###Invoking your Lambda function using AWS SDK
```
import {InvokeCommand, LambdaClient} from "@aws-sdk/client-lambda";

const client = new LambdaClient({
region: "eu-west-1"
});

client.send(new InvokeCommand({
  FunctionName: "helloWord"
}))
```

###Invoking your Lambda function using AWS CLI
```
# run this following commands

aws configure #configure aws cli

aws lambda invoke - function-name helloWorld response.json # invoke lambda function

cat response.json # read the response
```
Happy coding!!
Lifecycle of a URL Request
Tags: beginners, webdev
Published: 2023-09-10 22:34:35



Last week, I came across a valuable LinkedIn article by [Brij Kishore Pandey](https://www.linkedin.com/in/brijpandeyji/) detailing the journey of a "[URL from Keyboard to Screen](https://www.linkedin.com/posts/brijpandeyji_the-journey-of-a-url-from-your-keyboard-activity-7104787767296942081-VXer/?trk=public_profile_share_view)". I've written this blog to save its insights, but if you're in tech, I highly recommend reading it. The article breaks down the components and flow of a URL request.

---

The Journey of a URL: From Your Keyboard to a Fully Loaded Web Page! 🌐

Ever wondered what happens behind the scenes when you type a URL into your browser's address bar and hit Enter? 🤔

Let's demystify the magic that unfolds in milliseconds! ⏱️

🖥️ Client-Side Magic:

1️⃣ Initiating TCP Connection: Your browser initiates a TCP/IP 3-Way Handshake (SYN, SYN-ACK, ACK) to establish a connection.
2️⃣ HTTP Request: A GET request is sent to the server.
3️⃣ Browser Engine: The browser engine takes over, coordinating between the render engine and networking tasks.

🌐 The Role of DNS:

1️⃣ Root Domain Name Server: Helps in identifying the Top-Level Domain (TLD).
2️⃣ TLD Name Server: Points to the 2nd Level Domain Name Server.
3️⃣ 2nd & 3rd Level Domain Name Servers: They help in resolving the IP address of the website.

🖥️ Server-Side Magic:

1️⃣ Server Response: The server responds with status codes:

1xx: Information Message
2xx: Success
3xx: Redirects
4xx: Client Errors
5xx: Server Errors

🌍 Web Page Rendering:

1️⃣ Tokenizer & DOM Tree: HTML is parsed and a DOM tree is created.
2️⃣ CSSOM Tree: CSS is parsed into a CSS Object Model (CSSOM) tree.
3️⃣ Render Tree: DOM and CSSOM trees are combined.
4️⃣ Layout & Painting: The final layout is calculated and painted on the screen.

Your Web Page is Loaded!


---

Here's the image:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ejzdcwfqldqv7887ii10.gif)

This post is inspired by and based on a sketch from @manekinekko on X(Formerly Twitter)
This Gif it licensed under : https://lnkd.in/eBAGdRtG
Serverless wsgi zipped packages
Published: 2023-09-10 22:14:14

I just spent the longest time trying to debug why my Flask app run on AWS Lambda wasn't working correctly. Consistently, I was seeing the error,

```
No module named 'wsgi_handler'
```

I was able to track this down to how I am packaging my function. I create a zip file containing my function code and its requirements. Using Serverless Framework, this looks like,

```
package:
  artifact: .package/package.zip
```

I was then using the plugin `serverless-wsgi` to serve my Flask app.

The problem was that the `serverless-wsgi` plugin was unable to include its required `wsgi_handler` code file. This is because my code was already zipped before running `serverless deploy`.

The solution was to remove the `serverless-wsgi` plugin and wrap the handler manually.

1. Install `serverless-wsgi` as a python dependency

  ```
  $ pip install serverless-wsgi
  $ pip freeze > requirements.txt
  ```

2. Create the lambda handler

  ```python
  # file handlers/ui_handler/__init__.py
  
  import serverless_wsgi
  
  from handlers.ui_handler.app import app
  
  def handle(event, context):
      return serverless_wsgi.handle_request(app, event, context)
  ```

3. Using Serverless Framework, set the handler to this function

  ```
  functions:
    ui:
      handler: handlers/ui_handler.handle
      url: true
  ```
Apollo 0.1 Liftoff
Tags: blog, news, opensource
Published: 2023-09-10 22:12:41

GNU Telephony is creating a new free software framework for next generation ai assisted telephony services.  This is under active development for use in homes, offices, and in smart cities. The current stack is found at [https://codeberg.org/gnutelephony](https://codeberg.org/gnutelephony).

Apollo is a new front-end web management and integration service for a generic home and small office service implementation. This launch of Apollo features completion of extension line management.

My goal is to run these services on Raspberry Pi class computers. Something like the Banana Pi bpi-r3 with PoE running Debian GNU/Linux could make a lovely stand-alone target platform for a Coventry phone system / home automation server / ai smart assistant.

Coventry itself has a 4 level config system. There is a system config (/etc/coventry.conf) that you can use for primary configuration often needed for startup. There is a dynamic config that Apollo web services manipulates to define lines, though you also can do so in the system config for "defaults", too. There is a custom config which has overrides that cannot be modified by Apollo, including custom lines. Finally there is a state override for setting things like day / night / vacation behaviors.

Coventry configuration can be changed while the service is running. Existing calls and lines continue from the prior config, and new calls are processed based on the current config. Coventry itself has no running dependencies on other services working. It should be possible to install and update a fleet of Coventry devices and related device endpoints like netmouth all at once operating in the field using something like Ansible. However, it is the introduction of Apollo that turns this collection of code into a unified project and deploy-able service.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtz3mw5tchuipakcfqfs.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2wgw7qsjdws9p81f0nfx.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oosb6jom8fjjtbaaysyh.png)
My thoughts after creating a note web app | QuikNote
Tags: react, frontend, projects, thoughts
Published: 2023-11-11 03:13:17

---
title: My thoughts after creating a note web app | QuikNote
published: true
date: 2023-09-10 21:56:47 UTC
tags: react,frontenddevelopment,projects,thoughts
canonical_url: 
---

![quiknote web note app built by golden ekpendu](https://cdn-images-1.medium.com/max/1024/1*gK772y_GHADGiHA6N4wNpQ.jpeg)
_QuikNote logo_

A few months ago, I started coding up a project I’ve always wanted to create. Introducing **QuikNote** , a note web app.

🌎 [https://quiknote.vercel.app/](https://quiknote.vercel.app/)   

QuikNote features user authentication, a rich text editor, and a user-friendly interface.

**The story behind the project**

Originally created in React using JavaScript, I switched to Typescript (because this is my first project using Typescript). Though it was challenging at first, migrating from JS to TS, I later found the process to be a good learning opportunity.

_The app is powered by Firebase._

**Challenges**

The foremost challenge I faced in this project was creating a note and only displaying it to the owner, not everyone else who uses the app.

I must admit, I did spend a lot of time trying to fix this. I read the docs, tried stack overflow and other forums but I couldn’t solve the issue.

Finally, I had a _eureka moment_, and discovered the solution was looking me in the face all this time 😂. But that’s why I love taking my time on projects, no matter how small it is. If I try new things, errors are bound to happen but with a methodical approach, I’ll find the solution and learn from the experience!

Another challenge was using Typescript. I had watched a Typescript video prior but using it in real-time seemed to be very different. Fortunately, I have the internet and I utilized tools like blogs, forums, docs, videos to get a sense of what I needed to do.

I also utilised a good ol’ AI friend to explain certain Typescript concepts I was unfamiliar with.

**Future Plans**

I thoroughly enjoyed every second making this — from the frustration of things not working as they should, to the joyous moments seeing the progress being made.

From now on, I’ll try my best to use Typescript in most of my projects.

Also, I plan on using more UI styling libraries/frameworks.

On a final note, I saw firsthand what lack of planning in a project does to everyone involved. So I’ll continuously push myself to create user interfaces for each project before writing a line of code.

I can’t count how many times I had to pause because I didn’t have a set user interface beforehand.

Also, I do enjoy creating user interfaces, so why not combine two things I love?

_Thanks a lot for reading to this point, I really appreciate you. Be on the lookout for my next project (it’s a secret so I can’t tell you exactly what it is.

**TOOLS USED IN THIS PROJECT**  
⚛️ React.js  
📃 Typescript   
💅 Styled-components   
📁 React Icons  
🔥 Firebase  
[undraw.co](https://undraw.co) for illustrations

P.S: If you have some feedback or suggestion, please [use this form](https://forms.gle/4qJzk6Z86evDS4zx8)