teleren/devto huggingface dataset:
326.Leetcode Solution in JavaScript
Tags: javascript
Published: 2022-08-24 05:15:03

```
/**
 * @param {number} n
 * @return {boolean}
 */
var isPowerOfThree = function(n) {
    if (n === 0) return false;
    if (n === 1) return true;
    return n % 3 === 0 && isPowerOfThree(Math.floor(n / 3));
};

// iterative Ways
var isPowerOfThree = function(n) {
    if (n > 1) {
        while (n % 3 === 0) {
            n = Math.floor(n / 3);
        }
    }
    return n === 1;
};
```
#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/power-of-three/
Software escaping VM - how?
Tags: 0x00sec
Published: 2022-08-24 04:01:48

Freshly created a Windows Virtual Machine in VMWare which has a VPN running inside it so all traffic goes over VPN. Then installed a program that gives a free trial after clicking "Activate trial" button. Doesn't ask for email or any other info for activation. 

After few days program expired, so redownloaded it and reinstalled in another fresh VM with VPN connected to different region. Installation went fine but after clicking "Activate trial" button - which seems to talk to a server - it says trial expired.

Tried changing some of the VM hardware, creating another user on the VM and reinstalling in fresh VM but none of these worked. Somehow the program or the server its talking to knows the trial has been used/expired.

How is this possible? Any ideas where to focus/troubleshoot this?
Textual is the only Python Terminal UI Framework you will need.
Tags: python, terminal
Published: 2022-08-24 03:43:00

