fabiochiu/medium-articles huggingface dataset:
CS371g Fall 2020 Week 11: Siddhesh Krishnan
By: Siddhesh Krishnan
Tags: Careers, Students, Object Oriented, Internships, Software Development

That’s me!

What did you do this past week?

This past week I completed the Darwin project.This was a great project for us to learn more about classes as well as how to have good Object-Oriented design when it comes to creating something such as Darwin. I was also able to learn more about vectors in C++ as well.

What’s in your way?

There isn’t anything in my way right now! We only have the final project left, so I will be sure to look out for that and start to find a partner for this final project. So, as of now, there is nothing else in my way!

What will you do next week?

Next week, I continue to solidify my understanding of vectors as well as start to find a partner for the final project. In other worlds, I will continue to work on assignments for my other classes as well as work on refining my schedule for next semester!

If you read it, what did you think of The Dependency Inversion Principle?

This reading was extremely interesting! It was nice to see the the various cases how abstract classes or interfaces could be used in different methods and how they can be extremely helpful in making code more modular and reusable. I will be sure to translate the concepts which I have learned in this reading to my coding style in the future!

What was your experience of continuing to implement std::vector, move semantics, and allocators again? (this question will vary, week to week)

The process of implementing std::vector has been fairly ok so far. Not being familiar with C++ or the basic functionality of the class. Given this, I have never been exposed to move semantics as well, so there is a learning curve. However, I am sure that rewatching lectures as well as doing the supplemental HackerRank exercises will help me. Having learned allocators in CS 429, I am pretty familiar with that concept.

What made you happy this week?

This week, I was able to complete most of my work and catch up on most of my classes! Moreover, I was able to register for my classes this week and I got most of the classes which I hoped for!

What’s your pick-of-the-week or tip-of-the-week?

My tip-of-the-week this week would be AWS! AWS is a very dynamic in the fact that they allow for data storage, app hosting, as well as have GPU clusters. They do, however, only offer their services for a price. I hope y’all check it out !
Code Smell 18 — Static Functions. Yet another global access coupled with…
By: Maximiliano Contieri
Tags: Programming, Object Oriented, Code Smells, Object Oriented Design, Software Development

Code Smell 18 — Static Functions

Photo by Alex Azabache on Unsplash

Problems

Coupling

Testability

Protocol Overloading

Cohesion

Solutions

Class Single Responsibility Principle is to create instance. Honor it. Delegate method to instance. Create stateless objects. Don’t call them helpers.

Examples

Static class methods

Static attributes

Sample Code

Wrong

Right

Detection

We can enforce a policy to avoid static methods (all class methods but constructors).

Tags

Global

Libraries

Conclusion

Class are globals disguised. Polluting their protocol with “library methods” breaks cohesion and generates coupling. We should extract static with refactorings.

In most languages we cannot manipulate classes and use them polymorphically, so we can’t mock them or plug them on tests.

Therefore, we have a global reference too difficult too decouple.

Relations

Singleton

More info
JavaScript Objects and it’s Internal Representation.
By: Abhishek Aligh
Tags: Programming, Self Improvement, JavaScript, Object Oriented, Web Development

JavaScript objects are key-value pairs eclosed between {}, where the key is essentially a string and the value could be of any type. Objects are standalone entities imitating the real-life objects such as a dog, a car etc.

For example, a dog object can be represented in JavaScript as:

let dog={‘name’: ‘Rambo’, ‘colour’: ‘brown’, age: ‘2’, }

Creating an object

JavaScript objects can be created by using {}

To create an object for let’s say an employee follow along

To create an empty object

var employee={ }

To add values to the employee object you could add the comma-seperated key-value pairs or use the ‘[]’ notation to add a key-value pair

