teleren/devto huggingface dataset:
You don't need express to get started with socket.io
Tags: javascript, node, beginners, socketio
Published: 2018-08-08 06:55:10

---
title: You don't need express to get started with socket.io
published: true
description: 
tags: javascript, node, beginner, socket.io
cover_image: https://cdn-images-1.medium.com/max/812/0*xAADmPJN52Yy6XJV.jpg
---
The best place to get started with socket.io is their website. But once you access it you are given this example app demonstrating how to use socket.io.

```javascript
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.get('/', function(req, res){
  res.sendFile(__dirname + '/index.html');
});

io.on('connection', function(socket){
  console.log('a user connected');
});

http.listen(3000, function(){
  console.log('listening on *:3000');
});
```

If you are fairly new to node, this makes you think that express is needed in order to use socket.io. In the above example they include express to serve the index file which will be client app for your socket server. There is nothing wrong with the above approach but if lets say you don't know express, now you have one more thing to learn before using socket.io.

It would be better if they didn't introduce an additional library in their example. Socket.io has another example using the node http server

```javascript
var app = require('http').createServer(handler)
var io = require('socket.io')(app);
var fs = require('fs');

app.listen(80);

function handler (req, res) {
  fs.readFile(__dirname + '/index.html',
  function (err, data) {
    if (err) {
      res.writeHead(500);
      return res.end('Error loading index.html');
    }

    res.writeHead(200);
    res.end(data);
  });
}

io.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event', function (data) {
    console.log(data);
  });
});
```

But even this is a little bit too much. I prefer having the server and the client seperate. Therefore this would be my server.

```javascript
const io = require("socket.io");
const server = io.listen(3000);

server.on("connection", function(socket) {
  console.log("user connected");
  socket.emit("welcome", "welcome man");
});

```
And the client would include the socket.io client library and just plain html.

```html
<html>
    <head>
        <title>Socket io client</title>
        <script src="http://localhost:3000/socket.io/socket.io.js"></script>
        <script>
            var socket = io("http://localhost:3000");
            // use your socket
            socket.on("welcome", (message) => {
                // do something with the message.
            })
        </script>
    </head>
    <body>
    </body>
</html>
```
Small step to create telegram bot
Tags: guidingtheory, jokes, softwaredevelopment, bot
Published: 2019-10-01 16:35:00

---
title: Small step to create telegram bot
published: true
tags: Guiding theory,Jokes,software development,bot
cover_image: https://esabook.files.wordpress.com/2018/08/telegram-bots-father.png
canonical_url: https://esabook.wordpress.com/2018/08/08/small-step-to-create-telegram-bot/
---

