teleren/devto huggingface dataset:
Day 67 - #100DaysofCode - Adding Categories to Rails App
Published: 2020-08-08 02:07:25

I spent the day trying to add categories to my rails application. I am still in the process of adding some other functionality, like the nested route portion of it. However, so far, I was able to create a migration and make sure that post belong to a category and that a category can have many posts. In addition, I was able to create a drop down for each category on the posts index page. 

<h1><u> Schema </u></h1>
<h3><center> categories </center></h3>

```
  create_table "categories", force: :cascade do |t|
    t.string "name"
    t.text "desc"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
  end
```
<h3><center> posts </center></h3>
```
create_table "posts", force: :cascade do |t|
    t.string "title"
    t.text "description"
    t.integer "user_id"
    t.integer "category_id"
  end
```

<h3><u> Models</u> </h3>

<h3><center> post.rb </center></h3>

```
    #Categories section
    belongs_to :category
```

<h3><center> category.rb </center></h3>

```
class Category < ApplicationRecord
    has_many :posts
end
```
<h3><u> Views</u> </h3>

```
<%= form_tag posts_path, method: :get do %>
  <p>
    <%= select_tag "category_id", options_from_collection_for_select(Category.all, "id", "name"), {:include_blank => 'Search By Category'} %>
    <%= submit_tag "Search", name: nil, :class => "myButton" %>
  </p>
<% end %>
```

<h3><u> Controller </u></h3>
<h3><center> Posts Controller </center></h3>

``` 
if @category = params[:category_id]
        @posts = Post.where(category_id: @category)
        render 'index'
      else
        @post = Post.all
        @categories = Category.all
      end
 end
```

I need to refactor my code so that ``Post.where(category_id: @category)`` is in my model, instead of my posts controller, but my categories functionality seems to be coming together. I will work on it more and share the final code in the near future.

As always, thanks for reading!

Sincerely, 
Brittany

Song of the day: Yet, another throwback

{% youtube ZSM3w1v-A_Y %}
Day 66 : #100DaysofCode - Creating a Follow/Unfollow in Rails
Published: 2020-08-08 01:49:36

I created a follow/unfollow method in my rails application. It wasn't that difficult to implement, but the logic took a moment. 

<h1> Migration </h1>
First I created the Follows Migration. 

```
class CreateFollows < ActiveRecord::Migration[6.0]
  def change
    create_table :follows do |t|
      t.belongs_to :user
      t.belongs_to :post

      t.timestamps
    end
  end
end
```
<h1> Models </h1>

Then I updated the models for user and post. 

``post.rb`` 

```
 #Follow Section
    has_many :follows, dependent: :destroy
    has_many :users, through: :follows
```

``user.rb``

```
has_many :follows
```

``follow.rb``
```
class Follow < ApplicationRecord
    belongs_to :company
    belongs_to :user

    validates_uniqueness_of :user_id, :scope => :post_id
end
```

<h1> Views </h1>
Then I wanted to display a follow/unfollow button based off if a user was following or not in the view.

```
<%# Follow this post%>
<% if current_user.followed?(@post) %>
  <%= button_to "unfollow", post_follows_path(@post.id), class: "myButton" %>
<% else %>
  <%= button_to "follow", post_follows_path(@post.id), class: "myButton"  %>
<% end %>
```

<h1> Model Method </h1>

I created the ``followed?`` method inside of my user controller so that it would work with the current_user logged in.

```
  def followed?(post)
      follow = Followed.find_by(user_id: self.id, post_id: post.id)
    end 
```

<h1> Routes (nested) </h1>
Lastly, I updated my route to have a nested route for the post:

```
 resources :posts do 
    resources :follows, only: [:index, :create]
  end  
```

And that is it, a simple follow/unfollow function on my rails application. 

Thanks for reading!

Sincerely,
Brittany

Song of the day: A throwback 💕 

{% youtube V0lw3qylVfY %}
My Vim Journey :)
Tags: vim, beginners
Published: 2020-08-08 01:42:44

This all started when the pandemic began and we started working from home. At that time, I thought of learning something cool which would allow me to upskill my editing ability as well as becoming a good developer.

So one of my teammates told me about `Vim` and all of the good stuff about it!! I knew about `Vim` but the only thing I knew was opening it by mistake and then trying to quit it (which I think is most of the new guys :rofl:). 