employee={ name: “Olivia Culpo”, age: 25, employee_id=’NEZ-123', location: ‘Banglore’}

employee[‘salary’]= “$120k p.a”

We can see the new property “salary” was added to the employee object.

To access a particular property we can use either ‘[]’ notation or ‘.’ notation.
Building iterable object using python
By: Sushrut Ashtikar
Tags: Class, Object Oriented, Python3, Objects, Python

Photo by Clément H on Unsplash

Building an iterable object from scratch is easy in python, in this tutorial you will be able to learn how iterator works. We will be building a custom floating range functioning class which will return a sequence of floating numbers, similar to the range() function in python which returns an integer sequence.

The range() function in python returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and stops before a specified number.

In order to build a custom iterable object, your class should contain two functions __iter__() and __next__() , together they are called iterator protocol.

Most built-in types in python like list , tuple and string etc are iterable objects, which means they can be looped until the last element.

Let’s code

We will start by defining a simple python class which will include iter and next method.

Now that we are ready with our basic skeleton, let's add functionality to it. Starting with __init__() which is indeed constructor. For any given sequence all we need is starting and ending value.

def __init__(self, start=None, stop=None, decimal=0):

if start is None:

raise TypeError('floatingrange expected 1 argument, got 0')

if stop:

self.start = float(start)

self.stop = float(stop)

else:

self.start = 0.0

self.stop = float(start)



if decimal < 2:

self.decimal = 1

self.dp = 0.1 / 1

else:

self.decimal = decimal

self.dp = 0.1 / float('1' + ('0' * (self.decimal - 1)))

Since it's a range, if there is no starting value then the default value will be considered as 0.0, also we have a decimal point value specified through which we can break down our range.

Understand the decimal logic

If decimal point value is not specified, then by default we will split our range up to 1 decimal point, x.0 to y.1 where x is the starting value and y is ending value.

If decimal value is 2, the sequence breakdown will be from .01 to .99, likewise it will increase with increase in value.

Now that we have initialized our range, we need to tell our interpreter to initialize our object as an iterator, for that we need to modify our __iter__() function.

def __iter__(self):

return self

Now that we have an iterator object initialized, we need to specify a new value on every next iteration. For that, we need to modify our __next__() function.

def __next__(self):

if self.start < self.stop:

val = self.start + self.dp

self.start = val

return "{0:.{1}f}".format(val,self.decimal)

else:

raise StopIteration('Reached end of the value')

So, now each time we call a next() function with our object or just iterate it through a loop, it will increment and return a new value until the final value of the sequence.

Combining all functionality

Now that we have built an iterable object, let's see how it works.

That’s all folks
Why Encapsulation?
Tags: Java, Oops Concepts, Encapsulation, Object Oriented, Clean Code

First of all, If you didn't read my article “Why OOPS?” check out that one to have good continuity.

Today we are gonna learn about Encapsulation.

Encapsulation is one of the four principles of OOPS.

So, what is Encapsulation?

Encapsulation is just hiding the variables(properties) and functions(methods) of the same entity behind a Class. Those properties and methods can only be accessed by its object.

So, Why to hide those?

If we didn’t hide those, then any other variables or functions can able to access or change the data.

Ok, let’s see what was the real problem solved by encapsulation.

Scenario:

Let’s consider we need to process some data of a mom and her son.

For mom, we need to have her name, age, present month’s income one, present month’s income two, total savings, and the function which calculates the sum of the total amount she has.

For her son, we need to have his name, age, grade, math score, physics score, and the function which gives the total marks he scored.

Let’s solve this problem

Without Encapsulation

With Encapsulation

I’m using java to demonstrate these scenarios.

Without Encapsulation:

Hey Bharath, It seems like everything is clean and well organized. What’s the problem here?

Problem One:

Accidentally/Willingly accessing the wrong function.

Guess what will happen if son accidentally passed mathScore and physicsScore to the function “sum”, he will get 10574 as the total mark.

Guess what will happen if mom accidentally passed incomeOne and incomeTwo to the function “total”.(“This Little Maneuver’s Gonna Cost her 51 Years”😂)

Problem Two:

Your mom can access your score😱 just by calling the mathScore or physicsScore variable.

Ok Bharath, I got it. I won’t ask any other question 🤐. Just tell me how to hide.

Problem Three:

Caution: The stunt I’m gonna share is very dangerous and potentially fatal! Do not attempt this stunt without proper training!

Son can able to change his scores.(I never did that😁)

Here comes the Encapsulation part.

With Encapsulation:

Solution for problem one:

Encapsulation hides the variables and functions behind its object. Thus they cannot be accessed accidentally/willingly.

Solution for problem two:

No one can able to access your properties.

Solution for problem three:

It can even be secured with private properties and accessing them using getters. So that even the son cannot change the scores once assigned.

Bravo! We did it.

Thanks for your support guys!

return;
Abstraction ,Abstract Classes, Abstract Methods & Interfaces in Programming
Tags: Java, Basics, Object Oriented, Programming

Hi Readers!😍

First Lets see what is Abstraction.

Data abstraction is the process of hiding certain details

and showing only essential information to the user.

Abstraction can be achieved with either abstract

classes or interfaces. Inside abstract classes we can implement abstract methods.

Encapsulation vs Data Abstraction.

Encapsulation(getters and setters) is data hiding(information hiding) while Abstraction is detail hiding(implementation hiding). While encapsulation groups together data and methods that act upon the data, data abstraction deals with exposing the interface to the user and hiding the details of implementation.

Abstract Classes & Methods.

●If a class has at least one abstract method, then the class must be declared abstract. ● If a class is declared abstract, it cannot be instantiated.(objects cannot be made).

Using Abstract Class and Abstract methods
Internal representation of objects in JavaScript
By: Sushmitha Vootukuri
Tags: JavaScript, Object Oriented, Javascript Development, Objects, Web Development

In JavaScript, an object is a collection of properties that are defined as a key-value pair, where the key is the generic name of the object feature which can be assigned a value. Don’t confuse this object with class objects, where we define a class and then create an object for it.

JavaScript Native Objects

JavaScript has several built-in or native objects. These objects are accessible anywhere in your program and will work the same way in any browser running in any operating system.

Few JavaScript Native Objects are Number Object, Boolean Object, String Object, Array Object, Date Object.

typeof method returns the data type of its arguement.

In JavaScript, an object is a standalone entity where the properties of the object define the characteristics of the object.

For example if we consider Car as an object, its properties are weight and color, and methods are start and stop.

The property of an object is a key : value pair, where key refers to a variable, and value refers to any type of value associated with the key. The value can be of any type like a number, string, or even an array, or another object.

We can create an object in JavaScript either by using the constructor function or the object literal.

Creating a JavaScript Object Using Object Literal Syntax

To create an object using object literal syntax, we use curly brackets { } . It is the preferred way and simpler way too. We can define properties of this object inside the curly brackets.

Basic Javascript object representation

Accessing properties of an object

Properties of an object are accessed either by dot operator or square bracket notation.

Adding new method to existing object
Why OOPS?
Tags: Java, Oops Concepts, Object Oriented, Clean Code, Object Oriented Design

I like to divide this article into two parts.

Without OOPS

With OOPS

For easy understanding, I write the code snippets in java.

Scenario:

What if we have to process a large number of student’s details?

The details include their name, class, section, rank.

Without OOPS:

Without OOPS means obviously no classes. Then what do we got?

Primitive data types include:

Byte

Short

Int

Long

Float

Double

Boolean

Char

Non-Primitive data types include:

String

Array

Classes ( I’ll come back to this later)

In order to store the Name, String must be the best option.

For Class, we can also use String.

For Section, we can use Char.

For Rank, we can use Int.

For Simplicity's sake, we consider there are only 3 students.

In order to store data of 3 students we need

Pros:

You can call HTML as a programming language. (😂😂😂)

Cons:
4 important part of JavaScript must read for the beginners
By: Rawhatur Rabbi
Tags: Function, Array, Object Oriented, Javscript, String

If you are a beginner of JavaScript and have a minimum knowledge about programming language, this article is going to more easy and understandable for you. So lets Start.

JavaScript has a little difference from other programming languages. It has no concept of input or output. Basically, JavaScript’s mechanism is designed to run as a scripting language in host environment(browser). Its syntax and structure is inspired from Java and C.

JavaScript is also known as multi-paradigm and dynamic language. It also contain types, operators, built-in objects, methods like other languages.

Now we can start the 10 important parts of JavaScript.

Variable

In JavaScript, variables are declared as let, const and var.

Firstly, we will talk about ‘let’ variable. It is used as a block-level variable. that means it is accessible from a block. for example:

// here variable i is initialized as let

//i is not visible out here for (let i = 0; i < 5; i++) {

// i is only visible in here

}



