teleren/devto huggingface dataset:
Repair SQL Database MDF
Published: 2020-05-18 05:58:48

Repair and Restore SQL Database MDF file from corrupt SQL Server Database using the <a href="https://www.arysontechnologies.com/sql-database-recovery.html">Aryson SQL Database Repair tool</a> successfully. This tool will help you to repair your corrupted MDF file of SQL Server Database and rebuild a new database as an MDF file after that you can easily regain the previous data of SQL Database in SQL Server with ease.

It allows us to repair both MDF and LDF files of the SQL Server Database.
It helps to recover data from recovery pending state of the SQL Server database.
It recreates a new database file from corrupted SQL Server database file.
Supports all version of MS SQL Server and run on all versions of Windows OS.
What we learned during the lockdown
Tags: covid, lessonslearned, homeoffice, discuss
Published: 2020-05-18 05:48:52

---
title: What we learned during the lockdown
published: true
description: My experiences in a short list. Share your list with us!
tags: covid, lessonslearned, homeoffice, discuss
---

I thought about the things I learned while working from home during the lockdown and wrote them down in a small list.

- 100% remote is possible with ease in my job (even for me)
- From home I tend to work more than less
- It doesn't take shoes or pants to be focused on work while working from home
- After a month at home, weekend finally feels like weekend again
- I do not need a seperate workspace at home to focus
- I have a lot more time at home
- It's possible for my gf and me to be together 24/7 for more than a month without going insane (guess she's a keeper)
- I'm propably wasting a lot of time when driving to work
- Keeping muscles in shape with rubber bands excercises is possible
- I'm eating a ton of shit. I should improve my eating habits.
- I need my podcasts (especially the chitchat ones)
- I can easily keep myself up to date with twitch, tech podcasts and youtube
- I have an online community that is able to replace my entire social life (for a medium-term period at least)

If you have made this kind of experience, feel free to write them down in the comments, I'm curious about it.
GeoPandas: The building blocks
Tags: gis, geopandas, python
Published: 2020-05-18 05:45:26


GeoPandas:
According to the documentation, GeoPandas is an open source project to make working with geospatial data in python easier. GeoPandas extends the datatypes used by pandas to allow spatial operations on geometric types, but first things first:

-what is Pandas?

Pandas: Data analysis lib(kinda like excel for python!). geopandas just adds geospatial abilities to pandas.

-why use geopandas?

gepandas uses a lot of different libraries and combines them so we don't have to think about them separately, it does all the hard work.
tip: We should know about all those libraries though, because when we want to do smth specific, we'll just reach past geopandas into maybe fiona so I can for example manipulate the file first before using it in geopandas. This makes us a lot more powerful. 

-why do we need all those libraries?

When people deal with geographic shapes and files, they tend to use specific software packages that aren't necessarily in python. However, these tools are great so python libs just plug into them. that's why a lot of python packages are built on some non-python software (actually this is why the hardest part about geopandas is actually installing geopandas).

-what libraries is geopandas built on?

1.shapely: lib deals with geometric shapes such as lines, polygons and points. Shapely is built on another library called geos (geos: non-python software that does the heavy lifting of geometry for shapely).
2.fiona: software package for reading and writing files (all types of files geographic formats except for csv file for some weird reason!). It's basically an interface for GDAL/OGR (translation lib for reading and writing raster and vector geospatial data formats).
3.pyproj: cartographic projections, keeps track of different techniques and coordinate systems. It's built on PROJ4.
4.descartes: visualization lib; takes data and turns it into maps works hand in hand with matplotlib(python visualization lib).
5.geopy: package for geocoding; it converts addresses to lat and long pairs.
6.archery: simple spatial analysis. Things like whether a point is inside a polygon or a road goes through a neighbourhood.
7.pysal: open source lib of spatial analysis functions (more advanced spatial analysis) and mostly used for coloring maps.
8.numpy: math lib, pandas uses it for computational work.


ps: this post is mostly a transcript for this video, part of an amazing geopandas course by Jonathan Soma on youtube https://youtu.be/9qxXk2JxsqA?list=PLewNEVDy7gq3DjrPDxGFLbHE4G2QWe8Qh
Django - Improvement
Tags: django, codequality
Published: 2020-05-18 05:41:32

Hello Everyone!

