teleren/devto huggingface dataset:
Twitter with Swift
Tags: swift, tutorial
Published: 2020-02-29 11:03:08

## Twitter search API

```swift
import Foundation


struct Endpoint {
    let path: String
    let queryItems: [URLQueryItem]
}


extension Endpoint {
    static func searchTwitter(_ query:String, _ count: Int) -> Endpoint {
        return Endpoint(
            path: "/1.1/search/tweets.json",
            queryItems: [
                URLQueryItem(name: "q", value: query),
                URLQueryItem(name: "count", value: String(count)),
                URLQueryItem(name: "result_type", value: "mixed"),
                URLQueryItem(name: "lang", value: "en")
                
            ]
        )
    }
}

extension Endpoint {
    
    var url: URL? {
        var components = URLComponents()
        components.scheme = "https"
        components.host = "api.twitter.com"
        components.path = path
        components.queryItems = queryItems
        
        return components.url
    }
}

```

Extension methods allows good abstraction over `URLRequest` in Foundation. We generate `Endpoint` from static function. Use `Endpoint.url` to get the `URL`. 


```swift

let endpoint = Endpoint.searchTwitter("#coronavirus", 10) // static factory method to construct the Endpoint


let twitterURL = endpoint.url

// Construct URLRequest from URL
var ghRequest = URLRequest(url: twitterURL!)


ghRequest.httpMethod = "GET"
ghRequest.setValue("Bearer AAAATOKEN", forHTTPHeaderField: "Authorization")

// semaphore required for yielding async tasks

let semaphore = DispatchSemaphore(value: 0)

let taskGh = URLSession.shared.dataTask(with: ghRequest) { (data, response, error) in
    if let error = error {
        print("error \(error)")
        return
    }

    guard let data = data else { return }
    
    let json = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
    
    if let statuses = json!["statuses"] as? [[String: Any]] {
        for i in statuses {
            print(i["text"]!)
        }
    } else {
        print("Wrong with the OAuth token Authentication")
    }
    
        
    semaphore.signal()
}

taskGh.resume()

_ = semaphore.wait(wallTimeout: .distantFuture)


```
Any idea how to proceed coding this interface ?

Tags: codequality
Published: 2020-02-29 10:46:59

Hello everyone,,
already knowledge about CSS and HTML but never done something similar to a dashboard, I want to know how do I proceed and where do I begin to code this interface. Should I divise the screen to two column or use bootstrap or something else ? Thank you. https://mobdro.bio/ https://luckypatcher.tips/ https://kodi.bio/

https://i.imgur.com/XYalCr5.jpg

I want it to be responsibe like the mobile interface I added.
Maximize vertical Sidebar
Tags: css
Published: 2020-02-29 10:45:50

Hello everyone,,
I have a basic layout that mostly works using divs.

A header, a navigation bar, a content box, a footer, all stacked on each other.https://showbox.bio/ https://tutuapp.uno/ https://vidmate.vet/

Within the content box, I have a side bar on the left and main content on the right.

The navigation, footer, and sidebar all use a dark color background.

My question is, I want the left side bar (call it leftcolumn), to span from the navigation bar at the top to the footer at the bottom, so they visually look connected, reguardless of the length of the content in the side bar and the content box.