// i is not visible out here

Now lets talk about ‘const’. const have come from constant, which means never change.

const K = 8; // you can not change it

k = 1; // here you got an error because you cannot change a constant variable.

Lastly, ‘var’ is the oldest variable type. basically using var you can access it from everywhere.

// here variable i is initialized as var

//i is visible out here for (let i = 0; i < 5; i++) {

// i is visible in here

}



// i is visible out here

2. Operator

JavaScript has operators like other language have. + , - , * , / and %.

there are some operator which uses for comparison < , > , <= and >=. In JavaScript there is a simple difference. between == and ===. I will explain with an example:

555 == '555'; // true

0 == false; // true 555 === '555'; // false

0 == false; // false

3. Strings

Strings in JavaScript are successions of Unicode characters. String is sequences of UTF-16 code units, each unit is represented by a 16-bit number.

There are some built-in method in string like length, charAt, replace, toUpperCase etc. Lets see some example:

'javascript'.length; // 10

'hello'.charAt(0); // "j"

'hello, javascript'.replace('javascript', 'java'); // "hello, java"

'javascript'.toUpperCase(); // "JAVASCRIPT"

4. Number

Numbers in JavaScript follows “Double-precision 64-bit format IEEE 754 values”.

0.1 + 0.2 == 0.30000000000000004;

There are some build in function that give us some interesting output like sin, PI, parseInt, parseFloat, isNaN. Lets have a look some example:

Math.sin(3.5);

parseInt('123', 10); // 123

parseInt('010', 10); // 10

isNaN(NaN); // true

here sin function gives us the value of sin and parseInt function makes a string to binary, octal , decimal or any number system.

these are the important things which are must for the beginners.
[Programming!] Class??Object??…new!
By: 陳芃諭 Bonnie Chen
Tags: Programming, Java, Program, Object Oriented, Programming Languages

When discussed about object-oriented language, class and object are often mentioned. The relationship between class and object, making me feel like

bread form and bread 😆.

Take one sample written with Java for example.

From this picture, we can see that there are a Car class and a carObject. The car class just like the bread form, and we can instantiate/create the car object using new key word, thus the car object would have some properties and methods which we define in the Car class.

In the right side of the picture, the carObject has two variables, color and wheels. Moreover, in the line 19, the carObject could call run method, which to perform its method, and the result of performing the method is in the console.

Therefore, isn’t the relationship of bread form and bread like the relationship of class and object? 😏