1. Open conversation with [@BotFather.](https://telegram.me/BotFather)
2. Post `/start`, and you will see:

![telegram_bot_help](https://esabook.files.wordpress.com/2018/08/telegram_bot_help.png?w=343&h=451)

3. Post `/newbot`
4. Post **name** and **username**
5. Done, after you get `​token`​ like as `680788960:AAEKP9xGSZK9uyWGGouZFYmTkCN8i_y0w`

 

#Sending message to channel:

1. Open url or get =\> [https://api.telegram.org/bot](https://api.telegram.org/bot)token/sendMessage?chat\_id=chat\_id&text=test
2. Done

#Finding **chat\_id:**

1. Add bot to as `​channel administrator`
2. Post `/start` to send bot command
3. Open url or get =\> https://api.telegram.org/bottoken/getupdates
4. See `channel_post`.`chat`.`id`
5. Done

 

for more api kindly goto [https://core.telegram.org/bots/api](https://core.telegram.org/bots/api)
FlowLayout - A minimal layout kit 
Tags: ios, swift, app, iphone
Published: 2018-08-05 13:30:41

---
title: FlowLayout - A minimal layout kit 
published: true
description: FlowLayout is a minimal starter-kit for making modern iOS apps
tags: iOS, swift, app, iphone
---

### Concept:
The idea is to give aspiring app developers a dead simple "vanilla" swift library to start with. Just add some end point calls to instagram and you could literally have a minimal insta client in a day.

<img width="416" alt="img" src="https://rawgit.com/stylekit/img/master/short.gif">

### Description:
I wanted to make a very responsive fluid app like instagram or snapchat. But using apples own app framework always ended up feeling kind of outdated and slow. The concept is really simple. It's just 1 horizontal UICollection and 1 vertical UICollection. The current version uses only 1 RootViewController. The CollectionViews are UIViews with delegate handlers. This makes it really easy to transition to another ViewController. And it also enables you to embed FlowLayout in pure UIView setups like an image picker or alike. 

### Pull to refresh:
<img width="378" alt="img" src="https://rawgit.com/stylekit/img/master/Photo 04-08-2018, 13 29 23 copy.jpg">

### Compact mode:
<img width="378" alt="img" src="https://rawgit.com/stylekit/img/master/Photo 04-08-2018, 13 30 00 copy.jpg">

### Swipe to new pages:
<img width="378" alt="img" src="https://rawgit.com/stylekit/img/master/Photo 04-08-2018, 13 29 43 copy.jpg">

### Links: 

[https://www.producthunt.com/posts/flowlayout](https://www.producthunt.com/posts/flowlayout)  

[https://github.com/eonist/FlowLayout](https://github.com/eonist/FlowLayout)
Remember your goals will take time
Tags: discuss
Published: 2018-08-08 03:16:00

---
title: Remember your goals will take time
published: true
description: So this week I wanted to talk about something that I feel probably a lot of people go through. And that's when you first set out for a goal you have all this initial burst of motivation. And as time goes on you realize its a lot harder than you thought it was going to be. You may even feel like why is this not happening over night type of thought. 
tags: #discuss
---

So this week I wanted to talk about something that I feel probably a lot of people go through. And that's when you first set out for a goal you have all this initial burst of motivation. And as time goes on you realize its a lot harder than you thought it was going to be. You may even feel like why is this not happening over night type of thought. 

And well sadly as much as I want to say your goal can happen over night and all of the sudden your the next ceo of x company and your raking in millions. Or you landed your dream job. What ever it is its going to take time and your going to have to love the process of getting there. Rather then loving the end goal. And I think the best person to explain this if your interested is look up Gary Vanerchuck. And just listen to his thoughts on enjoying the process. 

The reason I even wanted to talk about this topic this week was because I have been grinding away for about the past 8 months. On nothing but math and programming. Which honestly is probably not that long of a time. But it sure seems like it when your studying day in and day out. And throwing as much time into something as you possibly can. And its all to reach my end goal of breaking into the programming industry. I will also say sometimes its going to be really rough. Especially if you watch others who have reached there goals. And I will say another thing stop paying attention. Be happy for them if they are your friends but at the same time keep focused on you. Because your not them and your on your own journey.

Lastly I want to say your not alone in the process just remember there others out there going through the same struggle. So just keep focused and put in as much time as you can. Even the smallest amount will push you that much further to your goal.I mentioned to a friend of mine on twitter the other day who was asking how to work on side projects. After work and how to block that time and so forth. And as I said to this even if you work for 10 15 or 20 minutes its getting something done. And while it may take more time you will get it done. For me I have days where I can only get maybe 15 minutes before work or on my lunch break at work but I take it. And I try to get any thing I can worked on. So over all I would say stay focused on your own goals. And just remember its not a race you will reach your goal in time. Just have patients and remember you are not alone. 

As usual thank you for reading and I hope you guys have a good rest of the week.
Why start learning blockchain ?
Tags: blockchain, career
Published: 2018-08-08 03:07:21

---
title: Why start learning blockchain ?
published: true
description: 
tags: #blockchain, #career
---

Lots of developers at some point of their careers feels that what they are developing looks almost the same, maybe for a different public or different business scope, but the results is almost the same. I mean, a product with some new features that people are enjoying (or not) and this will keep their company's earning money and growing. I'm not saying that this is a rule, but I know developers that feel this way and I'm one of those.

In my opinion the developers could do more to the world than only crafting applications that people will use to interact or manage businesses. Of course that they are important and should keep existing, but  we can create solutions for solving problems related to social inequality, food distribution and fair price policies. I'm not going to go deeper in those problems, but everybody knows that they exists and make a lot of people's life harder.

Looking into the Blockchain, it really can help the world with problems like those and that's why I started studying it.

With a blockchain we can create applications for tracking government transactions and make it impossible to commit embezzlement or money laundry. This is possible because blockchain is basically an accounts book that everyone have it and every time a new transaction happens a new record is generated and added to everybody's book. This brings transparency, trust that from where to where the money goes and that the amount taken from the sender to the destiny was really effective.

Ok, that is not going to solve all problems, but this is an example of what we can do to help the world to became a better place ( Even that is a little bit :D ) for everyone. Let's use our knowledge to something that makes a positive impact to the world !

I'm going to post all my studying learnings related to blockchain here and hopefully to make you more motivated to start learning it too.

Cheers :D
Do you schedule time and tasks for refactors?
Tags: discuss, refactor, cleancode
Published: 2018-08-08 01:37:07

---
title: Do you schedule time and tasks for refactors?    
published: true
description: 
tags: discuss, refactor, cleancode
---

This evening, I sat down to read on some of [Uncle Bob's](https://en.wikipedia.org/wiki/Robert_C._Martin) tweets and they are quite interesting, but one of them stood out for me:

{% twitter 1024254121338126336 %}

And I can totally understand what he means, but I recently started working on a project that is so tangled that it was actually slowing us down. No matter your seniority, you would find yourself increasing the "WTF per minute" counter constantly while working on what seemed like a basic task.

In case you may wonder what the "WTF per minute" reference is about, the following image should help you out:

![Wtf per minute](https://thepracticaldev.s3.amazonaws.com/i/7k5q0aq8nt0mmgruaj4d.png)

Which led us to speak to our manager and try to convince them that if we kept going that road we would make our lives worse with each step we take.

So, that resulted in a bunch of tasks that had to be estimated, divided into multiple devs in order to reduce the overall time it would take (as long as they could be worked in parallel) and blah blah blah.

This meant that we would have to spend at least 1-2 months putting everything on hold until we could refactor our code to be easier to manage, for both experienced and unexperienced developers.

Personally, I find that Uncle Bob's opinion _should_ be the way everyone should think, but it should not be written in stone. Depending on how critical or big the refactor may be needed, you may need those refactoring tasks to be tracked.

Other opinions found in this tweet thread:

{% twitter 1024428546851307530 %}

Which was replied with:

{% twitter 1024637347856572416 %}

And then Uncle Bob added:

{% twitter 1024640337854324738 %}

<center>**Now I would like to read your opinions about this topic :)**</center>
NTFS Compression and SQL Server Do Not Play Well Together
Tags: sqlserver, edgecase
Published: 2020-11-12 04:14:43

---
title: NTFS Compression and SQL Server Do Not Play Well Together
published: true
date: 2018-08-08 00:00:00 UTC
tags:
- sqlserver
- edgecase
canonical_url: https://www.sheldonhull.com/blog/ntfs-compression-and-sql-server-dont-play-well-together/
---

TEST

Wanted to be proactive and move a database that was in the default path on `C:\` to a secondary drive as it was growing pretty heavily.

What I didn't realize was the adventure that would ensure.

## Lesson 1

Don't move a SQL Server database to a volume that someone has set NTFS Compression on at the drive level.

## Lesson 2

Copy the database next time, instead of moving. Would have eased my anxious dba mind since I didn't have a backup. _before you judge me.. it was a dev oriented enviroment, not production… disclaimer finished_

## The Nasty Errors and Warnings Ensue

First, you'll get an error message if you try to mount the database and it has been compressed. Since I'd never done this before I didn't realize the mess I was getting into. It will tell you that you can't mount the database without marking as read-only as it's a compressed file.

Ok… so just go to `file explorer > properties > advanced > uncheck compress` … right?

Nope…

```
Changing File Attributes 'E:\DATA\FancyTacos.mdf' The requested operation could not be completed due to a file system limitation`

```

I found that message about as helpful as the favorite .NET error message `object reference not found` that is of course so easy to immediately fix.

## The Fix

- Pull up volume properties. Uncheck compress driveOR
- If you really want this compression, then make sure to uncompress the folders containing SQL Server files and apply.

Since I wasn't able to fix this large of a file by toggling the file (it was 100gb+), I figured to keep it simple and try copying the database back to the original drive, unmark the archive attribute, then copy back to the drive I had removed compression on and see if this worked. While it sounded like a typical “IT Crowd” fix (have you tried turning it on and off again) I figured I'd give it a shot.

… It worked. Amazingly enough it just worked.

Here's a helpful script to get you on your way in case it takes a while. Use at your own risk, and please… always have backups! #DontBlameMeIfYouDidntBackThingsUp #CowsayChangedMyLife

<script type="application/javascript" src="https://gist.github.com/sheldonhull/c13eec8bbd570f762fd3834b19464465.js"></script>

and finally to remount the database after copying it back to your drive …

<script type="application/javascript" src="https://gist.github.com/sheldonhull/274861a17a7db002bddd55861b781719.js"></script>
Clean up git branches that do not exist on origin
Tags: git, cleanup, shortcut, powershell
Published: 2019-10-09 21:10:04

---
title: Clean up git branches that do not exist on origin
published: true
tags: git, cleanup, shortcut, powershell
canonical_url: https://www.mehmetseckin.com/2018/08/08/clean-up-git-branches-that-do-not-exist-on-origin.html
---

# Clean up git branches that do not exist on origin

After our team worked on a git repository for a while, we accumulated a lot of useless branches that are no longer being used. We’ve removed these branches regularly from the origin, but the local branches remained in everyone’s workstations like zombies.

It was time to do something.

That’s when we decided to combine the powers of `git fetch --prune` and shell scripting to forge a PowerShell function that will kill the zombie branches in our local repositories.

The script simply uses `git fetch --all --prune` to update all remote references (`--all`) and drop deleted ones (`--prune`).

After this, it filters out the local branches that do not exist on the origin by scraping the output of `git branch -vv`, and deletes the zombie local branches.

Here’s the whole thing:

```
<#
.SYNOPSIS
Remove local git branches that are deleted from the origin.

.DESCRIPTION
Removes local git branches that are deleted from the origin using `git fetch --prune` and `git branch -[dD]`.

.PARAMETER Force
Switch to to force removal using `git branch -D` instead of `git branch -d`.

.EXAMPLE
Remove-DeletedGitBranches
Removes merged non-existing branches.

.EXAMPLE
Remove-DeletedGitBranches -Force
Removes all non-existing branches.

.NOTES
This cmdlet uses `git fetch --prune`, so it will delete references to non-existing branches in the process. Use with caution.
#>
function Remove-DeletedGitBranches
{
    param
    (
        [Parameter()]
        [Switch]
        $Force
    )

    $null = (git fetch --all --prune);
    $branches = git branch -vv | Select-String -Pattern ": gone]" | ForEach-Object { $_.toString().Split(" ")[2] };
    if($Force)
    {
        $branches | ForEach-Object {git branch -D $_};
    }
    else 
    {        
        $branches | ForEach-Object {git branch -d $_};        
    }
}

Set-Alias -Name "rmdelbr" -Value Remove-DeletedGitBranches
```
I just published my first open source project. Here's what I've learnt.
Tags: opensource, npm, javascript, showdev
Published: 2018-08-07 23:39:49

---
title: I just published my first open source project. Here's what I've learnt.
published: true
description: Unveil your first open source project to the world and learn something.
tags: opensource, npm, javascript, showdev
---

That it's one of the best ways to learn a technology you haven't worked with before.

I just published an npm package/tool that allows you to create static candlestick charts for financial data. All you have to do is plug in some JSON data, set some options and call the `draw()` function on it. Check it out here: https://www.npmjs.com/package/candlestickcharts

In a matter of a week's worth of solid work, I managed to:
- Learn how to create an NPM package (after publishing it, this point feels like a cop out since it REALLY is not that difficult. The point is, sometimes we hesitate making progress because of the anticipated workload).
- Learn how to work with HTML Canvas. I've never touched this before, but in evaluating my options for this project, I felt like this may be the best way to go about it. "Pfft...it's just HTML, right?!" Wrong. The HTML part of it all was half a line's worth of code. The rest was manipulating pixels using JavaScript.
- How to accurately scale and plot a chart using HTML Canvas, from data provided in JSON.

Let's not underestimate the value of getting practice in your favorite JavaScript ES6, object, array and Math/Number methods. Plus the fact that you just created a tool that can potentially make at least one developer's life easier and actually pushed it out into the world. That's always a good feeling. Whether or not someone takes this project and creates something out of it, well...🤷‍♂️.

Now to find out how much maintenance work is involved, maybe I'll make another post then 😉. In the mean time, I'm probably going to look into a new project - because let's face it, it's more fun to work on shiny new ideas than maintaining old ones. (Ha.)
Dart 2 has reached stable 🎉
Tags: dart, discuss, webdev, motivation
Published: 2018-08-07 23:14:54

---
title: Dart 2 has reached stable 🎉
published: true
description: Now is the time to join the Dart side
tags: dart, discuss, webdev, motivation
cover_image: https://thepracticaldev.s3.amazonaws.com/i/o8gq2t5uvefdwewbsgpf.png
canonical_url: https://creativebracket.com/dart-2-has-reached-stable/
---

It's with great pleasure writing this short message to celebrate Dart 2 hitting the stable milestone. This means that it is ready for building production applications.

I've had a pleasant experience diving into Dart so far, due to the reasons below:

1. I found it familiar and easy to pick up within days
2. I was impressed with the range of [useful](https://dev.to/graphicbeacon/top-10-array-utility-methods-you-should-know-dart-version--3217) [utility](https://dev.to/graphicbeacon/top-10-mapobject-utility-methods-you-should-know-dart--1ido) [methods](https://dev.to/graphicbeacon/top-10-string-utility-methods-you-should-know-dart--4df0), making it easier to work with the inbuilt types
3. It's truly object-oriented and has a strongly typed language
4. It promises and delivers a very productive experience
5. It has a growing community on [Reddit](https://www.reddit.com/r/dartlang/) and [StackOverflow](https://stackoverflow.com/questions/tagged/dart)
6. It comes with [a repository](https://pub.dartlang.org) of packages
7. It provides [tooling](https://webdev.dartlang.org/) for web applications
8. It has proven itself in the [mobile app development](https://flutter.io) space

And I'll continue to expand on these via future articles!

Here's the [full announcement](https://medium.com/dartlang/dart-2-stable-and-the-dart-web-platform-3775d5f8eac7) by the Dart team.

If you ever considered taking the leap, [now is the time](https://dartlang.org).

---
Dear 10 year old me...
Tags: discuss, motivation, ideas, history
Published: 2018-08-07 22:55:43

---
title: Dear 10 year old me...
published: true
description: 
tags: discuss,motivation,ideas,history
---

Dear 10 year old me:

Spend some more time asking questions instead of assuming answers.

## what would you tell your 10 year old self?