I tried a few things (height: 100%, some clear options, but nothing seems to work. I feel like there is an obvious property here to use that I am missing.
Why would people hate React (or JSX), but not Vue SFC, or even Angular?
Tags: webdev, discuss, healthydebate, react
Published: 2020-02-29 10:32:58

Or even, do you hate `lit-html`?

I mean, all you are doing is either HTML-in-JS, or truly JS function syntax anyway. No real separation of concern here, unless you truly visually separate them.

I think HTML-in-JS is the basis of SPA, anyway.
Nikema's 100 Days of Code - Days 12-13
Tags: 100daysofcode, wordpress
Published: 2020-02-29 10:20:04

I started a course on WordPress development. Having fun with it. I didn't log yesterday, so [today's log](https://github.com/prophen/100-days-of-code/blob/master/Days-12-13.md) combines the last two days.

I'm starting to get used to writing and looking at PHP. I only touched PHP over 10 years ago. I never felt comfortable with it. I think working with React and JSX made catching on to WordPress PHP easier for me. 

Also helpful are the VS Code extensions, I installed for use with my WordPress course. Brad doesn't recommend any extensions, but I added WordPress autocomplete and PHP IntelliSense ones.

https://github.com/johnbillion/vscode-wordpress-hooks
https://github.com/bmewburn/vscode-intelephense

 
{% twitter 1233690528127971328 %}
A small Introduction about me
Tags: self, introduction
Published: 2020-02-29 10:16:00

Hi everyone,
This is my initial post in dev.to.

I'm Arnold, 
A Python developer and also a Data Scientist.
Originally from Surabaya, Indonesia. And got my master's degree in Taipei, Taiwan. 

My passion and professional work mostly focuses on engineering data, create software and service, analyzing data, and I do them all in my main language: Python.
I have an excitement to do a cloud-powered service as they are flexible and affordable.


I've been excited to build my portfolios and record all of my professional and side project experiences through my website: https://arnold.id connected with dev.to. 
And hopefully, dev.to will be my main place to share and track my experiences where someday I can check my work again. 

I'm personally not a writer and not speak English as my main language. 
And for the reader's convenience sake I'll keep my posts as concise and as clear as possible. Just like this post.

Anyway, can't wait what dev.to may bring!

Thanks,
Arnold Samuel Chan
I have a project idea, need a little advice.
Tags: javascript
Published: 2020-02-29 09:46:45

Hello everyone,,
I am looking for project ideas to learn how to really apply what I’m learning. I am following theodinproject right now at home and having something separate to work on at work in my free time would help me cement a bit of my learning.

My idea is to create an ikea catalogue type of assembly procedure. A home screen that tells about what I am constructed in. A navbar that has say 8 sections each opening in a new tab or completely changing the page I am on and each page having a image larger than the rest of what is being assembled and beside it hardware parts and steps etc. maybe small boxes and lines showing what goes where or possibly room for sketches. Also I don’t know how to go about showing friends, posting online somehow using a flash drive etc. I don’t have to actually put words just filler text and photos are fine with me.
https://reversephonelookup.onl/ https://curated.onl/nba-reddit/ https://pcbuilder.onl/pcpartpicker/
Is this something doable for a beginner? Will this require more than I would even use for full stack? Would this be a huge waste of time or potentially help me learn?
Improving my counter
Tags: help, javascript, css
Published: 2020-02-29 09:46:00



I've created a count-up clock that I'd like some help refining if you wouldn't mind. Currently, I have two issues that are bugging (pun intended!) me.

1. The counter doesn't count up the hours, when it reaches two hours, it goes back to 01:01:01
2. The numbers jump around

Here is my code so far…

``` javascript
// Counter

if (!!document.getElementById("counter")) {
  var minutesLabel = document.getElementById("minutes");
  var secondsLabel = document.getElementById("seconds");
  var totalSeconds = Number(secondsLabel.textContent);
  var totalMinutes = Number(minutesLabel.textContent);

  setInterval(setTime, 1000);

  function setTime() {
   ++totalSeconds;
   secondsLabel.innerHTML = pad(totalSeconds % 60);
   minutesLabel.innerHTML = pad(parseInt(totalMinutes + totalSeconds / 60));
  }

  function pad(val) {
   var valString = val + "";
   if (valString.length < 2) {
    return "0" + valString;
   } else {
    return valString;
   }
  }
 }

// End Counter
```
``` css
#counter {
  background-color: #ee1a25; // TODO: Change this to a pattern
  color: $white;
  text-align: center;

  .counter_wrapper {
    flex-direction: column;

    @include desktop {
      flex-direction: row;
    }
  }

  .counter_container {
    display: flex;
    align-items: center;
    flex-direction: row;
    justify-content: center;

    .counter_number {
      font-weight: regular;
      font-size: 60px;
      font-family: $family-primary;

      font-feature-settings: "tnum";
      font-variant-numeric: tabular-nums;
      @include widescreen {
        font-size: 133px;
      }
    }

    .divider {
      display: inline-block;
      margin: 0 16px;
      width: 8px;
      height: 30px;

      @include widescreen {
        margin: 0 34px;
        width: 16px;
        height: 60px;
      }
    }
  }
}
```
I'd apprecitate any help and advice offered please
Is there some sort of CSS guide?
Tags: css
Published: 2020-02-29 09:45:03

Hello everyone,,
I learned CSS when I was younger on Neopets and remember most of it, but I don't quite know what calls everything/how attributes are named. Is there some sort of guide floating around the interwebz or is it going to be a trial and error thing for me??? https://openweb.vip/whatsapp-web/ https://19216801.onl/ https://routerlogin.uno/
Progress 2018 vs 2019
Tags: css, codepen, html, webdev
Published: 2020-02-29 09:42:17

Just looking at my progress and i can see a huge difference. On the left side two years ago 2018 i tried to make a css girl, it turned out too good for me i was so happy with it and on the right side 2019 i tried to make the exact same girl with some changes. 
https://codepen.io/MalaikaIshtiaq/pen/OexbXz
My Codepen Profile: https://codepen.io/MalaikaIshtiaq
Is it just me does anyone else feel that javascript world has gone crazy?

Tags: javascript
Published: 2020-02-29 09:04:00

Hello everyone,,
To begin with, there are so many js frameworks out there that's enough to intimidate a newbie who wants to learn "just javascript". Things in js world change so fast that we can barely keep up. I'm so thankful that I got a job as a python developer. But, when i was searching for jobs, I spent time learning reactjs. Then, I realized not everything can be done through react easily. So, I transitioned to angularjs. I had to learn nodejs and typescript too. This was back in 2017. Now, I look back through my udemy courses and a major portion of reactjs have got updated and there's again a learning curve.
https://trackeasy.fun/usps/ https://showbox.tools/

Why is this ? Or is it me who's making a big deal out of this. If so, how do javascript developer keep up with things changing so fast?

Please give me your feedbacks
Is there a way in CSS to enable Chrome's "Print Background Graphics" option ?

Tags: css
Published: 2020-02-29 09:02:58

Hello everyone,,
I have a page with table borders on it. When I go to print the page, the borders don't show up.
https://speedtest.vet/ https://vidmate.bid/
This is because "Print Background Graphics" option is not enabled by default in Chrome. If I turn this on, the borders appear in the print preview and print OK.

Is there a way in the body of the html to include a command to turn on the option to Print Background Graphics?
Debugging story of the week: Cargo refused to build my project - A Rust debugging story!
Tags: debugging, story, discuss, rust
Published: 2020-02-29 08:38:35

This is Debugging Story of the Week. A series where each week I post my favourite Debugging story from the interwebs, and why I think they're interesting. You are most definitely invited to share your debugging story.

This week it is from Raunak (@rrampage), it's my favourite because it shows how your code can fail to compile even when you've done nothing wrong. You can install the language using the right tools, write the perfect code, use all secure packages that are compatible with each other, and yet your code can fail to compile. His knowledge of compilers and linkers came in handy while debugging and thankfully the [Cargo Book](https://doc.rust-lang.org/cargo/reference/) had good documentation. If a tool doesn't have proper documentation, it is easy to get lost in guessing where the error could be originating from.

![If you want them to RTFM, write a better FM](https://external-preview.redd.it/cYLaCmWIjE17sMtkZCR7NKtcnOtgzkEm-e8QXURcgqM.jpg?auto=webp&s=9f8f8cecd588a44d932e1e42c5a9f523cb8db315)

Check out Raunak's story below and tell me what you think.

https://dev.to/rrampage/cargo-refused-to-build-my-project---a-rust-debugging-story-25e9

We all have debugging stories where in the end, we might even feel stupid (we all do). I think we should all share these stories with each other, so that when someone comes across a similar problem, they don't have to spend time pulling their hairs out wondering what went wrong.

So, what's your debugging story?
Learning Frontend as a Backend dev
Tags: backend
Published: 2020-02-29 08:10:59

Hello everyone,,
I thought I'd pull the community for tips on learning Frontend development.
https://snaptube.cam/ https://syncnet.onl/telegram-web/ https://9apps.cam/
I've been writing backend software in various forms for many, many years now. Even so, Frontwnd feels magical and scary.

It's definitely a skill I'm missing, but I wouldn't know where to start now.

Has anyone done this particular journey? Any tips????
Something you may not know about console log in JavaScript
Tags: javascript, webdev, tutorial
Published: 2020-02-29 08:35:44

---
title: Something you may not know about console log in JavaScript
published: true
date: 2020-02-29 01:00:00 MST
tags: Javascript, webdev, tutorial
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/lwui5m66utf8ovk9ej8v.jpeg
canonical_url: https://developerbacon.ca/articles/something-you-may-not-know-about-console-log-in-java-script/
---

## [The normal stuff](#the-normal-stuff)

The basics for the `console.log()` in JavaScript is just this:

```js
console.log("Hello World!");
```

## [Adding styles](#adding-styles)

But did you know that you can stylize the text you are logging? To add styles to the text you just need to add `%c` to the beginning of the text that you want to style. For an example of this in action, this is the welcome message for Developer Bacon.

```js
console.log(
	"%cWelcome to the console of developer bacon",
	"color:pink;text-transform:uppercase;font-weight:bold;"
);
```

## [Adding more styles](#adding-more-styles)

To add more styles to other text in the same console log you need to add the `%c` just before the second group of text. You can add as many of these indicators as you want you just need to add a new style group for each text group. Here is an example of multiple styling groups in action.

```js
console.log(
	"%cThis text will be bold. %cThis text will be red. %c This text will be small",
	"font-weight:bold;",
	"color:red;",
	"font-size:8pt"
);
```

Originally posted on [developerbacon.ca](https://developerbacon.ca/articles/something-you-may-not-know-about-console-log-in-java-script/)
Internal Domains with DNSMasq and Pi-Hole
Tags: dnsmasq, pihole, docker, dns
Published: 2020-02-29 07:37:55

Running services inside your own household is an absolute blast.  It usually starts with some application you need to keep running after you close your laptop.  Before you know it, you have a Raspberry Pi in every room, at least one Intel NUC, and a small server rack in your Amazon shopping cart.

When going down this path myself, I noticed an interesting problem arose after I introduced the second server.  Talking to one machine is easy, just memorize the static IP.  But once you start to introduce multiple machines or multiple services on the same machine, it becomes a game of "what IP, what port, what path."  And for the other people in the household, it's impossible to understand.

For me to continue, I needed my own DNS server.  Luckily, I already introduced one into my ecosystem when I starting running Pi-Hole (for blocking tracking/ads).

In the next section, I'm going to show you how to quickly augment Pi-Hole to serve internal domains as well as block those pesky external domains.

---

## 1. DNSMasq

Pi-Hole, under the hood, is running DNSMasq.  So we want to provide it with some additional hosts to resolve.

First is the additional configuration to run _after_ Pi-Hole:

{% gist https://gist.github.com/stjohnjohnson/d441e26e4d77a975fd3ebb4e6f19e3d6 file=internal.conf %}

Second is the list of hosts and their static IPs:

{% gist https://gist.github.com/stjohnjohnson/d441e26e4d77a975fd3ebb4e6f19e3d6 file=internal.list %}

## 2. File Placement

The `.conf` file should be placed in the `/etc/dnsmasq.d/` folder.  And the `.list` file should be placed in the `/etc/pihole/` folder.

For this demonstration, we're going to manage Pi-Hole locally in a Docker container.  Here is my `docker-compose` file that mounts those files correctly:

{% gist https://gist.github.com/stjohnjohnson/d441e26e4d77a975fd3ebb4e6f19e3d6 file=docker-compose.yml %}

## 3. Validating

If we run Pi-Hole with those settings, we can validate they are accepted by using `dig`:

```bash
$ dig @127.0.0.1 haas.example.com +short
10.0.0.205
$ dig @127.0.0.1 pihole.example.com +short
10.0.0.205
$ dig @127.0.0.1 plex.example.com +short
10.0.0.210
$ dig @127.0.0.1 go +short
10.0.0.215
$ dig @127.0.0.1 modem +short
192.168.100.1
```

And that external domains are still routed:

```bash
$ dig @127.0.0.1 google.com +short
172.217.5.206
$ dig @127.0.0.1 github.com +short
192.30.255.113
```

## Appendix

All of the steps and configurations you saw in this guide are available to checkout from [my GitHub Gist](https://gist.github.com/stjohnjohnson/d441e26e4d77a975fd3ebb4e6f19e3d6):

```bash
$ git clone https://gist.github.com/d441e26e4d77a975fd3ebb4e6f19e3d6.git
...
$ cd d441e26e4d77a975fd3ebb4e6f19e3d6
$ make
...
```
Youtube Video: Difference between Throw and Throw Exception in C#
Tags: csharp, webdev, dotnet, visualstudio
Published: 2020-02-29 07:15:36

---
title:  Youtube Video: Difference between Throw and Throw Exception in C#
published: true
description: Youtube Video: Difference between Throw and Throw Exception in C# Interface
tags: Csharp, WebDev, dotnet, VisualStudio
---

In this video, We are going to see the difference between Throw and Throw an exception in C#.  In this video, I am also going to explain what are the best practices for using throw in C#.

Lots of people make these mistakes and aim of this video to clarify the confusion between Throw and Throw(ex). 


{% youtube iioIzUFV1Ns%}

Source Code for this video is available on - https://github.com/JalpeshVadgama/ThrowBestPractice

So as a best practice you should always use Throw instead of Throw(ex)


If you like this video and wanted to see a similar kind of video then, please subscribe to my youtube channel at - http://bit.ly/codewithjv.

Also, Do let me know what more content you wanted to see in C# and DotNet.
Write gorgeous documentations for your products using Markdown inside your Laravel app
Tags: laravel, vue, php, opensource
Published: 2020-02-29 07:02:56

I've been working on a personal project using Laravel. It is a simple web-based API. As with every API, I came to a point where I had to write some documentation for any future users.

After some quick research, I came across the [LaRecipe](https://github.com/saleem-hadad/larecipe) package. I was facilitated by the simplicity and the intuitive frontend design. It basically saved me tons of time and I could just focus on writing my documentation in Markdown!

## Introduction

LaRecipe is simply a code-driven package that provides an easy way to create beautiful documentation like this for your product or application inside your Laravel app. However, the usage of LaRecipe is not limited to creating documentation only. See an example.

LaRecipe uses some open-source third-party libraries/packages, many thanks to the web community:

* Laravel
* VueJs 
* TailwindCSS 
* erusev/parsedown-extra
* symfony/dom-crawler 
* phpunit/phpunit 
* orchestra/testbench

## Installation

You need to have Laravel and `composer` already installed, besides that all you need to do to install the LaRecipe package is to run the following command:

```
composer require binarytorch/larecipe
```

After that you have to run the install command to publish the needed assets and configurations:

```
php artisan larecipe:install
```

This is it! Then you will have your documentation ready at `your_domain.com/docs`.

## Configuration

After installing LaRecipe your configuration file would be stored at `config/larecipe.php`. 

In this file, you can find various options to change the configuration of your LaRecipe installation like changing the default `/docs` route, adding extra versions for your API, caching, SEO settings a more.

It even has a built-in search functionality powered by `algolia`.

## Demo 

Here is a demo of the LaRecipe package:

https://larecipe.binarytorch.com.my/docs/2.2/overview

You can also take a look at this video by Tony Lea where he goes through a quick installation and introduction of the package:

https://devdojo.com/episode/larecipe

## Conclusion

LaRecipe is an amazing open-source package that is easy to install and configure and at the same time it has some powerful functionality that allows you to build amazing documentation that your users would love to read! 

If anyone is interested in the personal project that I've been working on, you can take a look at it here: 

https://quizapi.io

It is still under development but I hope to have this ready soon :)