Also, the new keyword is important to the class and object!
Hashing — A JAVA Secret Agent?
By: Pushpal Nandi
Tags: Java, Hashing, Object Oriented, Hashing Algorithm, Hash

Well, Hashing is a word with many meanings. Interesting to know that quite a few among the 43mil. people using this classic language JAVA may be very familiar with one of the most basic concept of object creations within the JVM i.e. Hashing.

Java Logo

Interesting to note every object ever created in the JAVA world gets consequently represented into a result of a function called implicitly, known as the Hash Function or hashCode(). The method is very well placed within the ultimate superclass i.e. Object class and returns an integer value.

For every inbuilt JAVA class there is a different implementation of this method and fair to say the respective method return a possible unique identification to

Representation of how hashing works?

any object created within the JVM. It is recommended that a user class should also implement or override the default method and try to provide a possible unique value every time in order to gain unique identity, or else the default implementation from the object class gets called which may or may not suit best for all cases.

Incase you were not aware of the above facts about this mechanism but still have been avidly using JAVA everyday, very well proves — Hashing is indeed a JAVA secret agent.
Building a MySQL Database Driver in Elixir
Tags: MySQL, Erlang, Elixir, Beam

Have you ever wondered what happens beneath the covers when you talk to your Database? Well, you are in for a treat! In this talk, we are going to uncover the dark magic behind Database Drivers. We will look at everything that is needed to talk to a database, query its data, and transform it into the native data types in Elixir.

https://speakerdeck.com/maqbool/building-a-mysql-database-driver-in-elixir
How to install Mysql Database Server on Redhat Linux
Tags: MySQL, Install Mysql, Mysql Server, How To Install Mysql, Mysql 8

In this article, I’m going to show you how to Install MySQL Database Server step by step on Redhat Linux.

For the MySQL database installation, we have required MySQL rpm files. You can find out these rpm files from your OS CD or from your YUM repository.

If the YUM server not configured on your machine, click here and check how to configure the yum server.

Install MySQL Database Server

For RHEL 5 and 6 use the following command as the root user.

#yum install mysql-server mysql

For RHEL 3 and 4 use the following command as the root user.

#up2date mysql-server mysql

How to start the MySQL server

After installing the above rpm start the MySQL servers using the following commands.

#chkconfig mysqld on

#/etc/init.d/mysqld start

Now make a password for root user of MySQL using following command.

#mysqladmin -u root password yourpassword

Now check the Mysql connection using the following command.

# mysql -u root -p

Now we need to configure MySQL Server, add the following settings in “/etc/my.cnf” file, you must remember the following values are sample values, set them as per your requirements.

#mysql settings

query_cache_type = 1

query_cache_limit = 1M

query_cache_size = 32M # For MyISAM buffer size and recover options

key_buffer_size = 24M

myisam_recover = FORCE,BACKUP # LOGGINGS for slow query

log_queries_not_using_indexes = 1

slow_query_log = 1

slow_query_log_file = /var/lib/mysql/mysqld-slow-query.log #cache and other limits tmp_table_size = 32M

max_heap_table_size = 32M

max_connections = 500

thread_cache_size = 50

open_files_limit = 65535

table_definition_cache = 4096

table_open_cache = 512

Save the above file and restart or reload the MySQL service using following commands.

#/sbin/service mysqld restart OR #/sbin/service mysqld reload

Create Database and check it using following command.

#mysql -u root -p

mysql> create database ocpgroup;

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| ocpgroup |

| test |

+--------------------+

4 rows in set (0.00 sec)

If you enjoyed this article, Please write in comment box about this article.
新卒2年目が業務の生産性を95%改善した話し
Tags: Java, Performance Tuning, Advent Calendar, MySQL

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Maximum Number of Columns Per Table — Mysql
By: Suresh Kamrushi
Tags: MySQL

Maximum we can have 4096 columns per table, but exact limit depends on several factors, listed below:

1) Every table has a maximum row size of 65,535 bytes. This maximum applies to all storage engines, but a given engine might have additional constraints that result in a lower effective maximum row size.

The maximum row size constrains the number of columns because the total width of all columns cannot exceed this size. For example, “ utf8 " characters require up to three bytes per character, so for CHAR(255) CHARACTER SET utf8 column, the server must allocate 255 X 3 = 765 bytes per value. Consequently, a table cannot contain more than 65,535 / 765 = 85 such columns.

2) Each table has an “ .frm" file that contains the table definition. The server uses the following expression to check some of the table information stored in the file against an upper limit of 64KB:

if (info_length+(ulong) create_fields.elements*FCOMP+288+

n_length+int_length+com_length > 65535L || int_count > 255)

The portion of the information stored in the .frm file that is checked against the expression cannot grow beyond the 64KB limit, so if the table definition reaches this size, no more columns can be added.

The relevant factors in the expression are:

info_length is space needed for "screens" This is related to MySQL's Unireg heritage. create_fields.elements is the number of columns. FCOMP is 17. n_length is the total length of all column names, including one byte per name as a separator. int_length is related to the list of values for ENUM and SET columns. com_length is the total length of column and table comments.

