Search code snippets, questions, articles...

A portal for programmers by programmers

Learn something new everyday and share your knowledge

Programming Feeds

Get random value from an array in PHP

Devsheet / June 25, 2022

When working with PHP, sometimes you need to get a random value from an array. This can be easily accomplished with the array_rand() function. We will show multiple methods in this post that can be used to get the random item from an array.

Run a Javascript file in Terminal window

Devsheet / June 24, 2022

In order to run a Javascript file in a Terminal window, the file must first be saved with a ".js" extension. Then, the file can be run using the command "node filename.js".

Demo1122

uditkumar / June 23, 2022

test

Select specific columns from a Pandas DataFrame

Devsheet / June 23, 2022

This Pandas tutorial will show you how to select two columns from a DataFrame. You can select columns by their name or by their index.

Close all excel process using C#

Devsheet / June 21, 2022

The code can be used to close all the excel processes running using C# code.

Add new row to an existing Pandas DataFrame

Devsheet / June 21, 2022

If you have a pandas DataFrame and want to add a new row, there are various ways to do this. You can use the append method to add a new row to the end of the DataFrame. You can also use the insert method to add a new row at a specific index. If you want to add multiple rows at once, you can use the extend method.

h

nitesh / June 17, 2022

Dependency

tijl.de.ridder7F42 / June 12, 2022

validation dependency

Get text before @ in an email using Javascript

Devsheet / June 12, 2022

Before we get into how to get the text before the @ in an email using Javascript, it's important to understand what an email address is. An email address is made up of two parts: the username and the domain. The username is the part of the email address that comes before the @ symbol, and the domain is the part that comes after. So, how can we get the text before the @ in an email using Javascript? The answer is quite simple. We can use the indexOf() method to find the position of the @ symbol in the email address, and then use the substring() method to get the text before it.

Change column values condition based in Pandas DataFrame

Devsheet / June 11, 2022

A Pandas DataFrame is a two-dimensional data structure that can store data of many different types. In a Pandas DataFrame, each column can have a different data type, and you can change the values in a column based on a condition. In this post, we will describe the methods that can be used to change column values of a Pandas DataFrame based on a condition.

Replace DataFrame column values with a specific value

Devsheet / June 11, 2022

A DataFrame is a two-dimensional array with labeled axes (rows and columns). We can replace the values of one or more columns in a DataFrame with a specific value. In this post, we will explain multiple methods in order to do that.

Check if a substring exists in a list of strings Python

Devsheet / June 9, 2022

A substring is a string that is a part of a larger string. A string is a sequence of characters. A substring may occur multiple times within a string. In this post, we will explain multiple methods to check if a substring exists in a list of strings using Python code examples.

Count NaN values in a Pandas DataFrame

Devsheet / June 8, 2022

A DataFrame is a two-dimensional data structure, i.e., data is aligned in a tabular fashion in rows and columns. Each row has a unique identifier called an index. A DataFrame can have multiple columns, each of which can hold a different type of data. NaN, or "Not a Number", is a numeric data type that is used to represent missing data. NaN values are often generated when data is missing, or when there is an error in the data.

Extract integer values from a string in Python

Devsheet / June 6, 2022

If you have a string that contains numbers and you want to get those numbers out, you can use the Python built-in functions int(), isdigit() to extract the integer values from the string. In this post, we will show you multiple methods to do that.

Get first n words from a string in Python

Devsheet / June 4, 2022

If you're working with strings in Python, there may be times when you need to get only the first n words from a string. This can be easily done with a few lines of Python code. In this article, we'll show you how to get the first n words from a string in Python.

Check if a list exists in a list of lists Python

Devsheet / May 31, 2022

A list of lists is a data structure that stores an ordered collection of items, where each item is a list itself. This is a powerful way to store data in Python, but it can be tricky to work with if you're not familiar with it. In this article, we'll show you how to check if a list exists in a list of lists, and how to access it if it does.

Check if item exists in a list using python

Devsheet / May 31, 2022

Python is a programming language with many features and functions. One such function is the ability to check if an item exists in a list. In this post we will explain multiple methods that can be used to check whether an element exists in a list or not.

SQL Server query to add auto increment field

Devsheet / May 30, 2022

If you're working with a SQL Server database, you may need to add an auto increment field at some point. This can be done using a simple query. In this article, we'll show you how to add an auto increment field to a SQL Server table using a query.

Get column values as list in Pandas DataFrame

Devsheet / May 29, 2022

If you have a Pandas DataFrame and want to get a list of the values in a column, it is easy to do by using the column name as an index. For example, given a DataFrame with a column "column_name", you can get a list of the values in that column like this: df['column_name'].tolist()

Get integer only values from a list in Python

Devsheet / May 28, 2022

If you have a list in Python that contains both integer and non-integer values, and you want to create a new list that contains only the integer values, there are a few ways you can do this. One way is to use a list comprehension, which is a powerful tool for creating lists based on other lists. Another way is to use the built-in function isinstance(), which allows you to check if a value is an integer.

Dismiss the mobile screen keyboard in Flutter

Devsheet / May 26, 2022

The mobile screen keyboard is necessary for many users who need to type on their phone or tablet. However, there are times when the keyboard is just in the way and needs to be dismissed. This can be accomplished in Flutter by using the FocusManager.

How to get current date in Flutter [Dart]

Devsheet / May 26, 2022

In this tutorial, we'll show you how to get the current date in Flutter using the DateTime class. We'll also show you how to format the date and time to your liking.

Loop through an object using map in React

Devsheet / May 26, 2022

When working with data in React, there may be times when you need to loop through an object in order to render a component for each key-value pair. In this article, we'll look at how to do that using the built-in map() function.

Get current date in Python (Multiple Formats)

Devsheet / May 25, 2022

Python is a versatile language that you can use to complete many different programming tasks. In this article, you'll learn how to get the current date and time in Python in various formats. You'll also see how to use the datetime module to work with dates and times in Python.

Assign different colors to each bar of a bar chart in Chart.js

Devsheet / May 23, 2022

A bar chart is a graphical representation of data that uses bars to represent different values. Bar charts are a popular way to visualize data, and Chart.js is a JavaScript library that makes it easy to create bar charts in web browsers. One common way to customize bar charts is to assign different colors to each bar. This can help to highlight different data values or to group related data values together. In Chart.js, there are a few different ways to accomplish this.

How to send form data in $.post jQuery

Devsheet / May 22, 2022

When using the jQuery $.post() method, one can send form data to a server without reloading the current page. This is done by serializing the form data and sending it as an argument to the $.post() method.

MySQL Query to change column type

Devsheet / May 22, 2022

If you want to change the data type of a column in a MySQL table, you need to use the ALTER TABLE statement. To do this, you need to specify the name of the table, the name of the column, and the new data type for that column. For example, if you want to change the data type of the column username to VARCHAR(255), you would use the following statement:

Javascript function to get cookie value by name

Devsheet / May 20, 2022

A function to get cookie value by name would be extremely useful for web developers who want to create dynamic web pages. By being able to access the value of a cookie, developers can store user preferences or track user behavior.

Remove all cookies from the current website using Javascript

Devsheet / May 14, 2022

Cookies are small pieces of data that are stored on a user's computer when they visit a website. Cookies can be used to store information about a user's preferences or to track a user's activity on a website.

Assign a Javascript variable to PHP variable

Devsheet / May 8, 2022

When working with PHP and JavaScript together, there are times when you need to pass values from JavaScript to PHP. This can be done by assigning a JavaScript variable to a PHP variable. In this post, We will explain different methods to do that.

Loading more...