I started seeing some screencasts and videos on youtube videos to see what all the fuss is about. After seeing all features of vim, I thought of giving it a try!! (Thank God I did this! :satisfied:). 
After setting up `Vim` and using it felt a bit different and difficult at the same time. But as I started using it in most of my development work like in `Xcode using XVim2`, `Chrome using Vimium`, and `Vim` with its awesome plugins, I got a hang of it. Then as I was progressing, my teammate told me about this great book [Practical Vim](https://www.amazon.in/Practical-Vim-Edit-Speed-Thought-ebook/dp/B018T6ZVPK). So I started going through all the exercises and code in it, and as I was trying everything  I got excited to see how I can do my previous work in no time using this modal editing which is like a whole new realm for me.

After learning all this (after 1.5 months), I started using vim for my office work too, and I saw a huge time gap between the work that previously used to take hours but now took mere minutes. :smile:

While I was seeing all the screencast and talks from youtube, I got to know about this [Vim Screencast pl by Greg Hurrell](https://www.youtube.com/playlist?list=PLwJS-G75vM7kFO-yUkyNphxSIdbi_1NKX). As I went through this playlist, I got to know about how cool the vim is and how I can even optimize my workflow even more.

For me, the journey has just started as I am still trying to learn out vim every week for making my work fun, easy, and efficient! 

Thank you all reading!! :smile: :upside_down_face: :blush:
(PS: This is my first ever post on any kind of technical thing)
Video: How to build a Twitter bot in 10 minutes
Tags: nocode, tutorial, video, visualdevelopment
Published: 2020-08-11 05:41:23

---
title: Video: How to build a Twitter bot in 10 minutes
published: true
date: 2020-08-08 01:39:29 UTC
tags: NoCode, Tutorial, Video, VisualDevelopment
canonical_url: https://maxkatz.org/2020/08/07/video-how-to-build-a-twitter-bot-in-10-minutes/
---

This videos shows how to build a Twitter bot with Zapier in under 10 minutes. The video is based on [How I built a Twitter bot with no-code in 10 minutes](https://dev.to/maxkatz/how-i-built-a-twitter-bot-with-no-code-in-10-minutes-43n9) blog post.

{% youtube Ft1Kusw0Ado %}

Check it out and let me know what you think. This is part of my journey to take an application built with code and build it with no-code tools. If you know any solutions built with code that I should try to build with no-code – let me know! You can also check out other [no-code videos](https://www.youtube.com/watch?v=I7wIIevk3MM&list=PLSAWywyhniCOpvlFSfUWVNAbclc2-1Kne) I have published.
3 awesome open-source iconsets! 🧰
Tags: css, opensource, design, uiweekly
Published: 2020-08-08 01:23:55

Over the past few weeks I’ve been creating a list of my favorite open-source icons. They’ve really expanded my thinking on different styles and trends in the design world. Let’s get started!

## [CSS.gg](https://css.gg)
CSS.gg is a minimalist library with over 700+ icons for CSS, SVG, Figma, Adobe XD, and more! CSS.gg also was created by @astrit

![CSS.gg](https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6a0e5d6f-b66b-4a62-b012-9586b1b897f3_1920x962.png)

With over 6000+ stars on Github, this open-source project is no joke. Each icon is very precise and detailed.

I’ve used [CSS.gg](https://css.gg) for a project in the past and it worked very well. Easy-to-setup, lightweight, and customizable. All very important features I look for.

## [FontAwesome](https://fontawesome.com)
Yep, I’m assuming you saw this one coming. With the huge library of icons and styles, this tool has taken web designers by storm. ⚡

![FontAwesome](https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F767b450e-5694-4ad0-ac70-e67628841220_1200x630.png)

With icons for every occasion, you’ll be set. 👍

You can either go with the free plan or purchase the pro membership which includes:
-6000+ more icons
- More styles and brand choices
- Pro licenses
- And much more!
I’m also pretty hyped 💪 for FontAwesome right now because version 6 is soon to release! I can’t wait to use their new styles which have a thinner and more modern feel.

## [HeroIcons](https://heroicons.dev)
Some have heard of it, some haven’t. The point is that you’ve now heard of it!

[Heroicons.dev](https://heroicons.dev) is another magnificent open-source icon toolkit with a very modern style.

![HeroIcons.dev](https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F72658cde-65b5-4821-8ceb-2faa325eb187_1280x640.png)

To be honest, I recently found this while browsing Indiehackers…

…and boy am I glad I did!

Heroicons has a very clean and unique style to it that makes any design feel fresh. I love that. It also has a solid and regular style just like FontAwesome which is pretty cool. I am planning to use this in BuildFaster’s website very soon.

---

*This story is an extract from [The BuildFaster Update](https://buildfaster.substack.com).*

*View the full post [here](https://buildfaster.substack.com/p/update-06-we-all-icons)* 👈
LaTeX documents
Tags: compilers, latex, coding, cheatsheet
Published: 2020-08-08 00:43:56

We have been using word processor and many smart office systems that we starts thinking to response that yes I coded my resume.

Yes I created my resume in LaTeX programming and you should try it. The LaTeX project says that

>'You get what you see'.

You can read more about LaTeX and it's working but here I am going to provide you cheat sheet which I prepared when I wrote my first LaTeX document.

##LaTeX document structure

document class
use packages
definitions and macros
title page content
\begin document
...
...
\end document

and ignored extras



##LaTeX command instructions



`%` for single line comment

`\begin{document} . . . \end{document}`

`\documentclass[10pt,a4paper,twoside]{article}`

`\usepackage[property_name]{package name}`

`\author{hello_vatsal}`

`\title{intro}`

`\begin{itemize} . . . \end{itemize}`

`\begin{enumerate} . . . \end{enumerate}`


`\& for &` `\% for %` for special characters use `\` other examples are # { $ _ " '

`\t{00}` `\AA` `\0e` `\day` `\pound` `\copyright` `\pi` `\Pi`

`\date{specify}` example `\date{\today}` _but remember that \maketitle is required to use command \today_



_Create your own environment commands by_ `\begin {command} . . . \end {command}`

_To create new line break use_ `\\`

`\section {give name}`

`\subsection {section name : number}`

`\subsection { : : }`

`\tableofcontents` _Make sure to use after maketitle command_

`\newpage`

`$...$` to insert inline formulas

`$$...$$` to insert center justified formulas

`\begin {array}`

`^ {}` for super scripts

`- {}` for sub scripts

`\begin {eqharray} enter equation here \end {eqharray}`

`\nonumbe` use this in above statement to skip numbering of equation


`\begin {figure}`

`\begin {minipage}`

`\input {path}` to import files

`\VSpace {-0.5cm}`

`\begin {aligh}`

`\begin {aligh*}`

`\begin {tabular} {# of col, alignment, vertical yes/no}`

`\hline`

`\cline {column start - column end}`

`\begin {table}` this contains tabular as child element

`\caption { }`

`\label { }`



`\textbf { }` make bold face

`\textit { }` make italics

`\textsc { }` capitalize

`\textsf { }` distinguished

`\textsl { }` slant

`\texttt { }` typewrite fonts

`\emph { }` emphasize

`\color {color name}` first import color package

`\tiny`  SIZE

`\scriptsize`  SIZE

`\footnotesize`  SIZE

`\small`  SIZE

`\normalsize`  SIZE

`\large`  SIZE

`\Large`  SIZE

`\LARGE`  SIZE

`\huge`  SIZE

`\HUGE`  SIZE




###I'm planning to make this cheat sheet more readable and organized so it is easier to understand. Please share your views in comment below.
Why I created a Node.js backend service for my portfolio site
Tags: node, webdev, showdev
Published: 2020-08-08 00:38:32

**When I originally wrote this I used Google's Firebase Cloud Functions and has since changed, this post has been slightly updated to reflect that**

When I started developing [my website](https://lorna.dev) I never thought I'd be using a back-end API service, I mean what's the need? Surely a portfolio should be pretty simple and at minimum contain pages such as about, projects and contact?

For a while now, I've been spending a lot of my spare time working on projects and getting to grips with new tech - including Node.js. I created an opportunity for myself to showcase what I've learnt.

I've developed a API Node.js back-end service to do the following:
- Projects (GitHub)
 - Get all repos with basic stats
 - Get repo readme
- Blog (DEV.to)
 - Get all posts with basic stats
- Email (Nodemailer)
 - Send contact email

You can find the [repo here](https://github.com/lornasw93/my-apis). I have a config file that's included in gitignore for smtp settings, github token and twilio dets. If helpful I can include the layout of this here at some point? Anyway...

I'm still learning Node.js and next I want to tidy the code base up i.e. add controllers, services and routes. Thank you for reading and any feedback is welcome. 😇
What's the best on-boarding experience you've had?
Tags: discuss, career, management, teamwork
Published: 2020-08-08 00:27:08

Adding new engineers to an existing project or team can be a challenge for many reasons. 

If your team is new and growing rapidly (startup), it might be hard just to find time to work on on-boarding process, docs, and trainings. If your team is well-established, there could be a ton of 'tribal knowledge' about how and why things are the way they are. And if the new hire is replacing someone who's already left, well, there can be knowledge gaps.

As a hiring manager I've seen it go both ways. I'm curious what has worked well for *you*, either when joining a new team or adding people to your project.
GitHub README on portfolio project page
Tags: github, node, webdev, showdev
Published: 2020-08-08 00:18:55

*Please note: my approach with the code feels dirty and needs improving. Nevertheless I felt was worth sharing. 🎉*

![enter](https://media.giphy.com/media/q6RoNkLlFNjaw/giphy.gif)
 
I wanted to improve my [portfolio website](http://lorna.dev/) - specifically the projects and blog page where originally both links just redirected the user elsewhere. I created a card layout page (for projects) and for each project displayed basic details such as name, URL and created date etc. Initially I was planning on displaying the readme file when a user clicked on a card. Since, my objectives changed and I decided to leave it. Nevertheless, it was interesting to work on so thought I'd share. 😎

I briefly talked in [this post](https://dev.to/lornasw93/using-node-js-to-get-useful-github-data-54ne) about why I chose not to use the GitHub API - essentially I wanted something quickly. 

From this... [(Readme)](https://github.com/lornasw93/api-the-musical-kind/blob/master/README.md)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rwt4momipxk3lab9ccyh.PNG)
 
To this...
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ea5q56xy0plhecemhm4t.PNG)

To keep this post short and sweet, I'm gonna jump right into the code. Basically fetching the html of *article*. 👀

```
var express = require("express"),
  app = express(),
  bodyParser = require("body-parser"),
  axios = require("axios"),
  cheerio = require("cheerio");

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

app.get("/repo/:name/readme", (request, res) => {
  var repo = request.params.name;

  axios({
    method: "get",
    url: `https://github.com/lornasw93/${repo}/blob/master/README.md`,
  })
    .then((response) => {
      const htmlString = response.data;
      const $ = cheerio.load(htmlString);
      const pText = $("article").html();
      res.send(pText);
    })
    .catch((err) => {
      res.send(err);
    });
});

```

Thanks for reading! Check out the [repo here](https://github.com/lornasw93/my-apis).
Example of Generators in Python
Published: 2020-08-08 00:12:54

Memory management is very important during software development, to scale it in a healthy way, knowledge of its language functions must provide the performance that will make a difference.

Let's get to know generators in Python, what it is, how to use it and the relationship with memory management.

We can define generators as iterators, with the difference that the value is not stored, the execution occurs on the fly. 

The best way to use is through functions, that you can get the value as the generation occur. 

```
def generator_function():
    for i in range(5):
        yield i

# Output: 0
# 1
# 2
# 3
# 4
```

A good use is the fibonacci numbers, if we pass a function a like that...


```
def fibon(n):
    a = b = 1
    result = []
    for i in range(n):
        result.append(a)
        a, b = b, a + b
    return result

for x in fibon(1000000):
    print(x)
```

We will probably run out of memory, because the result is being stored in a array.

With the generators... 

```
def fibon(n):
    a = b = 1
    for i in range(n):
        yield a
        a, b = b, a + b
```

We will use far fewer resources because there is no value being stored. 

This was just a simple example, but you had a view how the things work, the generators are powerful and a good friend of your system.
How to check if an object is of a particular class in JavaScript?
Tags: javascript
Published: 2020-08-08 00:00:00

---
  title: How to check if an object is of a particular class in JavaScript?
  published: true
  tags: JavaScript
  date: Sat Aug 08 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/check-instance-class-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-485272c918d333b78471058d87e4e5eb.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/check-instance-class-javascript)
  
To check if an object or an instance belongs to a certain class you need to use the `instanceof` operator.

To understand it better let's create a class `User` and instance of `User` class called `John`.

```javascript
// class User
class User {
  sayHello() {
    console.log("Hi, I'm John");
  }
}

// create an instance or object
// of User class called John.
const John = new User();
```

Now let's check if the instance `John` belongs to class `User` using the `instanceof` operator.

```javascript
// class User
class User {
  sayHello() {
    console.log("Hi, I'm John");
  }
}

// create an instance or object
// of User class called John.
const John = new User();

// check if John instance is of class User
console.log(John instanceof User); // true
```

- The syntax is `objectName instanceOf className`.
- The `instanceof` operator returns boolean `true` if it belongs and `false` if it doesn't belong to the particular class.

You can also use the `instanceof` operator to check for the instances of normal constructor functions.

```javascript
// User constructor funstion
function User(name) {
  this.name = name;
}

// instance of User construtor funtion
const John = new User("John Doe");

// check if John instance is of constructor function User
console.log(John instanceof User); // true
```

One important thing to note with `instanceof` operator is it will return true for all the classes if it belongs to the prototype chain.

Consider these 2 classes `User` and `Admin`, Where `Admin` class inherits all the properties and methods from the `User` class.

```javascript
// class User
class User {
  sayHello() {
    console.log("Hi, I'm John");
  }
}

// class Admin
class Admin extends User {
  givePermissions() {
    console.log("Giving full permissions");
  }
}

// create an instance or object
// of Admin class called John.
const John = new Admin();

// check if John instance is of class User
// the instanceof operator will return true
// since the User class is in the prototype chain
console.log(John instanceof User); // true
```

### Feel free to share if you found this useful 😃.

---
About Aimloaded 
Published: 2020-08-07 23:53:28

We are one of the latest music websites in Nigeria and Africa at large. We are building the largest inventory and <a href="https://freehitzplus.blogspot.com">Music</a> related content for the modern-day music lovers across the continent.

OUR PURPOSE
The joy of creating an atmosphere for music lovers to be able to get access to any kind of <a href="https://litemusics.com/category/album">Download Music Albums</a> of their choice is what we stand for at Aimloaded 

We provide all kinds of latest musics that brings people closer to themselves ranging from <a href="https://aimloaded.com.ng/download-mp3-simi-duduke/">Download Mp3 Simi Duduke</a>, <a href="https://aimloaded.com.ng/category/foreign-musics">Foreign Songs Download</a>, throwback music, Albums and lots of packages that bring people together to live in the moment and unite people's feelings with music's that touches the soul. Thereby providing a good and very accessible route to download the music of your choice through shared experiences that evoke feelings of togetherness and pride.

Aimloaded is about a sensory-led experience that allows you to see, touch, feel and breathe something greater than yourself in the best memorable experience. This develops an intuitive consciousness of the musical environment and spaces that you find yourself in. We aren’t just a <a href="https://fastmp3plus.blogspot.com">Music</a> blog. We are a blog centered around your community and day to day activities.
Cohort 8 Recap
Tags: react, firebase, javascript, css
Published: 2020-08-04 03:10:29

Watching folx come to Collab Lab and grow their collaboration skills is, without a doubt, one of my favorite parts of life. We’ve just wrapped [Cohort 8](https://the-collab-lab.codes/about-us/#cohort-8) and I am incredibly grateful to have gotten the chance to work on such a fun, ambitious team of developers! 

![The Collab Lab Cohort 8 on a Zoom call](https://dev-to-uploads.s3.amazonaws.com/i/7brv084hruutg8ojcmcz.png)

## The team:

- :hibiscus: [Shajia Abidi](https://twitter.com/abidishajia)
- :star2: [Lily Zhou](https://twitter.com/lilymzhou)
- :crystal_ball: [Ali Thompson](https://twitter.com/alilynnet)
- :sunny: [Luka Baramishvili](https://twitter.com/Lukabaram)

## The mentors: 

- :blossom: [Adrienne Lowe](https://twitter.com/adriennefriend)
- :sparkles: [Stacie Taylor](https://twitter.com/the_real_stacie)
- :boom: [Andrew Hedges](https://twitter.com/segdeha)

Each member of this team is incredibly gracious and humble. Throughout their eight weeks together, they were always sharing credit for a job well done and lifting each other up! When it came to code reviews they were great about accepting and incorporating feedback and even proactively asking for it.

Shajia, Lily, Ali, and Luka are all strong technically, but completely understood the importance of learning good team practices. They consistently inspired me with their organized and thoughtful weekly demos and their teamwork was absolutely inspiring. 

I enjoyed spending time getting to know each member of Team #8 and cannot wait to see what the future holds for them!