Thus, using long column names can reduce the maximum number of columns, as can the inclusion of ENUM or SET columns, or use of column or table comments.

3) Individual storage engines might impose additional restrictions that limit table column count. Examples:

info_length is space needed for "screens" This is related to MySQL's Unireg heritage. create_fields.elements is the number of columns. FCOMP is 17. n_length is the total length of all column names, including one byte per name as a separator. int_length is related to the list of values for ENUM and SET columns. com_length is the total length of column and table comments.

For more information: MySql

Source : http://sforsuresh.in/maximum-number-of-columns-per-table-mysql
Reset MySQL Root Password on MAC
Tags: MySQL, Passwords

MySQL verison: 8.0.22

Step1. Stop MySQL Server

Make sure the status of MySQL Server located in macOS System Preferences Panel is in red(means stopped). If it is in green(means running)，you must top it by clicking the ‘Stop MySQL Server’ button.

Green means the MySQL Server is running

*If Stop MySQL Server has no response, try:

/usr/local/mysql/support-files/mysql.server stop

Now, the MySQL Server has stopped

Step2. Skip grant tables in Terminal

cd /usr/local/mysql/bin sudo ./mysqld_safe --skip-grant-tables

Input system password, not MySQL’s.

Step3. Alter root password in Terminal

Open another terminal window,

cd /usr/local/mysql/bin ./mysql -u root mysql> FLUSH PRIVILEGES; mysql> ALTER USER 'root'@'localhost' IDENTIFIED by 'new_password';

If it occurs errors like :

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

We need to adjust the values of the password policy and length.

The new version MySQL doesn’t support the password function anymore. Instead of using ‘validate_password_policy’, you should imply ‘validate_password.policy’.

“The validate_password.policy value can be specified using numeric values 0, 1, 2, or the corresponding symbolic values LOW , MEDIUM , STRONG . The following table describes the tests performed for each policy. For the length test, the required length is the value of the validate_password.length system variable. Similarly, the required values for the other tests are given by other validate_password.xxx variables.”

For example,

#set password level

mysql> set global validate_password.policy=0; #set password length

mysql> set global validate_password.length=1;

Then, you can set the new password.

Other, ways to start, stop, and restart MySQL database server via the command line:
Accessing remote MySql server using local PhpMyAdmin
By: Suresh Kamrushi
Tags: MySQL, Phpmyadmin

How to access remote MySql server using local PhpMyAdmin

It is very tedious to connect your remote mysql box especially when you are working with VPN. Initially I used telnet to connect to mysql box than I try to use workbench. Workbench is good and better than using telnet but again it consume more memory and if VPN got disconnected it just hanged. It so irritating. Than I try to configure my PHPMyAdmin to access remote mysql server and it is really very easy to setup. Just you need to configure/modify a single file in PHPMyAdmin folder i.e. “ config.inc.php”.

Just add below lines to your “config.inc.php” file add the bottom:

//provide hostname and port if other than default$i++; $cfg['Servers'][$i]['host'] = 'HostName:port';

//user name for your remote server

$cfg['Servers'][$i]['user'] = 'userName';

$cfg['Servers'][$i]['password'] = 'Password'; //password $cfg['Servers'][$i]['auth_type'] = 'config'; // keep it as config

If your mysql server is in remote than make sure that you are very much connected to box and than try to access PHPMyAdmin using url. You will get “Current Server” drop down with both “127.0.0.1” and one what you have provided with “$cfg[‘Servers’][$i][‘host’]”. You can switch between the servers by selecting the server “Current server” dropdown.

My PHPMyAdmin version: 4.0.4.1

My MySql Version: 5.5
How to delete sleeping processes in Mysql
By: Suresh Kamrushi
Tags: MySQL

Whenever a new query executed, a fresh process start and once the query is completed process should be end but many times application does not clean up their connection after end of process and hence process goes to sleeping mode. MySql will clean up such process as per the configurable value of “wait_timeout” . Default value of “wait_timeout” is “28800”.

SHOW VARIABLES LIKE 'wait_timeout'

Sleeping states of Mysql process does not harm anything unless it is in thousands. Even if you want to remove it manually you can do like this: login to Mysql as admin using command prompt:

mysql -uroot -ppassword;

And than run below command:

mysql> show processlist;

You will get something like below :

+----+-------------+--------------------+----------+---------+------+-------+------------------+

| Id | User | Host | db | Command | Time | State | Info |

+----+-------------+--------------------+----------+---------+------+-------+------------------+

| 49 | application | 192.168.44.1:51718 | XXXXXXXX | Sleep | 183 | | NULL ||

| 55 | application | 192.168.44.1:51769 | XXXXXXXX | Sleep | 148 | | NULL |

| 56 | application | 192.168.44.1:51770 | XXXXXXXX | Sleep | 148 | | NULL |

| 57 | application | 192.168.44.1:51771 | XXXXXXXX | Sleep | 148 | | NULL |

