teleren/devto huggingface dataset:
Use comments to figure out where you're going wrong
Tags: productivity, codenewbie
Published: 2020-08-04 03:36:21

One of the things that tends to happen to every developer is that you get get stuck with something you're working on. Your code isn't producing the result you are expecting it to.

What do you do?

Try this:

Go through every line of code and write a comment about exactly what it does. Get descriptive. What data is being used, what's the intended result.

Use a debugger, or just good old `print` statements to validate that's what is happening.

Sometimes the problem is in the expectations: The data that is really necessary is a few lines down, so reorganizing the code may help.

Sometimes the result you are getting doesn't match the result.

Walking through the code and adding comments will help clarify your thoughts and give you something solid to stand on. Try it the next time you're stuck.
Effective Java! Use EnumSet Instead of Bit Fields
Tags: java, effective, enum, architecture
Published: 2020-08-04 03:29:42

---
title: Effective Java! Use EnumSet Instead of Bit Fields
published: true
description: A dive into chapter 36 of Effective Java
tags: java, effective, enum, architecture
series: Effective Java Review
canonical_url: https://blog.scaledcode.com/blog/effective-java/effective_java_use_enumset_not_bit_fields/
---
 
Sometimes when we have an enumerated type that is primarily used in sets developers will set each value as an `int` or `long` with each being a different power of two. Something like the following:

```java

public class TextStyles {
  public static final int STYLE_BOLD = 1 << 0; // 1
  public static final int STYLE_ITALIC = 1 << 1; // 2
  public static final int STYLE_UNDERLINE = 1 << 2; // 4
  public static final int STYLE_STRIKETHROUGH = 1 << 3; // 8

  public void applyStyles(int styles) { ... }
}
```

This class can then be used using bitwise ORs to combine styles. For example:

```java
text.applyStyles(TextStyles.STYLE_BOLD | TextStyles.STYLE_UNDERLINE);
```

We can also perform union and intersection operations with this setup. It also proves to be very space efficient. All of this being said, this system suffers from the same issues that we discussed in the previous chapter. While debugging this system likely suffers from even further confusion as figuring out the current state of the variables requires considering the bits of each value. Another thing that we need to consider is how many enumerated types we will ever need to determine if we need an `int` or `long`. If we need to change this type later it is difficult to change the API throughout the system.

There is a better way built into the `java.util` package in the form of the `EnumSet` class. This class implements the `Set` interface with all of it's richness, type safety, and interoperability. On top of this the implementation is extremely efficient in using a single `long` internally if the enum holds less than 64 values. Bulk actions on the set are also performed with bitwise operations. This means that the performance is comparable to the bit method described above. This ends up being the best of both worlds. 

Let's see what our above example would look like using a proper `enum` and `EnumSet`:

```java
public class TextStyles {
  public enum Style { BOLD, ITALIC, UNDERLINE, STRIKETHROUGH }

  public void apply(Set<Style> styles) { ... }
}
```
and it's use:
```java
text.apply(EnumSet.of(Style.BOLD, Style.UNDERLINE));
```

This leads to a much safe and extensible system. This is one of the rare examples where we don't really have any real downsides. We get to keep the performance we desire with the richer API of the collections.
Ruby Modules
Tags: ruby, beginners, oop
Published: 2020-08-04 03:05:39

