teleren/devto huggingface dataset:
Conexión a SQL Server con Python
Tags: database, sql, python, tutorial
Published: 2021-02-22 18:03:49

En esta ocasión quiero hablar sobre como accedes a un SQL Server usando Python. Estuve investigando un poco y la solución que encontré mas practica es `_mssql`.

`_mssql` es una librería de código abierto que de una forma simple y eficiente nos permite ingresar y modificar a bases de datos SQL utilizando Python.

---
## Conectarse a una base de datos SQL

El primer paso es muy sencillo, para crear la conexión primero importamos la librería `_mssql` y llamamos al método `.connect()`:

```py
import _mssql

server = 'SERVER_NAME'
user = 'USER_NAME'
password = '<PASSWORD>'
database = 'MY_DATABASE'
conn = _mssql.connect(server, user, password, database)

# aqui creamos una tabla de ejemplo

conn.execute_non_query('CREATE TABLE pets(id INT, name VARCHAR(100))')
conn.execute_non_query("INSERT INTO pets VALUES(1, 'Firulais')")
conn.execute_non_query("INSERT INTO pets VALUES(2, 'Pelusa')")
```

De esta forma ya deberíamos estar conectados a la base de datos SQL, pero ahora viene lo importante: poder utilizar estos datos a través de queries.

---

## Realizar Queries

Y para poder realizar queries y manipular la base de datos, debemos llamar al método `.execute_query()`. Aquí dejo un ejemplo:

```py
conn.execute_query('SELECT * FROM pets WHERE name=%s', 'Firulais')

# como extraer filas de una tabla
for row in conn:
    print "ID=%d, Name=%s" % (row['id'], row['name'])
```

---