In my college I was studying Electronics major but I had and still have a lot of interest in programming. So I decided to learn programming myself. After the end of my third year, I got an internship opportunity in one of the startup companies. During my internship, I managed to learn python, flask, and Django. After the internship, I was accepted as a full-time employee in the same company. Now it's been two years as a full-time employee in the company, I decided to look for job change. I have applied to many companies but didn't get any calls. One day I got a call from an HR for an opportunity, They gave an assignment in Django and asked me to complete within 2 days. I completed the task and sent it to them. After a week, They decided to move forward without me. 

They provided a JSON file of data of users with their activity period. The task is to design and implement a Django application with User and ActivityPeriod models, write
a custom management command to populate the database with some dummy data, and design
an API to serve that data in the json format.

Project repo url: https://github.com/IP10/ftl-test

It would be helpful if anyone goes through the project and provided suggestions for improvements.
PHP high-performance Excel extension, don't worry about memory consumption, don't worry about the speed is too slow.
Tags: xlswriter, php, excel, extension
Published: 2020-05-18 05:38:08

xlswriter is a PHP C Extension that can be used to write text, numbers, formulas and hyperlinks to multiple worksheets in an Excel 2007+ XLSX file. It supports features such as:

Writer:

- 100% compatible Excel XLSX files.
- Full Excel formatting.
- Merged cells.
- Defined names.
- Autofilters.
- Charts.
- Data validation.
- Worksheet PNG/JPEG images.
- Memory optimization mode for writing large files.
- Works on Linux, FreeBSD, OpenBSD, OS X, Windows.
- Compiles for 32 and 64 bit.
- FreeBSD License.
- The only dependency is on zlib.

Reader:

- Full read data.
- Cursor read data.
- Read by data type.

### Benchmark

> Test environment: Macbook Pro 13 inch, Intel Core i5, 16GB 2133MHz LPDDR3 Memory, 128GB SSD Storage.

#### Export
Two memory modes export 1 million rows of data (27 columns, data is string)

- Normal mode: only 29S is needed, and the memory only needs 2083MB;
- Fixed memory mode: only need 52S, memory only needs <1MB;

#### Import
1 million rows of data (1 columns, data is inter)

- Full mode: Just 3S, the memory is only 558MB;
- Cursor mode: Just 2.8S, memory is only <1MB;

### Install

```bash
pecl install xlswriter
```

### Quick start

#### Writer:

```php
$config = ['path' => '/home/viest'];
$excel  = new \Vtiful\Kernel\Excel($config);

// fileName will automatically create a worksheet, 
// you can customize the worksheet name, the worksheet name is optional
$filePath = $excel->fileName('tutorial01.xlsx', 'sheet1')
    ->header(['Item', 'Cost'])
    ->data([
        ['Rent', 1000],
        ['Gas',  100],
        ['Food', 300],
        ['Gym',  50],
    ])
    ->output();
```

#### Reader:

```php
$config   = ['path' => '/home/viest'];
$excel    = new \Vtiful\Kernel\Excel($config);

$data = $excel->openFile('tutorial.xlsx')
    ->openSheet()
    ->getSheetData();

var_dump($data)
```

### Link

GitHub: https://github.com/viest/php-ext-xlswriter
Document: https://xlswriter-docs.viest.me
Began a new toy project
Tags: toyproject, pairing, mentorship, devdev
Published: 2020-05-18 05:37:10

---
title: Began a new toy project
published: true
description: toy project, classic scrolling shooter game
tags: #toyproject, #pairing, #mentorship, #devdev
---

I got a coding buddy! Xenia is programming with me on a small project to design a classic shooter game.

I got the first code running. 
Today I did the first refactor for this project. Introducing a new class to move KeyEvent behaviour to its own class.

We have an issue with visual side of the game - the pngs are too big for our use, that will get fixed today. Quite chuffed really. Its sometimes so amazing to see how little it takes to get the coding fun going!