| 58 | application | 192.168.44.1:51968 | XXXXXXXX | Sleep | 11 | | NULL |

| 59 | root | localhost | NULL | Query | 0 | NULL | show processlist |

+----+-------------+--------------------+----------+---------+------+-------+------------------+

You will see complete details of different connections. Now you can kill the sleeping connection as below:

mysql> kill 52;

Query OK, 0 rows affected (0.00 sec)

Source : http://sforsuresh.in/how-to-delete-sleeping-processes-in-mysql
What is a MySQL Database? What is it used for?
By: Erin Skidds
Tags: Programming, MySQL, Wikipedia, Learning, Learning To Code

Photo by Luke Chesser on Unsplash

According to Wikipedia, “ MySQL is an open-source relational database management system. Its name is a combination of “My”, the name of co-founder Michael Widenius’s daughter, and “SQL”, the abbreviation for Structured Query Language. “ To put that in laymen’s terms, that means it is a system to store information so that you can grab and display it on your website.

These databases are not only used for websites, you can use them for Discord Bots, Applications, offline storage and more. You can think of databases as “the cloud”. The same place where you store your files like Google Drive, iCloud Drive, etc. Those are run by a version of database that stores your files so computers can read it. It is very complicated but to keep it simple, that’s what a database is and used for.

If you want to know more about MySQL you can go to their website here: https://www.mysql.com/
SQL Server joining cool syntax Club
By: Ganesh Chandrasekaran
Tags: MySQL, Rdbms, Database, Ansi Standards, Sql Server

Microsoft SQL Server is very powerful and popularly used but it lacked some simple features which existed in ANSI SQL like MySQL/PostgreSQL.

If you are wondering about what I’m talking, lets see this simple example.

Photo by Michael Dziedzic on Unsplash

Till SQL Server 2014, to check whether table “Actor” exists before dropping the table

-- Using OBJECT_ID function IF OBJECT_ID('dbo.Actor', 'u') IS NOT NULL DROP TABLE dbo.Actor;

-- Using sys.objects if EXISTS (SELECT * from sys.objects WHERE name = 'Actor' and type = 'u') DROP TABLE Actor;

From SQL Server 2016, we have the cool If Exists syntax.

DROP Table If Exists Actor;

This is simple and easy to remember and compatible with other leading RDBMS in market. Its not just for Table, works with anything with DROP.
Optimizing Wordpress Database
By: Code, Ev'Rything In Btwn
Tags: MySQL, WordPress, Optimize

in The Andela Way
Restore remote database backup to local
By: Massimo Caliman
Tags: MySQL, Python

PySysop https://github.com/mcaliman/PySysop is a Python system operations collection utilities, restore_remote_database.py is the script for create remote database dump, download and restore to localhost instance.

My project is work in progress. Stay tuned! Next implementation? What would you like me to add about?
The 6 Principles of Effective Data Visualization
By: Benedict Neo
Tags: Programming, MySQL, Data Visualization, Data Science, Data Analysis

The 6 Principles of Effective Data Visualization

Data visualization is an essential step in the data science process. It’s where you present your findings and communicate the results of your analysis in a graphical format that is both intuitive and easy to understand.

Data visualization takes hard work, and tons of cleaning and analysis go into distilling and manipulating messy data into beautiful graphs and charts. But even with data prepared, one still has to adhere to certain principles or methodologies to produce useful and informative graphics.

That said, in this article, I will be taking inspiration from Edward Tufte’s book Beautiful Evidence, which encapsulates six principles for how to make data graphics that are useful and informative. It’s these principles that separate useful graphics from those that aren’t.

This article is also largely inspired by Roger D. Peng’s book Exploratory Data Analysis in R. It’s available free on Bookdown, and you can read it to learn more about EDA.

Now let’s dive into the principles.
MySQL Installation to Ubuntu 20.04
By: Jan Brian Paul Ebora
Tags: MySQL, Ubuntu, Ubuntu 20 04, Mysql Server

Step 1 : Install the mysql server package.

sudo apt install mysql-server

Step 2 : Configure MySQL

sudo mysql_secure_installation

Step 2.1 : Select your Validation Policy Level — I chose 2

Step 2.2 : Enter your new password and re-type it.

Step 2.3 : The next step will give you the estimate strength of the password you chose. Simply type Y to proceed and it will remove anonymous user and test database.

Step 3 : Testing your MySQL.

To start your mysql run the command below.

sudo systemctl start mysql

Step 3.1 : Check if MySQL Server is running.

sudo systemctl status mysql

In addition you can check the current status using mysqladmin command. Just look at the Uptime.

sudo mysqladmin -p u root version

Note: root is the account you are using it may change if you create a new user.

All information I wrote here is based on how I understand it. Feel free to correct me and comment on your suggestions. Thanks for reading!
Reparar el servicio MySQL en Windows 10
By: David Raygoza Gómez
Tags: Programming, Windows 10, Español, MySQL

NSSM - the Non-Sucking Service Manager