> Dejo el [link](http://www.pymssql.org/_mssql_examples.html) a la documentación de esta librería. 

---

Van un par de ejemplos más de como realizar queries:
```py
# contar filas de una tabla
num_pets = conn.execute_scalar("SELECT COUNT(*) FROM pets")

# seleccionar segunda fila de determinada tabla
pet_2 = conn.execute_row("SELECT * FROM pets WHERE id=%d", 2)
```


## Cierre de la conexión

Una vez terminadas todas las tareas que se debían realizar con la base de datos, procedemos a cerrar la conexión con el SQL Server:

```py
conn.close()
```
> Este paso es importante para no desperdiciar recursos en tareas que ya han sido finalizadas o que ya no son necesarias 👍

---

# Conclusión

`_mssql` es una buena alternativa a `pyodbc` y `mymssql` ya que su sintaxis es mas simple para establecer la conexión con la base de datos y  también al momento de realizar queries.

Espero que mi aporte te haya sido de utilidad, y ¡hasta la próxima!
PowerShell Replace – How to Rename a File or Change a File Extension in Windows 10
Tags: tutorial, windows, powershell, renameitem
Published: 2021-02-22 17:52:57

Windows PowerShell is a Microsoft framework for automating tasks using a command line shell.

In this tutorial we will learn on how to change a file name or its extension using either the relative directory or absolute directory.

{% youtube zIlmKtBQBnc %}

Here is a short 3 minute video in which I walk through how to change a file name or its extension.

We will be using Rename-Item cmdlet. You can read more in the official docs [here](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/rename-item?view=powershell-7).

Using `Rename-Item` we can not only rename a file but also move it into different directories or even change registry names as well.

You can find some very good official examples on the PowerShell docs page [here](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/rename-item?view=powershell-7#examples).

So let's begin.

### How to rename a file

Open your PowerShell command line shell. Type in the following command:

```code
Rename-Item -LiteralPath "hello.xls" -NewName "bye.xls"
```

Rename-Item accepts two flags:

- LiteralPath is the file you want to rename 
- NewName is the new name of the file you want

### How to change a file extension

You can change the extension of a file similar to how you would rename it by simply doing this:

```code
Rename-Item -LiteralPath "hello.txt" -NewName "hello.docx"
```

If you found this useful drop a message to me on [twitter/adeelibr](https://twitter/adeelibr). 

Happy coding.
Class-less CSS frameworks
Tags: webdev, css
Published: 2021-02-22 17:36:53

The class-less (or no-class) CSS framework's promise is that as long as you have a valid HTML and structure your elements in a sane way, you will get a decent-looking page by including one stylesheet.

They are useful to put something online quickly. It can also serve as a starting point or as a temporary solution while you finish other aspects of your application or website.

Since they style only the general HTML elements (paragraphs, headings, buttons, etc.), you don't have to worry about adding their unique class names or removing them later.

Some class-less CSS frameworks have a distinct personality, like [Bahunya](https://kimeiga.github.io/bahunya/) or [YoRHa](https://metakirby5.github.io/yorha/). Others provide minimal styling, focusing on the spacing between elements and making things acceptable. The latter ones are an excellent choice for prototyping applications. The [Water.css](https://watercss.kognise.dev/) and [awsm.css](https://igoradamenko.github.io/awsm.css/)  seem to be good ones.

CSS-Tricks has [an article](https://css-tricks.com/no-class-css-frameworks/) where you can find some popular ones. Another place to find a curated list is the [Classless CSS](https://github.com/dbohdan/classless-css) repo.
Don't just write codes, solve problems.
Tags: javascript, webdev, programming
Published: 2021-02-22 15:22:22

You’ve gotten stuck so many times while coding. We all have. Some hard, nasty problem. Many conditions. Maybe this can be broken down into smaller problems. Maybe some dynamic programming could help. There must be some famous algorithm behind this.

 We’re programmers, so writing code is what we do, is it not ? As the title suggests, our job is a bit more complicated than stroking keys on a keyboard in front of a screen all day. If you go beyond programming languages, and frameworks and processes, beyond test suites and sprints and Jira tickets, you will always find a problem that needs to be solved. Let me say that we, as programmers, are, first and foremost, problem solvers. We take a problem that someone else has and, using all the tools at our disposal, produce a solution.

**Programmers seem to have forgotten the real purpose of software, that is to solve a real-world problem.** If developers become too narrowly focused on development, they can miss the purpose behind the software or program they write. They may not see hidden solutions that don’t require any code.

The best in their field are the ones who appreciate that there is always more to learn. Here are six steps to becoming a better programmer this year.

**Coding is an evolving discipline.**

Write code three times.
Writing code has been compared to writing a novel and,just like in novel writing, you should never tout your first draft as your finished product.

1. Practice a lot. (Get addicted)


2. Always try to get a solution which is most efficient for the problem Never compromise on complexity.

3. Start a day coding an easy problem. This will make you feel better.


4. Once you have given up. Understand the problem how much ever difficult it is.


5. Don't underestimate yourself.


6. Before you code, it would be better if you write down the algorithm and check if it is working for all test cases. It would be much much better if you could prove your algorithm.

*Solve logical puzzle,Write your own programmes, Develop projects for yourself in that language.*
*Practice and practice coding whenever you get time.*

**Stay more with good programmers, your teachers, mentors and gain or suck knowledge from them.**

HAPPY CODING!!
A Vite 2.0 Demo
Tags: javascript, vue
Published: 2021-02-22 17:33:24

Vite 2.0 is now available for general adoption. The Vite team has completely refactored the internals that now provides framework-agnostic features. 

{% link https://dev.to/yyx990803/announcing-vite-2-0-2f0a %}

## Demo

Watch Evan You (creator of Vue) and share a new breed of front-end build tools that significantly improve the front-end development experience. 

{% youtube UJypSr8IhKY %}

## Open Source Fridays

Come along to our Open Source Friday live streams. We go live on the [GitHub Twitch Channel](https://github.community/t/attended-making-twitch-bots-that-talk-to-the-github-api-let-s-chat/159453/2) most Fridays. Join the [Meetup Group](https://www.meetup.com/GitHub-Virtual-Meetup/) to stay up to date and see the topics each week.
Instale o Git no Xubuntu
Tags: linux, ubuntu, git, braziliandevs
Published: 2021-02-22 17:32:14

Olá pessoal, hoje iremos instalar o [Git](https://git-scm.com/), que é um sistema utilizado para permitir o versionamento de código distribuído, foi criado por [Linus Torvald](https://pt.wikipedia.org/wiki/Linus_Torvalds) para auxiliar no desenvolvimento do [Kernel Linux](https://www.kernel.org/). Neste tutorial, estarei utilizando o sistema operacional **Xubuntu 18.04** , mas os procedimentos funcionará em qualquer distribuição baseada no **Ubuntu**.

Para instalar a versão estável, utilize o comando a seguir:

```bash
sudo apt-get install git
```

Para instalar a versão mais recente utilize os três comandos abaixo:

1. Adicione o repositório PPA do Git:
    ```bash
    sudo add-apt-repository ppa:git-core/ppa
    ```
2. Atualize a lista de programas que podem ser instalados:
    ```bash
    sudo apt update
    ```
3. Instale a versão mais recente do Git:
    ```bash
    sudo apt install git
    ```

Para verificar se a instalação foi realizada com sucesso, verifique a versão do Git:

```bash
git --version
```

Hoje aprendemos como instalar o **Git**, valeu pessoal 😎✌!
Why you should use TypeScript in 2021?
Tags: typescript, javascript
Published: 2021-02-22 17:25:43

Hey Guys, In this video I will try to convince you to use Typescript for your next projects or migrate existing projects. I am going to cover couple of scenarios where JavaScript miss common issue which are very obvious. 

{% youtube BUSLmFVuY1U %}

I will show you how TypeScript can help in catching bugs early in development cycle and reduce complexity of application. TypeScript helps in not only catching code issues during compile time, it also helps in reducing the code.

Typescript types are very powerful feature that can minimize issues in your code
A Social Media Platform Where You Aren't The Product
Tags: social, privacy, discuss
Published: 2021-02-22 17:19:17

By now we all should have at least heard of the Netflix Movie "the social dilemma". In short, it's a documentary on how social media platforms like Twitter, Facebook, TikTok, Reddit and YouTube are optimized to be addictive, so that they can make more money, by showing us even more ads. 

> “If something's free then you aren't the customer, but the product."

So, what if there was a social media platform that you would have to pay for in order to use it?

According to [this](https://www.socialmediatoday.com/news/would-people-pay-to-use-social-media-platforms-to-avoid-data-sharing-info/575956/) article, people would be willing to pay up to 5$ a month to use facebook + instagram.

So the question is, do you believe it to be worth investing time and resources on building such a platform?

Here are my personal Pro's and Con's, I'll gladly add yours as well:

#### Pro's
+It's the goal of the Platform to connect you, not to get you addicted
+Content could not be regulated by advertisers.

#### Con's
-Hard to get paying userbase

## Final words
One last remark, this platform would only solve half of the problem. People could still get addicted, younger users might still define their self-worth by the amount of likes. But it would be a much more private platform than anything that exists at the time. If you have any interest in helping bootstrap such a site, please do leave a comment.
My Ansible Playbook for setup M1 Mac
Published: 2021-02-22 14:23:36

The other day, I bought an M1 Mac. The setup seemed to be a pain, so I made an Ansible Playbook so that I can easily recreate it later.

#### GitHub
https://github.com/katsuhisa91/m1mac-ansible


#### About Roles
|  roles  |  about  |
| ---- | ---- |
|  prezto  |  Prezto is the configuration framework for Zsh. https://github.com/sorin-ionescu/prezto  |
|  dotfiles  |  This is my dot files. https://github.com/katsuhisa91/dotfiles  |
|  rustup  |  Install Rust by rustup for my favorite command. https://github.com/rust-lang/rustup/blob/master/doc/src/installation/index.md#installing-nightly  |
|  command  |  This is my favorite command.  |

## How to execute

### 1. Install xcode command line tools

```zsh
xcode-select --install
```

### 2. Install Homebrew

Follow the steps below and you should be able to install it without any problems.

https://docs.brew.sh/Installation

> This script installs Homebrew to its preferred prefix (/usr/local for macOS Intel, /opt/homebrew for Apple Silicon) so that you don’t need sudo when you brew install.

```zsh
cd /opt
sudo mkdir homebrew
sudo chown $USER homebrew
sudo chgrp admin homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
```

### 3. Set PATH for M1 Mac brew

```zsh
export PATH="/opt/homebrew/bin:$PATH"
```

### 4. brew install Ansible

```zsh
brew install ansible
```

### 5. Setup & Execute Playbook

```zsh
#!/bin/zsh

ANSIBLE_PATH=~/workspace/settings/m1mac-ansible

## clone repo
git clone https://github.com/katsuhisa91/m1mac-ansible.git ${ANSIBLE_PATH}

## ansible galaxy
ansible-galaxy collection install community.general

## ansible
cd ${ANSIBLE_PATH}
ansible-playbook -i inventory/localhost localhost.yml
```

That's it! Enjoy your M1 Mac life! :rocket:
Should I Go To College?
Tags: college
Published: 2021-02-22 16:53:28

Who invented college?
And why?

The history of universities dates back to 1000 AD when Cambridge, Oxford, and Paris University were created.
It was meant to be a place to think bigger and expand thinking and ideas.

The trend to receive higher education picked up speed after WWII when the economy exploded with new industries and corporations. 

But are we in the same situation today?  
Is college the right path?
[Should I go to college?](https://www.brooksconkle.com/should-i-go-to-college) 

It is one of the biggest decisions of life as it sets your life path financially and professionally. 

With the rise of technology in the last 40 years, we have witnessed numerous radical changes in how we communicate and learn. We have seen a disruption in the job market with many jobs going obsolete and new professions emerging. 

Despite all these changes, our education system has not kept pace with the shift. 

And invariably, this lack of reform has made university education dispensable.

While higher education is right for some people, I can confidently say that it isn’t necessarily for everyone.

What are your thoughts?
All about spring boot initializer | Onurdesk
Tags: spring, onurdesk, springboot, java
Published: 2021-02-22 16:51:22

Introduction
Spring Initializr provides a simple and intuitive web UI for creating and configuring and generating a Spring-based application. This tool makes it easier for developers to create an initial project framework without thinking about the framework and dependencies of the project. The High-Level Spring Initializr tools take care of the following points for every Spring-based application.
⦁ Project structure.
 ⦁ Dependencies needed to start work.
 ⦁ Build a script (Maven or Gradle) to build your application.
 ⦁ Language and version (Initializr adds the correct version-based dependencies)
 ⦁ packaging (war or jar)
Spring Initializr is available on the web, most of the IDEs have built-in integration with the Initializr.

[Please click this for the complete tutorial](https://onurdesk.com/all-about-spring-boot-initializr/)
NPM is good friend of every web-developer in JavaScript community

Tags: npm, javascript, node, webdev
Published: 2021-02-22 16:47:22

Here i have included all the cool features of npm that i experienced. This blog is uploaded to blogger.com by me.
[read it here](https://sudip-karmakar.blogspot.com/2021/02/npm-is-good-friend-of-every-web_22.html)
Calculator
Published: 2021-02-22 16:39:33

One of the more difficult problems that I assigned myself in my limited time as a programer was to make a calculator. Even after I decided to put the project down it wasn't in a perfectly working state. It would be nice to come back the the problem and bulletproof my code later on. The calculator was deceptively hard to build. 

I chose to only use the base operations that were built into the programing language (-*/+) so the main issue I faced was to program order of operations. I would expect the user to put in a string as an input "7/5 (6 + 7)" and give them a number as an output.

The first part of the order of operations was to take the lowest level of parens. This was difficult because It was hard to determine what the lowest level was. I came up with a system where I counted open parens "(" and closed parens ")." when my open parens matched the amount of closed parens I would cut that string out and out it in a struct array. 

I can't remember off the top of my head If I decided to make a tree or assign a value to the struct for level of importance. I'm pretty sure I made a tree I'm not going to go over my code because I don't want to spoil the fun when I try to recreate it. Anyways, I'm pretty sure I made a tree of structs and the lower you got on the tree the higher the priority of the order of operations was. 

The code would do something like this... 
ex "7 + 4 (6-5 (4+2))"
top of tree : "7 + 4 operation x"
second branch : "6 - 5 operation x"
third branch : "4 + 2"

The struct would keep an operation as a placeholder that would default to multiplication unless otherwise stated. It would also hold an area of where the branch underneath the current branch would go in its string. Once the math is resolved which would at this point just be standard pemdas without the "p" and the "e", I would send the number value of that branch up for the rest of the problem to be resolved. This would go on until the problem is solved. I'm sure that this isn't the best way to solve this problem and there are likely a few bugs here and there. If you're new give it a shot, it took me like a whole month to figure it out. If you're experienced it probably could be solved in a sitting, don't give me your answers until I have a new perfectly functioning calculator built. Thanks
Today i learned about CSS skew 📦
Tags: todayilearned, css, tutorial, codenewbie
Published: 2021-02-22 16:31:55

Hello, coding people,

Hope you are doing well in your coding journey.

This post is our "20 days CSS animation" post

{% link https://dev.to/atulcodex/20-days-of-css-animation-post-3g8d %}

According to my, CSS skew property is used to push or pull elements from the x-axis and y-axis or from both sides. There are 3 variations in skew which is

* transform: skewX(10deg);
* transform: skewY(20deg);
* transform: skew(10deg, 20deg);
* transform: skewX(10deg) skewY(20deg);

Now play around with this codepen then it will so easy to understand for you.

{% codepen https://codepen.io/atulcodex/pen/VwmMLJx %}

And if you guys interested in my free website templates please download them here 👉[AtulCodex Marketplace 🏪](https://www.instamojo.com/atulcodex/).
CSS Color Scheme Prefers
Tags: css, webdev, tutorial
Published: 2021-02-22 16:29:54

Part 6 of the 21 CSS tips for 2021 Series

[Subscribe To The Channel!](http://www.youtube.com/FollowAndrew?sub_confirmation=1)

{% youtube DSd5mCzBBX4 %}
Watch the Video Tutorial on YouTube for a visual explanation!
An understanding of Spring Security
Tags: security, spring, springboot
Published: 2021-02-22 16:18:07

Spring Security offers authentication and authorization of our application using basic servlet filters. Web apps are vulnerable to security breaches and threats, as anybody who uses the Internet will access them. Any REST endpoints may have limited access to individual users, such as reviewing records or admin-related tasks, for example.
To secure URLs, we can use Spring Security. By providing efficient, flexible security features such as authentication and authorization, Spring Security is a security system that secures J2EE-based enterprise applications. For securing Spring-based software, it is the de-facto standard.
There are mainly four concepts on which spring security works


For all tutorial, [please click](https://onurdesk.com/a-understanding-of-spring-security/)
Open your files with PhpStorm from iTerm2
Tags: engineeringmonday, phpstorm, iterm2, 1percentimprovement
Published: 2021-02-22 16:17:46

Did you ever CMD + click on a file path in your iTerm2 and expected that file to open in your beloved PhpStorm editor only to experience that exact file to open in TextEdit, Sublime, or something else?


  > Look no further, open your files in PhpStorm like a pro!

___


Here is the simplest of NodeJS index.js scripts:

```js
// index.js

var http = require("http");

http.createServer(function(request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello World. This page is running Node.js version: ");
  response.write(process.version);
  response.end();
}).listen(3000);
```

The road to hell,


```js
// index.js

var http = require("http");

http.createServer(function(request, response) {
  ...
  throw new Error('Oops 🤷🏻‍♂️'); 
  ...
}).listen(3000);
```

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chxewf5kor2u780ydagj.png)

...is paved with good intentions.

___
### Firstly - you'll need to create a command-line launcher for your PhpStorm executable.

If you **are not** using JetBrains Toolbox:
* Tools   ➡️   Create Command-Line launcher 

If you **are** using JetBrains Toolbox:
* Open the Toolbox and click on the gear icon, and then on "Settings":

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8ptsxa2ybiffe0vracp.png)
 
* Configure your shell script name:

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zrx91whgk4zpvhii4eh0.png)
 
* You might need to enable shell scripts, if so, do the following:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3kl3wiyyun4ujbof2xv.png)

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vklua6jzsha9suq2tjb8.png)
 
 
### Secondly - you'll need to configure your iTerm2 to open files in PhpStorm

* Open iTerm2 preferences

* Go to:
Profiles   ➡️    Advanced   ➡️    Semantic history 

* Expand the dropdown menu:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jwxwqgk3m9p3x7mvuoh.png)
 
* Select "Run coprocess..." and paste in the following:
 `/usr/local/bin/phpstorm --line \2 \1`
 Or something else, depending on what you configured in the first step

### Thirdly - reap the benefits

Voila, now when you CMD + click on a file path in iTerm2, the file will open in your beloved PhpStorm, with the selector at the respective line.



Happy file opening ✌🏻
Let's Git Started
Published: 2021-02-22 11:07:14

What is a git? What's GitHub? If you don't know the answer to either of these questions, you've either never needed to work with code or you have terrible professors.

A git is a command line version control system. Basically, this means you can play with some code without completely wrecking it for the person who created/published it. GitHub is a platform for sharing code to be forked, or copied for use by people who didn't even write that code! Isn't technology great?

GitHub is a great tool for team collaboration with anything in regards to coding. We've all had that one project member who has no idea what they're doing, they go in and break the code on everybody else who has been working to get it running. Version control can put a stop to that! Rather than allowing anybody and everybody to crash your code, on GitHub you can require edits, or commits, to be requested. This way, people can play with your code, but they can't change the main branch unless you give them the go-ahead. So long, worthless group member contributions!

If you want to see a short video showing the utility of GitHub and version control, hit this link:
https://youtu.be/PWqBQtR_WLM