IF you ever wanted to build rich User Interfaces that work in the terminal with mouse support written in Python, then [Textual](https://www.textualize.io/) is the Library for you.

The framework is completely written in Python and supports CSS for styling. You can use the mouse or shortcut keys for navigation.

You may be asking why would you need a UI framework for the terminal, well to me here are some of the benefits:

- UI Applications that can be accessed through SSH
- Single point of maintenance similar to web applications
- No GUI dependencies

Yet it is still a work in progress according to the creator of Textual [Will McGugan](https://twitter.com/willmcgugan), so lets look at some examples of what can be done with Textual so far.

First lets install Textual using pip:

```sh
pip3 install textual
```

Once installed we can try out some examples which can be found in the Textual github repository (https://github.com/Textualize/textual). So let's clone the repo:

```
git clone https://github.com/Textualize/textual.git
```

Once cloned lets run some examples like the Calculator app:

```
cd textual/examples/
python3 calculator.py
```
You can either use your numpad/keyboard to enter in numbers or use your mouse by pointing and clicking right in your terminal. You will also notice that as you resize your terminal window the whole app adjusts to fit the screen size.

![Textual Calculator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/evj2sznuk9afdqgr1wek.png)

How about something a little more complicated like a code viewer:

```
python3 code_viewer.py
```

Select the file you would like to view from the left-side file browser by clicking on it, you will then see the preview on the right-side. On the bottom bar you can either use your keyboard for the shortcut keys or click on the required function.

![Textual Code Viewer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqegto78uv9i8jzu0nfu.png)

As you can see the potential with Textual is endless, your imagination is the limit. For inspiring ideas or to see some use-cases of Textual you can visit the [Textual gallery](https://www.textualize.io/textual/gallery)
How To Store Data In Database Using Node.js
Tags: node, database, mysql, beginners
Published: 2022-08-24 03:32:45

In this article, we will see how to store data in a database using node js. In the previous node js article, I will give you examples of how to connect a MySQL database with Node.js and how to create a MySQL database in Node js. So, now I will give you information about inserting rows into the MySQL database table from node.js or inserting multiple records into MySQL using node.js.

So, let's see, how to save data in a database using node.js or how to insert data into a MySQL table using node js. Before performing this article please make sure to create a database with a connection. So, read the below tutorial for connecting the database.

Example:

```
var mysql = require('mysql');

var con = mysql.createConnection({
  host: "localhost",
  user: "your_username",
  password: "your_password",
  database: "techsolutionstuff"
});

con.connect(function(err) {
  if (err) throw err;
  console.log("Connected..!!");
  var sql = "INSERT INTO users (name, email) VALUES ('techsolutionstuff', 'test@gmail.com')";
  con.query(sql, function (err, result) {
    if (err) throw err;
    console.log("Record Inserted Successfully!");
  });
});
```

Run db_record_demo.js file

```
node db_record_demo.js
```

The response with console messages like

```
Connected..!!
Record Inserted Successfully!
```

---

Read More: Insert Multiple Records Using Node.js on Original Post
Common services and methods of openTCS
Tags: opentcs, java
Published: 2022-08-24 03:14:21

# Introduction
openTCS is a vendor-independent and flexibly usable control system software for automated guided vehicle systems (AGVS) and other non-continuous conveyors like electric monorail conveyors and mobile assembly platforms. It was originally developed during a publicly funded project. Now the code base is being maintained and development continued by Fraunhofer Institute for Material Flow and Logistics (IML) in Dortmund, Germany.

# Services and methods
## plantModelService
Create model, get model information, etc.
Create a new model
plantModelService.createPlantModel();
Get model properties, such as modification time
plantModelService.getModelProperties();
get model name
plantModelService.getModelName();
Get the elements on the model: point, car, order, etc.
plantModelService.fetchObjects();

## transportOrderService
After the order is created, the initial status of the order is RAW
Create Order
transportOrderService.createTransportOrder();
Create order sequence
transportOrderService.createOrderSequence();
Mark order sequence complete
transportOrderService.markOrderSequenceComplete();

After the order is created, set the properties, such as the expected execution trolley, deadline, etc. Order status changed to ACTIVE

## routerService
The router checks whether each destination can be reached, and can modify the order status to dispatchable. If not, change the order status to UNrouteable
routerService.updatePathLock();
routerService.updateRoutingTopology();

## dispatcherService
The dispatcher assigns the trolley to execute the corresponding order, and when the trolley starts to execute, it changes the order status to be processed
Allocate orders
dispatcherService.dispatch();
Cancellation by car
dispatcherService.withdrawByVehicle();
Cancellation by order
dispatcherService.withdrawByTransportOrder();

## vehicleService
Services for trolleys, mainly including communication adapters
Update cart integration
vehicleService.updateVehicleIntegrationLevel();
get processModel
vehicleService.fetchProcessModel();
vehicleService.sendCommAdapterCommand();
vehicleService.attachCommAdapter();
vehicleService.disableCommAdapter();
vehicleService.enableCommAdapter();
vehicleService.fetchAttachmentInformation();
vehicleService.updateVehicleAllowedOrderTypes();
vehicleService.sendCommAdapterMessage();

## schedulerService
schedule
schedulerService.fetchSchedulerAllocations()

## notificationService
Notice
notificationService.fetchUserNotifications();
notificationService.publishUserNotification();
isPowerOfThree
Tags: javascript, leetcode
Published: 2022-08-24 03:09:00

```
var isPowerOfThree = function(n) {
   return checkIsPower(n);
    
};

const checkIsPower = (n) =>{
    if(n<=0){
        return false;
    };
     if(n % 3 === 0){
        return checkIsPower(n/3)
    } 
    if(n==1){
        return true;
    };  
    return false;
}
```
Create a Log-in Page with HTML and CSS
Tags: html, css, learning, frontend
Published: 2022-08-24 02:53:46

---
title: Create a Log-in Page with HTML and CSS
published: true
description: 
tags: #html #css #learning #frontend
# cover_image: ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8a1h7ptpzrm230se915.jpg)
# Use a ratio of 100:42 for best results.
---
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8a1h7ptpzrm230se915.jpg)

This article will discuss the functionality and languages used to set up a Simple log-in page.

Most social media platforms, bank accounts and other individual sites use this log-in page. 

The log-in page creates room for a user’s little details for identification and verification to a particular site that one might have claimed to be already registered. 

Many times, the log-in page consists of the User’s registered name and password of the registration to that site.

The truth is that anyone can create a Log-in page with HTML and CSS.

Firstly, we will write the basic HTML structure.

https://gist.github.com/Peterimie/6df7e91a6d53897b321fa1934f323d7f

Having done this, we create a form with a background colour, light grey, indicating a user should fill. 

Let us create a session for the username and password

https://gist.github.com/Peterimie/6ea3571501cef23f458d2724f45e8c3d
https://gist.github.com/Peterimie/9f0d78f804fd62aadf1fe7eb46b3f8a0

Note that the input type assigned to each placeholder is essential as it will tell the browser what kind of data inserted.

Having done this, the expected output;

We style as follows;

https://gist.github.com/Peterimie/4bc55b02a0303a1321aaa9b8f01791b4

Our output;

Whenever a user inputs his name and password, we are required to see the log-in button and a part where the Remember me button will be to avoid the user logging in multiple times.

Creating and styling the button and the remember me is as follows;
https://gist.github.com/Peterimie/dac103e117d3f45029da826bd22b66a4

Style your button as follows;

https://gist.github.com/Peterimie/9c07b62367fde4e7a56d8a07715eca7a

After this, your output is;

Lastly, we create the Forgot password? Section.

We create it as a link to the PHP server where we can enter other trial log-in details if one has forgotten his original log-in credentials.

https://gist.github.com/Peterimie/4e8959a4174aca8d990be0e1d828e873
As we can see above, I decided to float the Forgot password to the right to make it look more professional. Here is the output;


Here is our User’s interface for the log-in page. 

When you input your username and password, you click the log-in button.

  
Our code shows that the log-in detail is functioning correctly.
Create a table with ActiveRecord.
Tags: ruby, programming, beginners
Published: 2022-08-24 02:50:52

**What is ActiveRecord?**

ActiveRecord is the M in the MVC (Model-view-controller). The model is the layer of the system responsible for representing data and logic. Active Record facilitates the creation and use of objects whose data requires persistent storage to the database.

ActiveRecord facilitates building tables using Ruby. As well as, enabling us to interact with a database to retrieve properties and relationships of the objects in an application without writing SQL statements. 


**How to create a table with ActiveRecord?**

Creating a table is simple, but before you do that you have to create a migration before setting up your table. to create the migration you have to run this command on the terminal `rake db:create_migration NAME=<name-migration>`

After you do this you will have new file like this.

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

Inside of this file we will create our table method.

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

After the table name artists we write a a block of code that is passed a block parameter `t`. It is a special Active Record migration object that helps add different columns to the table. 

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

After this we run `rake db:migrate`
Active Record will create a new database file. 

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

This will also create a `db/schema.rb` this is used as a snapshot of the current state of the database. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/39h4o48qvfq2oidlawno.png)

We then create an Artist class and extend the class with ActiveRecord::Base


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

We then are able to instantiate a new Artist.


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

After creating a few more Artists we can see all of their information. 


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


sources:
[ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html)
VSCode Secret Hidden Feature
Tags: vscode, javascript, beginners
Published: 2022-08-24 02:34:23

Did you know that VSCode has a secret hidden developer console built in!  The reason for this is that VS Code is built with Electron. 

Electron uses web technologies like javascript, html and css to build an application. Under the hood it’s using chromium. Chromium is the open source part of googles chromes browser. Electron allows you to build cross platform applications. That’s why you can use VSCode on mac, windows, in the browser and much more. 

Now you have the option to test out a snippet of JS in VSCode or Chrome dev tools.

Checkout the youtube short for more details
{% embed https://www.youtube.com/shorts/dQqbtPsFh04 %}
Razor pages or mvc
Tags: csharp, dotnet, help
Published: 2022-08-24 01:14:00

Hi fellow devs, i'm rebuilding some projects, so i could use a little help.
My previous solution was a .Net framework app that uses a lot of APIs from a webapi project. I'm moving to .Net core and a little confused about the performance and sustainability. Should i stick to mvc or the Razor pages approach could be better?
How to switch between PHP versions on Mac OS X using homebrew
Tags: php
Published: 2022-08-27 16:36:49

---
title: How to switch between PHP versions on Mac OS X using homebrew
published: true
date: 2022-08-24 01:09:44 UTC
tags: PHP,php
canonical_url: https://davidloor.com/2022/08/23/how-to-switch-between-php-versions-on-mac-os-x-using-homebrew/
---

I use docker for all the projects, but the other day I needed to run a composer command in my host machine to install a Drupal distribution which is not compatible with PHP 8.0, so I needed to switch the PHP version. And the steps to do so are:

1. Install homebrew: [https://docs.brew.sh/Installation](https://docs.brew.sh/Installation)
2. Install the [Brew PHP switcher script](https://github.com/philcook/brew-php-switcher), using: `brew install brew-php-switcher`
3. Switch to the version needed, in this example is 7.4: `brew-php-switcher 7.4`
  1. You will need to install the version of PHP first: `brew install php@7.4`
Improve Data With Twitter Lists
Tags: twitter, api, awesome, geaux
Published: 2022-08-23 23:19:31

## I make Twitter Lists of Official Groups

And they rock to have in lists for organizing and cleaning your data. I'm about to make a bot to automate this, but feel free to swing by home page or Twitter each day to see what kind of list is trending and what I got for ya at https://geauxweisbeck4.dev 

Hope y'all enjoy!
Linking your Microservices with Workflows
Tags: webdev, javascript, beginners, podcast
Published: 2022-08-23 23:14:02


Original: https://codingcat.dev/podcast/2-21-linking-your-microservices-with-workflows

{% youtube https://www.youtube.com/watch?v=jUAB7mJsbFE %}

## Questions

1. Can you tell us a little about what Temporal is and how you got started there? 
  1. [https://www.swyx.io/why-temporal/](https://www.swyx.io/why-temporal/)
  2. [https://gist.github.com/sw-yx/ff8a4f6757286444fa20b43f6b98b205](https://gist.github.com/sw-yx/ff8a4f6757286444fa20b43f6b98b205)
  3. [https://www.swyx.io/self-provisioning-runtime/](https://www.swyx.io/self-provisioning-runtime/)
2. Do you still need to use things like Cloud Pub/Sub or AWS SQS?
3. Should you use a scheduler of any kind outside of Temporal?
4. How does a temporal workflow increase productivity?
5. What services would Temporal help with?
6. Pricing is not public yet.
7. Who is the target customer?
8. How much are you getting to use Svelte?
Regaining JavaScript Performance in your Website
Tags: webdev, javascript, beginners, podcast
Published: 2022-08-23 23:09:02


Original: https://codingcat.dev/podcast/2-20-regaining-java-script-performance-in-your-website

{% youtube https://www.youtube.com/watch?v=u0RVYskNzKc %}

## Questions

1. Can you tell us about yourself and how you got started
2. [JS Performance in 2020](https://javascript.plainenglish.io/javascript-frameworks-performance-comparison-2020-cd881ac21fce)
3. Lets talk about this [Partial Hydration Thread](https://twitter.com/ryanflorence/status/1489052911506128898)
4. How do frameworks like [Qwik](https://github.com/builderio/qwik), [Svelte](https://svelte.dev/), [Marko](https://markojs.com/) compare with [SolidJS](https://www.solidjs.com/)?
  1. Would you say that [React](https://reactjs.org/) is the closest comparison?
5. Will something else start [trending](https://www.npmtrends.com/@angular/core-vs-react-vs-solid-js-vs-svelte-vs-vue-vs-marko) this year?
6. Q&A
Enterprise Databases that Scale
Tags: webdev, javascript, beginners, podcast
Published: 2022-08-23 23:04:03


Original: https://codingcat.dev/podcast/2-19-enterprise-databases-that-scale

{% youtube https://www.youtube.com/watch?v=RTFMT9BKDIg %}

## Questions

1. Since the last time you were on you have moved from Auth0 to Planet Scale
  1. Did you get any time to spend on yourself, your channel?
  2. How was the transition? It often take time to learn a whole new team and product.
2. What is Planetscale? 
  1. What does the “scale of open source” mean?
  2. What is [Vitess](https://vitess.io/)?
      1. What does Sharded MySQL mean?
  3. If this is serverless is it running on AWS or GCP?
3. Is Branching of a database just a copy?
4. Will running an ALTER for your schema require you to have downtime?
5. CLI
6. Pricing
7. Foreign Key Constraints
8. Using Prisma with Planetscale

### Alex Patterson

[Envato Elements](https://elements.envato.com/) [Raycast](https://ray.so/)
Making the Web Easier to Build
Tags: webdev, javascript, beginners, podcast
Published: 2022-08-23 22:59:01


Original: https://codingcat.dev/podcast/2-18-making-the-web-easier-to-build-with-una-kavets

{% youtube https://www.youtube.com/watch?v=8wVPvZe5aZc %}

## Questions

1. Can you give us some background on how you got here?
2. Transition DevRel lead at Google
3. Job at Web platform for chrome and dev tools
4. What is the connection between Chromium and Chrome Browser?
5. We are going to have an entire episode on OpenUI, but could you give us a brief overview of it?
6. What was the inspiration behind web.dev?
  1. What are your goals for the web.dev?
7. How did you get started with the Toolsday Podcast?
8. How closely do you work with other browser teams?
9. What is Cascade Layers?
  1. [https://developer.chrome.com/blog/cascade-layers/](https://developer.chrome.com/blog/cascade-layers/)
10. Can you use !important?
11. What is your favorite CSS trick? 
  1. [https://web.dev/one-line-layouts/](https://web.dev/one-line-layouts/)
  2. [http://1linelayouts.glitch.me/](http://1linelayouts.glitch.me/)
  3. [https://una.im/](https://una.im/)
12. What is your favorite new CSS feature?
13. What is one thing you can do to make your site better?

### Alex Patterson

useHooks - [https://usehooks-ts.com/](https://usehooks-ts.com/)

CSS Podcast - [https://thecsspodcast.libsyn.com/](https://thecsspodcast.libsyn.com/)
Building the Future of Svelte at Vercel
Tags: webdev, javascript, beginners, podcast
Published: 2022-08-23 22:54:02


Original: https://codingcat.dev/podcast/2-17-building-the-future-of-svelte-at-vercel

{% youtube https://www.youtube.com/watch?v=F1sSUDVoij4 %}

## Questions

1. I don’t know if this man needs an introduction, but can you give us a brief introduction and tell us a little about your previous work with Rollup and Svelte and your work at Vercel?
2. Where does Vercel fit in the future of Svelte?
3. What is the biggest difference in having a compiler vs the virtual dom?
4. How does declarative Svelte turn into efficient imperative code for the browser?
5. What do you envision is the next big thing for Svelte and SvelteKit?
6. What are your thoughts on where the web is going with islands architecture?
7. What are your thoughts on reactivity in Svelte, are there ways to improve on it similar to the SolidJS approach with more fine grained updating?
8. What do you think Svelte has to do to get more market share?
  1. How to get buy in on a team?
9. Do you think the State of JS and other surveys provide value for the community?
10. What is your favorite thing about the Svelte Community? 
  1. How many are on the core team?
  2. Move to GitHub Discussions
11. Shadow endpoints are a new for Svelte. What is the reasoning behind adding this and what are the benefits?
  * What about the proposal for an api layout wrapper? ‣
12. Do you think Svelte is the most beginner friendly framework?
  1. Do you think there is value in learning the fundamentals first?
How to use .ttf fonts with Tailwind CSS
Tags: tailwindcss, webdev, tutorial, css
Published: 2022-08-23 22:53:49

If you are a frontend developer, you might have face some problems while searching good and unique fonts. If you want to use some special fonts which are not available in [Google fonts](https://fonts.google.com/), but it is available in `.ttf` or `.woff` or any other formats like these. Then I will show you how to use these with **Tailwind CSS**.

I will show you step by step process for it. I have initialized a blank project on [NextJs](https://www.nextjs.org), So I am going to talk in reference to [NextJs](https://www.nextjs.org) folder structure but you can follow the same process for **any framework or for vanilla JS project**.

**Step 1**. Create a folder **font** (you can use any name) inside **styles** folder.
**Step 1**. Add the `.ttf` or `.woff` fonts inside the **font** folder.
**Step 3**. Create a new CSS file inside the **font** folder, I am creating stylesheet.css
**Step 4**. Now use `@font-face` CSS rule which allows us to import our own font in CSS.
```CSS
@font-face{
	font-family: 'Pixellari'; // Write the name of your custom font.


	// Below you need to give the path of the font, If you have only one format no problem
	// but if you have more then one format, you can add all those, you just need to
	// separate these with commas.
	src: url('Pixellari.woff2') format('woff2'), url('Pixellari.woff') format('woff');
}
```
**Step 5**. Now you need to import the previous CSS file on your global CSS, in my case I need to import `stylesheet.css` to my `globals.css`
```CSS
@import url('./fonts/stylesheet.css');
```
**Step 6**. Now lastly, you need to inform `tailwind CSS` that you need to extend a font-family, So for this you need add a few lines in `tailwind.config.js`.
```javascript
module.exports = {
	//.... All the initial code
	theme: {
		extend: {
			fontFamily: {
				'pixellari' : ['Pixellari', 'sans-serif'],  // after you font, add some fonts separated by commas to handle fallback.
			}
		}
	}
	//.... All the initial code
}
```

Now you are good to go, you can now use font-pixellari property in your `html class` or `jsx className`.

### Thanks for your time
Hope you like this blog, and it add some value to your skills. Feel free to connect with me on [Twitter](https://www.twitter.com/shubhamku044) or [LinkedIn](https://www.linkedin.com/in/shubhamku044).