The project began its life in here:
[xy](https://github.com/xeniakora/xy)

We are borrowing some code from the [zetcode](zetcode.com) site to get a headstart, hopefully with the blessings of Jan Bodnar.  And yes, this update just in he allows us to use the code! Which made me even happier!

We are also using the CC-BY pngs for images from opengameart.org.

I am so grateful that I found someone to help and who I will be a support to in my own coding development!
Autoscaling Kubernetes using RabbitMQ
Tags: docker, kubernetes, linux, devops
Published: 2020-05-18 03:47:50

---
title: Autoscaling Kubernetes using RabbitMQ
published: true
description: We look into scaling Kubernetes using a RabbitMQ queue or using horizontal autoscaling. There are guides for autoscaling using CPU, and I found a repository for RabbitMQ scaling. I will do the operations I've detailed in the git repository below.
tags: docker, kubernetes, linux, devops
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/b99xyxagugkrqbmfd35r.jpg
---

Needed to find a way to scale our Kubernetes pods at work. Figured out how to scaled depending on CPU or queue.

{% youtube Q9cUO2UEPWc %}

We look into scaling Kubernetes using a RabbitMQ queue or using horizontal autoscaling. There are guides for autoscaling using CPU, and I found a repository for RabbitMQ scaling. I will do the operations I've detailed in the git repository below.
How I've been misusing Async Await
Tags: javascript, asyncawait, beginners
Published: 2020-05-18 03:27:27

---
title: How I've been misusing Async Await
published: true
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/78szil0f0n3k9lhq3ocv.png
description: My JS programs execution times have been taking a hit because of how I've been misusing the Async-Await feature.
tags: javascript, async-await, beginners
---

Async-await is very intuitive and apparently very easy to misuse. Recently I've found out how I've been misusing this feature because of which my JS executes a lot slower than it should. 

Let's look at the example to demonstrate what the problem was:

## How I used to do it:

```Javascript
// Fetching promises one after the other, blocking execution

const getItems = async() =>{ 
    const itemA = await fetch("http://url.com/itemA");
    const itemB = await fetch("http://url.com/itemB");

    return [itemA, itemB]
}


```

## How the pros do it:

```Javascript
// Fetching multiple promises concurrently to avoid delaying program

const getItems = async() =>{ 
    const itemA = fetch("http://url.com/itemA");
    const itemB = fetch("http://url.com/itemB");

    const items = await Promise.all([itemA,itemB]);
    return items;
}
```

See the core difference is how I was previously waiting for itemA to resolve before fetching itemB. On the other hand, when I wait for both the promises to resolve concurrently I speed up the execution by not having itemA to resolve before itemB.

(Note: However this is only recommended when the itemB does not somehow depend upon the promise from itemA being resolved first.)

*P.S. Please follow me on twitter, I'd really appreciate it. [@Nipeshkc](https://twitter.com/NipeshKc7)*
Committing to Sharing My Learnings
Tags: juniordev, mentorship, project, learning
Published: 2020-05-18 03:01:14

---
title: Committing to Sharing My Learnings
published: true
description: 
tags: #juniordev #mentorship #project #learning
cover_image: https://images.unsplash.com/photo-1498050108023-c5249f4df085?
---
I've recently connected with a mentor who will be my partner in crime as I work towards building my first fully functional web application. I've built a few apps for school ([Flatiron School](https://flatironschool.com/)), but with those, my focus was more so hitting project requirements than anything else. With this project build, I'll be working on integration's I've had no previous experience with so as terrifying as it is, it's super exciting! What better way to learn than to do, right? 

After our first meeting he broke down a list of everything we will implement, and just from that conversation I already know I'll come out of this a better developer. So with that, I wanted to commit to sharing my learnings on a weekly basis. My goal here is to write a blog post at the end of each week sharing anything from code to concepts, to frustrations, and of course - wins! 

The main reasons why I've decided to do this are:
- accountability
- teaching what I learn
- watching my progress


### It Will Keep Me Accountable
- I'll be more aware of the details of what I learn, so I have something (hopefully) interesting to share. Each week I'll be sure to try to learn something new. Which shouldn't be hard, since there's so much to learn! 

### Reiterating and Teaching
- One great way to learn is to teach. So if there's a concept I struggle with, I'm hoping that having to write about it would help me better understand it. 

### Watching My Progress / Remembering Wins
- Sometimes, as developers we get caught up with the negatives. Not understanding, struggling to learn, not feeling like you're making progress. So having ongoing weekly documentation gives me the opportunity to look back at prior weeks and see how much I've grown. 

This weekend marks the end of my first week. But I didn't want to write my first blog about it until sharing the reasoning behind why I'm doing this. I'll publish my week 1 blog post tomorrow, and if you come across it - I hope you learn something new!
MSSQL
Tags: mssql, cheatsheet, rdbms
Published: 2020-05-18 02:53:29

## MSSQL GUI Management Tool
### Windows
- SQL Server Management Studio (SSMS)

### Mac
- Azure Data Studio

---

## Connection String
- http://www.devlist.com/ConnectionStringsPage.aspx

---

### Disable all constraints
``` sql
EXEC sp_MSforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
```

### Enable all constraints
``` sql
EXEC sp_MSforeachtable @command1="print '?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
```

### Drop database
``` sql
USE master;
ALTER DATABASE [database] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE [database];
```

### Create login
``` sql
CREATE LOGIN [login_name] WITH PASSWORD = '[login_password]';
```

### Create user
``` sql
CREATE USER [user_name] for login [login_name]
```

### Grant privilege
``` sql
GRANT SELECT, INSERT, UPDATE, DELETE on [schema.object] to [user_name];
```

### Get existing MSSQL connections
``` sql
SELECT * FROM sys.dm_exec_sessions WHERE status = 'running';
OR
EXEC sp_who;
```

### Take a table lock in transaction
``` sql
BEGIN TRAN  
SELECT 1 FROM dbo.Members WITH (TABLOCKX)
WAITFOR DELAY '00:00:30' 
ROLLBACK TRAN   
GO 
```

## Take a row lock in transaction
``` sql
SELECT * FROM dbo.Members WITH (ROWLOCK, UPDLOCK)
WHERE ID = 2
```
My One year of work — Gatsby Cookbook
Tags: gatsby, react, showdev, books
Published: 2020-05-18 02:14:18

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/u2ybyiphur4bly9esvdm.png)

As most of my readers know, i had invested heavily in **GatsbyJS** and writing blog in it for the past 1 year. I also created 3 of my personal sites in Gatsby with 1 more to come soon.

The book will launch on all major platform like leanpub, amazon, iBooks in **July 2020**. 

The book is currently 80% complete and available on leanpub to purchase at [this](https://leanpub.com/gatsbycookbook) url. So, please show your support and purchase the book or tell it to someone who is interested in developing blazing fast production websites in GatsbyJS.

https://leanpub.com/gatsbycookbook

![leanpub](https://res.cloudinary.com/dxkxvfo2o/image/upload/v1591207471/dev30andUp/leanpub_kfrpls.png)

Although 60% of the book is available on my blog, but 40% is exclusive content. The content of the book is below.

* Chapter 1 — Agency Site

* Chapter 2 — Blog Site with Stackbit

* Chapter 3 — Tourism Site with Contentful

* Chapter 4 — Video Chat Site

* Chapter 5 — Blog Site using mdx

* Chapter 6 — Ecommerce site with snipcart

* Chapter 7 — Recipe site with firebase

All the sites in the book are created with the awesome static site generator GatsbyJS. The details on creating the sites are explained in plain English and in a very simple way, although a bit of knowledge of ReactJS and GraphQL will help.

I am also announcing my new blog site [https://thewebdev.tech/](https://thewebdev.tech/). This site contains 50% of my blogs and will soon have all of my blogs. You can find all of my blogs at my current site [https://nabendu.blog](https://nabendu.blog)

![New Site](https://cdn-images-1.medium.com/max/2880/1*kl__kVEUftBkGv7ev16hHQ.png)*New Site*

Please do subscribe in it to get more details on my new book. See you all soon with more updates.
Difficulties Encountered with React Hooks
Tags: react, discuss
Published: 2020-05-18 02:13:55

Photo by [Dave Phillips](https://unsplash.com/@teracomp?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/hooks?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)

Kent C. Dodds has a great post, [5 Tips to Help You Avoid React Hooks Pitfalls](https://kentcdodds.com/blog/react-hooks-pitfalls). There's lots of great advice in there, but I'm curious what issues all you wonderful devs on DEV have encountered in regards to React [Hooks](https://reactjs.org/docs/hooks-intro.html).

It could be a production application or a side project you're working on. It could be a small issue you encountered or it could be a whale of an issue you struggled with.

<center>

![Whale hello there!](https://media.giphy.com/media/mW05nwEyXLP0Y/giphy.gif)

</center>

It could be an issue that stumped you with an out of the box hook, a 3rd party hook or your own custom hook.

Go!
React Hooks: useState()
Tags: react
Published: 2020-05-18 01:54:09

In a recent post on React hooks, I advocated their usage and explained how they could make your functional components flexible, extendable, and reusable. I would like to bring your attention to one of my favorite hooks: useState().

In some cases, you need to bring some state logic into a function component. Instead of rewriting it as a class component, you can hook into React state and lifecycle features. Implementing it is easy!

```js
import React from 'react';
import {useState} from 'react'

function App() {

  const [importantThing, setImportantThing] = useState('initial value')

  return (
    <div >
      {importantThing}
    </div>
  );
}

export default App;
```
After importing useState from React, we see two values in an array being declared, and an initial value being set. The array is there to destructure the variables in useState, where the first value references the variable that lives in the state, and the second value is the reference to the function that changes the variable. 

You can also set the variable to be an object, like so:

```js
const [fruits, setFruits] = useState([{ apple: 'Granny Smith' }]);
```
Environment Variables with pm2: The Right Way
Published: 2020-05-18 01:35:29

# Introduction

This post is meant to support anyone who is setting up environment variables for a Node.js daemon that they will manage with pm2. Specifically, this post will show you how to handle `NODE_ENV` for development and production settings for pm2. 

There are multiple ways to handle environment variables for a pm2 daemon.
1) Some deployment tools, like Heroku or Netlify, let you set environment variables.
2) You can set them in your CLI. 
3) You can use a pm2 `ecosystem.yml` file.

There are trade-offs between all of these approaches. The first option forces you to navigate a deployment tool's interface to figure out any bugs relating to environment variables. 

The second approach makes it easier to debug. You might implement it with something like this, in the `scripts` section of your `package.json`:

```json
"scripts": {
  "start": "NODE_ENV=production && pm2 start app.js",
  "dev": "NODE_ENV=development && pm2 start app.js"
}
```

While this approach is viable, to my tastes it feels "hacky". It does the immediate job of setting one environment variable, but what if you wanted to set more environment variables? Maybe you would write a `set_env_var.sh` script and invoke it in your `package.json` script, but then you would have to go to that shell script to debug any issues.

pm2 provides a preferred way to handle environment variables: an ecosystem file.

# Solution

Compare this `ecosystem.yml` file below with the `package.json` snippet above:

```yml
apps:
  - script: ./app.js
    name: "app"
    env:
      NODE_ENV: development
    env_production:
      NODE_ENV: production
```

It would be far easier to add environment variables, here. And, better still, you're clearly communicating your intent to your collaborators: this file is where we handle environment variables for our pm2 daemon. 

You complete the solution by adding something like the following to your `package.json`:

```json
"scripts": {
  "start": "pm2 restart ecosystem.yml --env production",
  "dev": "pm2 restart ecosystem.yml --env development"
}
```

Similar to the first `package.json` scripts, these scripts will start (or restart an existing) pm2 process, and update the environment for that process to include the variables you declared in your `ecosystem.yml` file. 

This is a useful pattern, when setting up dev ops for a pm2 micro service. Consider the following snippet from `app.js`:

```js
const TOKEN =
    process.env.NODE_ENV === "production"
      ? process.env.PROD_TOKEN
      : process.env.DEV_TOKEN;
```

If you call `yarn start`, you will re/start a pm2 process with a token designated for production; if you call `yarn dev`, you will re/start a pm2 process with a token designated for development. 

# Conclusion

I hope this guide was useful for anyone getting started with pm2, and thinking through how to implement environment variables for their daemon. An example application that uses this pattern can be found on my [GitHub](https://github.com/gortron/cupbot).
Students: Want to win a cool System76 Desktop PC? Enter your dev project. Open to high school or undergrads (ends 5/29/2020)
Published: 2020-05-18 01:14:44

Create and share an open source project that addresses climate change and/or pollution. Must be licensed under a standard free software license such as BSD, GPL or MIT.

https://themadbotter.com/2020/04/22/earth-day-2020-contest/

Rules below::

Your solution must be posted to a publicly accessible Github repository with the appropriate license included.
You must be a US high-school or undergraduate college student.
If you are below the age of 18, you must provide written parental consent to have your submission considered; this can be done via email.
In the event that you win, The Mad Botter INC is granted the right to post a picture of you in the winning announcement and other applicable venues; if you are below the age of 18 your parent or guardian also provides permission for this by consenting to your entering the contest.
The winning entry will be the one that shows the most practical potential and creativity and will be selected by The Mad Botter team.
All submissions should be sent to sales@themadbotter.com and include a brief bio, explanation of the solution and a link to the Github repository.

Tag me if you win! The System76 Thelio Desktop is slick! Alas, I am not a student 

Submissions will be accepted until 5/29/2020.