nssm is a service helper which doesn't suck. srvany and other service helper programs suck because they don't handle…
Do we use a large table or multiple small tables in MySQL?
By: Chanaka Mannapperuma
Tags: MySQL, Query Performance, Database Administration

Recently we had an interesting discussion regarding the redesigning of our database. When we design a database, it is quite important to use the suitable tables, correct datatypes and proper indexing. However, finding the best design is almost impossible due to the complexity of data that have to be dealt with day-today projects. My biggest question was whether should we use one large table or multiple small tables to store network data inside our database. In order to find the answer to my question, I did execution time comparison by making one large table and one small table and then joining them with gene information table. I used identical number of columns and indexing for both large and small tables. Following picture shows the basic design of the MyISAM tables for both network and gene information.

Database design diagram for gene_info and network_single/network_many tables

The small table (network_single)contains 1655022 records belongs to one experiment and the large table (network_many) contains 5763305 records belongs to four experiments. Then I used following command to extract the number of records for 468 random gene IDs.

SET @GENES=”Potra2c131s34676,…”

select count(gene_info.gene_i) from network_many left JOIN gene_info on gene_info.gene_i= network_many.gene_i1 where FIND_IN_SET(gene_info.gene_id,@GENES) and network_many.dataset=”aspwood” union select count(gene_info.gene_i) from network_many left JOIN gene_info on gene_info.gene_i= network_many.gene_i2 where FIND_IN_SET(gene_info.gene_id,@GENES) and network_many.dataset=”aspwood”;

I got a small execution time when I use small table and here is the results.

To fetch data from large table took 154 seconds

To fetch data from small table took 3 seconds

In conclusion using multiple small tables makes the system much faster.
Cannot uninstall/repair/Change MySQL-Connector-net? Issue Resolved..
By: Gampa Ramya
Tags: MySQL, Uninstall Mysql, Uninstall Mysql Connector, Mysql Connector Net, Mysql Server

Are you facing an issue in uninstalling MySQL -Connector-net 8.0.22 or some other version ? Even I struggled a lot in resolving this issue.

MySQL is a popular database which is widely used for most of the applications. However, it’s installation may not be always smooth. So we may try to reinstall it after uninstalling . There are also other instances like where we want to update the version hence we require uninstalling. This uninstalling sometimes creates trouble .(Frankly, I don’t know the reason)

I tried these things to uninstall the MySQL-Connector-net:

Settings-> apps and features ->MySQL-Connector-net-> Remove/change/modify.

2. Search->Control panel->Add or remove program->MySQL-Connector-net->Uninstall/Repair/change.

Yet, None of the above solutions seemed to work. I was not even able to change or modify anything. Finally, I found something on the Internet which helped me to resolve this issue. You can also try. It may work.

Solution: Download windows install and uninstall troubleshooter. You can download it here.

=>Download link:https://support.microsoft.com/en-in/help/17588/windows-fix-problems-that-block-programs-being-installed-or-removed

=> Run the troubleshooter after installation.

=>Select Uninstalling when a question is displayed asking the area of trouble

=>Select MySQL-Connector-net from the list of programs displayed . click on next.

=>Windows will start detecting the problem and fixes the problem with uninstallation. The program will be uninstalled. (you can uninstall after the problem is fixed if it does not get uninstalled immediately).

This is how it worked for me. Hope it helps for you. Happy uninstalling !!!
No one cares
Tags: Programming, JavaScript, University, MySQL

You scroll through your old “impressive” repos and smile trying to neglect the thing you are working on just to go back and well, get frustrated again. It is a combination of old repos, the refrigerator, and just random thoughts that prevent you from working on the task in front of you. If you are one of these people, this is my advice to you.

No one cares

No one cares about your old repos. No one cares about what's in your fridge. No one cares about pretty much anything you do. People care more about themselves, not you. Don’t scroll through your old repos thinking you are some sort of God programmer because you’re not. If you keep doing that, you will stop yourself from learning more and you will be stuck in the same place for days, weeks, months maybe even years[very serious when I say this]. Enjoy struggling just as much as you enjoy your successes, and you will reach places you had thought you couldn’t. Good luck and this is entire post from my standpoint is more wasted time. I should not even post this but I am.
How to connect MySQL with Python?
By: Mayank Dixit
Tags: MySQL, Python Programming, Python, Data Science, Data Analysis

To connect MySQL with python, we need to install a connector. This connector can be installed using the command: pip install mysql-connector-python in the command line/Anaconda Prompt.

Now, since the MySQL connector has been installed, let’s jump to the IDE and import the package.

import mysql.connector

To establish the connection, we’ll perform the following operations :

Open MySQL Workbench after entering the credentials.

We then initialize the connection in the IDE, using mysql.connector.connect ( ).

Inside( ), we need to enter the hostname, user name, and password.