When we write classes in Ruby, we may find that we end up using a lot of code just for methods. In Ruby, we can use modules to abstract out any methods our class needs access to. (If you're unfamiliar with Ruby classes, you can <a href="https://dev.to/lberge17/classes-and-instances-in-ruby-3dn">check out a blog I wrote on classes and instances in Ruby here</a>). We declare modules in a similar way to classes. For example, we're going to use a class of Dog that is going to need access to many methods.

```ruby
class Dog
    attr_accessor :name

    def initialize(name)
        @name = name
    end
end
```

<h2>Instance Methods in Modules</h2>

Now that we have our class, we're going to create a module to store methods our individual dogs may need access to.

```ruby
module DogInstanceMethods
    def speak
       puts "Woof!"
    end

    def growl
        puts "Grrrr..."
    end

    def sit
        puts "*sits*"
    end

    def walk?(energy)
        if energy
            true
        else
            false
        end
    end
end
```

In order to <em>include</em> DogInstanceMethods in our Dog class, we need to use the 'include' keyword.

```ruby
# make sure to include the filename with the module at the top such as:
# require_relative DogInstanceMethods.rb

class Dog
    include DogInstanceMethods
end

jitta = Dog.new("Jitta")
jitta.speak #=> "Woof!"
```

<h2>Class Methods in Modules</h2>

Now this works great for instance methods, but what about class-level methods? When declared inside a class, we use self to tell our program we're operating on Dog as a class. However, self in the module is the module DogInstanceMethods itself. So in order to include class methods, we use the same format as above except we use extend instead of include.

```ruby
module DogClassMethods
    def species
        puts "Canis Lupus"
    end

    def fun_fact
        puts "Dogs have unique nose prints like humans have fingerprints."
    end
end


class Dog
    extend DogClassMethods
end

Dog.fun_fact #=> "Dogs have unique nose prints like humans have fingerprints."
```

<h2>Nesting Modules</h2>

Let's put our class and instance methods under the same roof in order to keep the code organized. We can nest them within a larger module called DogMethods and refer to them using 'OuterModule::InnerModule'.

```ruby
module DogMethods
    module InstanceMethods
        def speak
            puts "Woof!"
        end
    end

    module ClassMethods
        def species
            puts "Canis Lupus"
        end
    end
end

class Dog
    include DogMethods::InstanceMethods
    extend DogMethods::ClassMethods

    attr_accessor :name

    def initialize(name)
        @name = name
    end
end

jitta = Dog.new("Jitta")
jitta.speak #=> "Woof!"
Dog.species #=> "Canis Lupus"
```

<h2>Questions</h2>

Feel free to leave any questions or comments about modules in Ruby. Happy coding!
Combined backend and frontend on Github
Tags: github, fullstack
Published: 2020-08-02 04:59:48

We have been taught about updating separated repository, for backend, and frontend, on Github, for various reasons such as better deployment, and better control broken codes.
In some instances where you have to update both you backend and frontend on the same repository, like me, some people which first time experience might caught off guard since Github will not show the file, you and other people can't review your code, something like this: 
![submodule](https://dev-to-uploads.s3.amazonaws.com/i/51swqhfidaemdaynu6s3.png) 
Github probably changed its designs hence the folder might just look grayed out, or lighter color, indicating that you cannot open it on github.

So, how do you fix this issue? You will probably need to use gitignore so that Github will not interpret your files as submodule. Let's say, for my project named transmission, I have a folder called transmission, with the two subfolder for frontend and backend. Called transmission-ruby (backend), and transmission-react (frontend). Organized like this:

```
---tranmission
     |
     |---tranmission-ruby
     |
     |---tranmission-react
```

Here, both files have different languages, with node_module folders, so how does Github supposed to know which one to ignore without you telling it specifically?

### The solution

On the root folder, transmission, add a .gitignore file. 
And then for each gitignore lines that you do in a normal repo, add the names of your subfolder before it, like this, for my example:

```

# dependencies
transmission-react/node_modules
transmission-react/.pnp
transmission-react/.pnp.js
# testing
transmission-react/coverage
# production
transmission-react//build
# misc
transmission-react/.DS_Store
transmission-react/.env.local
transmission-react/.env.development.local
transmission-react/.env.test.local
transmission-react/.env.production.local
transmission-react/npm-debug.log*
transmission-react/yarn-debug.log*
transmission-react/yarn-error.log*

# Ignore bundler config.
transmission-ruby/.bundle
# Ignore all logfiles and tempfiles.
transmission-ruby/log/*
transmission-ruby/tmp/*
transmission-ruby!/log/.keep
transmission-ruby!/tmp/.keep
# Ignore uploaded files in development.
transmission-ruby/storage/*
transmission-ruby!/storage/.keep
transmission-ruby.byebug_history
# Ignore master key for decrypting credentials and more.
transmission-ruby/config/master.key
```
Okay, now we got the gitignore file to warn github about what to not push (since we have files such as Node Module on both subfolders), the next step is to delete the .git folder inside both of your subfolders, leave the .git folder at the root alone.
The process will be a little odd, because when command ```ls``` you won't see .git folder, but they are there, not just one but maybe many. You can google how to delete a .git folder.

Push on Github and now you will be able to open both folders.
Learning Cloud
Tags: aws, googlecloud, azure
Published: 2020-08-04 02:41:19

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

I created an index for my resources for learning AWS, Azure, GCP and Alibaba Cloud on a GitHub Repo - https://github.com/lynnlangit/learning-cloud.

I have links to over 100 resources, including courses, sample code (in Repos), communities, technical articles, screencasts and more.  I will continue to update this central repo as I create new content as well.
Buy Cheap Longines Replica Watches With High Quality For Men And Women
Published: 2020-08-04 02:33:26

Today, Longine's best <a href="https://www.swissreplica.is/">Swiss replica watch</a> is arguably the first brand to still have a company, unchanged, within the World Intellectual Property Organization (WIPO) global registries. The company has a long tradition, characterized by the elegance of its watches. Based in Saint-Imier since 1832, Longines has a long tradition of the watch industry. It all started with Auguste Agassiz, who partnered with a watchmaker and took over shortly after. At the time, the company made inexpensive <a href="https://tablo.io/swisswatches/breitling-superocean-heritage-46-replica-watch">replica Longines Heritage watches</a> using the establishment method, doing the work in your own home. Agassiz developed commercial bands that allowed him to market his watches on other continents, particularly in the United States.

During the 1850s, Ernest Francillon required Agassiz's cousin in control of the company. He started creating the different rounding stages from the watch together in one place. To cope with his project, he bought two adjacent plots in Les Longines in 1866 and founded the Longines factory in 1867. In 1889, Francillon registered the top logo of the Longines Tradition replica and the winged shapely logo design. Francillon's technical procedures widened, and production also continued to grow from well into the first third of the last century. In 1911 production had more than 1,100 employees, and the output was distributed worldwide.

The engineering research conducted on the Les Longines Sport replica watch has been offset by several awards, earning the company status; most awarded the watch industry company at global shows and Universal Expositions, up to and including the Barcelona World's Fair in 1929, without no less than 10 Grand Prix. in the early 20th century, Longines also affirmed his attachment to sports timekeeping. Very active in horses racing from 1878, the company excelled with a first jockey's watch by 1926 was the timekeeper for that Concours Hippique International Officiel de Geneve. At the same time, Longines grew to associated with gymnastics, skiing, tennis, and archery; but still, it is even today. Now part of the Piece of fabric Group, Earth's leading watch manufacturer, Longines Elegance, has watch mark procedures in more than 130 countries.
KDB cookbook
Tags: kdb
Published: 2020-08-04 02:24:38

I am still a KDB noob. This page will be kept updating whenever I have new tricks.

#### Display string to console**

```
0N!"Hello World"
```

#### Cast string to symbol

```
ticker:"MSFT"
ticker_symbol:`$ticker
```

### List

#### Define a list

```
mylist:(1;2;3)
```

#### Get n-th element

```
(1;2;3)[1]
```

```
{x[1]}(1;2;3)
```

#### Get first n elements

```
3#(1;2;3;4;5;6;7;8;9;10)
```

#### Get last n elements

```
-3#(1;2;3;4;5;6;7;8;9;10)
```

#### Filter list

```
even_list:{x where not x mod 2}(1;2;3;4;5;6)
```

#### Run function on each element

```
{0N!x} each ("Hello";"World")
```

```
({0N!x}')("Hello";"World")
```

#### Convert string list to long list

```
({"J"$x}')("123";"456";"789")
```

### Command line parameters

This is the command we use.

```
rlwrap q myscript.q -foo "bar" "123"
```

`.z.x`

```
arguments:.z.x
/ arguments is a list (0h) of ("-foo";"bar";"123")
```

`.z.X`

```
arguments:.z.X
/ arguments is a list (0h) of ("q";"myscript.q";"-foo";"bar";"123")
```

`.Q.opt .z.X`

```
arguments:.Q.opt .z.X
/ arguments is a dict (99h) of (enlist `foo)!enlist ("bar";"123")
```

### String

#### Get substring

```
6 8 sublist "Hello world"
```

```
6 _ "Hello world"
```

#### Join strings

```
"Hello"," ","World"
```

```
"" sv ("Hello";enlist " ";"World")
```

#### Find occurrences of a substring in a string

```
ss["Hello world";"wo"]
```

### File IO

#### Open a file where file name is in variable

```
filePath:"/tmp/test.txt"
file:hopen hsym[`$filePath]
```

#### Delete a file

```
hdel `:/home/franz/test.txt
```

#### Check if a file exists

```
not () ~ key hsym `:/home/franz/test.txt
```

#### Delete a file only if it exists

```
if[not () ~ key hsym `:/home/franz/test.txt; hdel `:/home/franz/test.txt]
```

#### Write a single string to file (Not append)

```
`:test.txt 0: enlist "Hello world"
```

### Table

#### Define a table

```
table1:([] c1:1 2; c2:`abc`def; c3:123 456)
```

#### Define a single row table

```
table1:([] enlist c1:1; c2:`abc; c3:123)
```

#### Export a table to csv

File name is same as the table name.

```
save `$"/home/franz/table1.csv"
```

#### Export a table to csv with a different file name

```
`:/home/franz/test.txt 0: csv 0: table1
```

#### Load csv file to table

`"jsj"` is the data type of each column in the csv. For example, `j` is `long` and `s` is `symbol`.

```
table3:("jsj";enlist",")0:`$"/home/franz/table1.csv"
```

### Conditional branching

#### try-catch

[Execution Control](https://code.kx.com/q4m3/10_Execution_Control/)

```
h:@[hopen;`::9999;{show "Unable to connect"; exit 1}]
```

#### Early return

Use `:` without anything on the left

```
:"Hello World"
```
Format and run SQL on save in Vim
Tags: postgres, vim
Published: 2020-08-04 02:11:03

Install and configure [ALE](https://github.com/dense-analysis/ale) in `~/.vimrc`:

```vim
call plug#begin('~/.vim/plugged')
  Plug 'dense-analysis/ale' " :help ale
call plug#end()
```

In `~/.vim/ftplugin/sql.vim`:

```vim
" Auto-fix
let b:ale_fixers = ['pgformatter']
let g:ale_fix_on_save = 1
let b:ale_sql_pgformatter_options = '--function-case 1 --keyword-case 2 --spaces 2'

" Run current file
nmap <buffer> <Leader>r :!clear && psql -d $(cat .db) -f %<CR>
```

In my [laptop.sh](https://github.com/croaky/laptop), I have a variant of the following that is idempotent; it will install or update [Homebrew](https://brew.sh/) and [pgFormatter](https://github.com/darold/pgFormatter):

```bash
# pgformatter
brew install pgformatter

# Vim plugins
curl -fLo "$HOME/.vim/autoload/plug.vim" --create-dirs \
  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
vim -u "$HOME/.vimrc" +PlugUpdate +PlugClean! +qa
```

In each of my projects, I have a `.db` file that contains only my database name:

```
example_development
```

When I save a `.sql` file in Vim, it auto-formats it with `pgformatter` using the flags from my `ftplugin/sql.vim`.

When I run `<Leader>r` from a `.sql` file in Vim, it runs the file against my `.db` Postgres database through `psql`.
Font Awesome 5 with Using a Package Manager + using Gulp 4
Tags: webdev, npm, saas, gulp
Published: 2020-08-04 01:27:54

In this article, we will learn how to add Font Awesome 5 by using the package manager and gulp 4.

1- Install Font Awesome using a Package Manager

`npm install --save @fortawesome/fontawesome-free`

or 

`yarn add --dev @fortawesome/fontawesome-free`


2- Import Font Awesome in you main SCSS file
```
// in your main SCSS file
@import '../../node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss';

// import one or more styles
@import '../../node_modules/@fortawesome/fontawesome-free/scss/regular.scss';
@import '../../node_modules/@fortawesome/fontawesome-free/scss/solid.scss';
@import '../../node_modules/@fortawesome/fontawesome-free/scss/brands.scss';

```

**Important Tip:** *to avoid getting blank squares for font awesome icons you need adding those files`otf | ttf | eot | svg | woff(2)` and they are in `webfonts` folder
you need to make sure `webfonts` folder and `index.html` are in your `dist` folder of production version*

![Alt text of image](https://dev-to-uploads.s3.amazonaws.com/i/bt61uner64s3f5rqe7a8.png)

3- Check if `webfonts` folder exists then make a copy in dist by using any file in the webfonts folder.

**Note:** *We need to pass a path for a file, not a folder because in [docs](https://www.npmjs.com/package/file-exists) of package was mentioned that:*
> The package used to check if filepath exists and is a file. Returns false for directories.

We will use [`file-exists`](https://www.npmjs.com/package/file-exists) package to check if `webfonts` exists then make a copy of `webfonts` and put in the `dist folder`  

```
// in your gulpfile
const fileExists = require('file-exists');
const gulpif = require('gulp-if');

const webFontsPath= './node_modules/@fortawesome/fontawesome-free/webfonts/*';
const distWebfonts= 'dist/webfonts';

// use a file of webfonts to check it's existing then make a copy in dist
const fontawesomeWebfont =
  './node_modules/@fortawesome/fontawesome-free/webfonts/fa-brands-400.eot';

// to check if file exists or not for testing purposes
console.log(fileExists.sync(fontawesomeWebfont)); // OUTPUTS: true or false

// copy webfonts folder if it exists
// because our task contains asynchronous code
// use async before our task
// to avoid getting this error `Did you forget to signal async completion`
async function copyfontawesomeWebfontsTask() {
  return gulpif(
    fileExists.sync(fontawesomeWebfont),
    src([webFontsPath]).pipe(dest(distWebfonts))
  );
}
```
Wow, now you can use copyfontawesomeWebfontsTask :)

Thanks for reading! I know there are many methods to do that but this method worked for me and like to share with you. 
Hope this article helps, feel free to share it with your friends, any feedback will be appreciated :)
Using DEV.to API and Node.js
Tags: showdev, webdev, node, womenintech
Published: 2020-08-04 01:21:48

On my website I originally implemented a link back to here, my blog, in the nav bar. I've been recently playing around a lot with Node.js and APIs. My aim was to display basic post info such as:
- Title
- Description
- Tags
- URL
- Created date

The end result was this: *(site isn't currently reflecting this change and isn't finished)*

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

Let's begin with the usual setup, create a new project folder in your workplace and `cd` init. Run `npm init` and install the following packages:

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

The code is pretty straightforward, a simple `GET` so just need to call `http://localhost:3000/api/posts` to get the JSON response data.

```
var express = require('express'),
    cors = require("cors"),
    app = express(),
    bodyParser = require('body-parser'), 
    axios = require('axios');
 
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

app.use(cors());

app.get("/api/posts", (req, res) => { 
    axios.get('https://dev.to/api/articles?username=lornasw93').then(resp => {
        res.send(resp.data);
    }).catch(err => {
        res.send(err);
    });
});

const PORT = process.env.PORT || 3000;
module.exports = app.listen(PORT, () => {
    console.log('Server running on port %d', PORT);
})
```

The repo lives [here](https://github.com/lornasw93/my-blogs-api).

This project is very much a work in progress so will update the repo when needed.

Thanks! 😃
Web Development - Interview Cracking Crash Course
Tags: javascript, tutorial, webdev
Published: 2020-08-04 01:03:17

## LIMITED TIME DISCOUNT - WEB INTERVIEW CRACKING

## COUPON VALID FOR FIRST 5 ONLY - First Come First Basis

[Course Link](https://www.udemy.com/course/web-dev-interview-prep)
Referral Code : DF88E564495FDE3715A1 🏆

Don't Miss, Core concepts and tricky questions discussed with explanation.
Are developers Jerks?
Tags: discuss
Published: 2020-08-04 00:56:24

Ran across a slew of questions about "why are developers rude" - etc... but it seems... well, what do you think?

https://www.reddit.com/r/learnprogramming/comments/2yhjwe/why_are_experienced_programmers_so_hostile_toward/

https://www.quora.com/Why-are-software-developers-rude
10 Questions I'm Asking All Companies Before Scheduling Any Interviews
Tags: interviewing, jobsearching, questions, career
Published: 2020-08-04 00:56:03

---
title: 10 Questions I'm Asking All Companies Before Scheduling Any Interviews
published: true
description: It's important to ask questions early to find out if you even want to work somewhere.
tags: interviewing, jobsearching, questions
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/cjke391gmk1tfx1m4yc8.png
canonical_url: https://ashleemboyer.com/10-questions-i-m-asking-all-companies-before-scheduling-any-interviews
---

Interviewing requires *a lot* of time and energy. Maybe you need to study some technical topics ahead of time. You probably already have commitments that require a lot of your focus&mdash;like another job or children. That's why it's important to be selective where you can about companies you want to interview with.

Here are the ten questions I'm using to decide whether or not I'm interested in interviewing with a company:

1. How large is the engineering team?
2. What is the make-up of the engineering team? Such as, how many managers are there, who do they manage, etc.
3. How often are one-on-ones?
4. Who are the one-on-ones with?
5. Is there career coaching?
6. Are there performance reviews?
7. How have you handled performance reviews with the pandemic?
8. What's the development process like? For example, do you work in sprints?
9. How tasks are estimated and assigned?
10. Are there regular team retrospectives?

---

Did you know I have a newsletter? 📬

If you want to get notified when I publish new blog posts or make major project announcements, head over to https://ashleemboyer.com/newsletter.