mydb = mysql.connector.connect(host=’localhost’,user=’root’,password=’123456789',use_pure = True)

Now, we need to check if the connection is established or not. This will return a Boolean, either True or False that tells us if the connection has been established or not.

mydb.is_connected()

Now since we know that we have an established connection, the next step is to query the database.
Backing Up Views with MySQL Dump
Tags: MySQL, Mysqldump, Linux, Bash Script

Here’s a full command line example using a bash script

mysql -u username INFORMATION_SCHEMA

--skip-column-names --batch

-e "select table_name from tables where table_type = 'VIEW'

and table_schema = 'database'"

| xargs mysqldump -u username database

> views.sql

This extracts all of the view names via a query to the INFORMATION_SCHEMA database, then pipes them to xargs to formulate a mysqldump command. — skip-column-names and — batch are needed to make the output xargs friendly. This command line might get too long if you have a lot of views, in which case you’d want to add some sort of additional filter to the select (e.g. look for all views starting with a given character).

Source: https://stackoverflow.com/questions/1658204/backing-up-views-with-mysql-dump
apache and mysql shutdown unexpectedly
By: Mahdi Ahmed
Tags: MySQL, Phpmyadmin, PHP, Xampp

mysql shutdown unexpectedly:

then i have face the other problem mysql shutdown unexpectedly port blocked , now this the one i have spent 2 hours on it so what i have done to solve this one:

first i try to change the port from 3306 to 8111 by going to xampp control panel and open config on mysql it’s open my.ini to me 😄 so and change it like so:

[client]

# password = your_password

port=8111

socket=”C:/xampp/mysql/mysql.sock”

==============================

# The MySQL server

default-character-set=utf8mb4

[mysqld]

port=8111

then i go to the xampp control panel and in upper right corner under config>>>services and port settings>>> under mysql: I change the port to 8111.

and unfortunately that’s not work for me 😒 so i try to change it to 3307 with the seam above steps and the mysql run just fine to me 😄

next i start apache and mysql no errors so far so good right 😄 then lets give it a test on chrome

open `localhost:81` then go to phpMyAdmin tap to see if mysql work or not then this happen :

Cannot connect: invalid settings.

mysqli_real_connect(): (HY000/2002): No connection could be made because the target machine actively refused it.

Connection for controluser as defined in your configuration failed.

mysqli_real_connect(): (HY000/2002): No connection could be made because the target machine actively refused it.

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

feels bad right 😒 now i feel so angry 😠 about this time to google it 🤓 i learn that you need to tell phpmyadmin about the changes you did on mysql port so you need to tell it what is the new port that you gave to mysql so in order to do that you need to open this file: `C:\xampp\phpMyAdmin\config.inc.php`

do some changes in this file change the following lins :

line 27:

from

$cfg[‘Servers’][$i][‘host’] = ‘127.0.0.1’;

to be

$cfg[‘Servers’][$i][‘host’] = ‘127.0.0.1:3307’;

line 30 just in case you have user permission problem :

from

$cfg[‘Servers’][$i][‘controluser’] = ‘pma’;

to be

$cfg[‘Servers’][$i][‘controluser’] = ‘root’;
Gezielte Ransomware Angriffe auf MySQL Server
By: Andre Fritsche
Tags: MySQL, German, Passwörter, Ransomware, Deutsch

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
MySQL down but it is running as mysqld_safe [MariaDB]
By: Kodeslogic Web Solutions
Tags: MySQL, Database, System Administration, Cpanel, Mariadb

Symptoms

The cPanel & WHM software reports MySQL is down:

/usr/local/cpanel/scripts/restartsrv_mysql — status

(XID l35tte) The “mysql” service is down.

But mysqld_safe is running:

# ps fauxww | grep mysq[l]

root 2141 0.0 1.2 223743 1592 ? S 23:23 1:00 /bin/sh /usr/bin/mysqld_safe — datadir=/var/lib/mysql — pid-file=/var/lib/mysql/srv01.hostname.tld.pid

mysql 2345 0.0 9.8 2316495 99519 ? Sl 23:31 0:01 \_ /usr/sbin/mysqld — basedir=/usr — datadir=/var/lib/mysql — plugin-dir=/usr/lib64/mysql/plugin — user=mysql — log-error=/var/lib/mysql/srv01.hostname.tld.err — open-files-limit=10000 — pid-file=/var/lib/mysql/$hostname.pid

Description

MariaDB versions below 10.4.4 and after 10.1.17 on EL7 systems are subject to a race condition between systemd and the init script they provide. This means that upon reboot, sometimes MySQL gets restarted with mysqld_safe when it never should.

The following upstream bug cases are related:

MDEV-10797

MDEV-11046

Workaround

Make sure that MariaDB is enabled with this command:

systemctl enable mariadb

Example:

# systemctl enable mariadb

Created symlink from /etc/systemd/system/mysql.service to /usr/lib/systemd/system/mariadb.service.

Created symlink from /etc/systemd/system/mysqld.service to /usr/lib/systemd/system/mariadb.service.

Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

Stop MySQL, then start it using the restartsrv script:

/usr/local/cpanel/scripts/restartsrv_mysql — stop

/usr/local/cpanel/scripts/restartsrv_mysql — start

Still not confident to apply the fix? You can reach Kodeslogic experts anytime to help you…