teleren/devto huggingface dataset:
Reverse Collection in Swift 4
Tags: reversecollection, example, swift, code
Published: 2018-09-10 16:10:40

---
title: Reverse Collection in Swift 4
published: true
tags: reverse-collection,example,swift,code
canonical_url: 
---

Ever need to reverse the characters in a String or indices in a for loop? You can use **ReversedCollection** for that.

Here is a quick example for using reversed on a String.

![](https://cdn-images-1.medium.com/max/1024/1*hMnXB1k2xXYrPKEdQ8f8qg.png)<figcaption>Reversing a String</figcaption>

You can also store the newly reversed String into another variable:

![](https://cdn-images-1.medium.com/max/1024/1*28xkT2rSXX0_YG1bSuaRnA.png)

Looping through indices and their reversed indices is very easy as shown below.

![](https://cdn-images-1.medium.com/max/1024/1*4JiozoKX-wqgeEwsg7ofFg.png)<figcaption>Reversing indices</figcaption>

The great thing about reversed is that you do not create new storage. You can also transform the reversed elements in a collection and get back a new array:

![](https://cdn-images-1.medium.com/max/1024/1*3IpwI21DxMDgOtgOwpm3gw.png)<figcaption>Reversing numbers and transforming the results</figcaption>

Here is one more example of enumerating the indices along with the reversed elements in an array:

![](https://cdn-images-1.medium.com/max/1024/1*c2o9vtLNfiNm_E90VBqfMw.png)<figcaption>Enumerating list in reverse order</figcaption>

From Apple’s documentation:

The reversed() method is always lazy when applied to a collection with bidirectional indices, but does not implicitly confer laziness on algorithms applied to its result. In other words, for ordinary collections c having bidirectional indices:

- c.reversed() does not create new storage
- c.reversed().map(f) maps eagerly and returns a new array
- c.lazy.reversed().map(f) maps lazily and returns a LazyMapCollection

### Where to go from here?

You can check out Apple’s API on [Reversed Collection](https://developer.apple.com/documentation/swift/reversedcollection) for more information.
How to add code highlighting to your Dev.to posts.
Tags: explainlikeimfive, postwriting, markdown, codeception
Published: 2018-09-10 12:21:34

---
title: How to add code highlighting to your Dev.to posts.
published: true
description: Way too many posts on Dev.to lack code highlighting, let's change that.
tags: explainlikeimfive, postwriting, markdown, codeception
cover_image: https://thepracticaldev.s3.amazonaws.com/i/77oanfb0c05w88jlmc8s.jpg
---

The simple truth of the matter is that:

```javascript
const turorialFunction = (name) => {
  console.log(`Hello ${name}`)
}
```

does look way nicer than:

```
const turorialFunction = (name) => {
  console.log(`Hello ${name}`)
}
```

when writing a post here on Dev.to.

<hr />

## How to do it

Dev.tos posts are based on Markdown. Within Markdown we can use *identation* or so called *Code Blocks* to specify sections of code. The later ones are indicated using <code>&#96;&#96;&#96;</code>. Read more about this in [this cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Here-Cheatsheet#code-and-syntax-highlighting).

Using the three *`* variant we can also specify a language for the code block. A lot of tooling build on top of Markdown utilized this characteristic to implement richer features. But the simplest of them is code highlighting. The above nicely colored code snippet is achieved by starting the code block with <code>&#96;&#96;&#96;javascript</code>.

The full example for the above would be:

<pre>
&#96;&#96;&#96;javascript
const turorialFunction = (name) => {
  console.log(`Hello ${name}`)
}
&#96;&#96;&#96;
</pre>

And if you are now wondering how the hell I got that to display:

<pre>
&lt;pre&gt;
&#96;&#96;&#96;javascript
const turorialFunction = (name) => {
  console.log(`Hello ${name}`)
}
&#96;&#96;&#96;
&lt;/pre&gt;
</pre>

and the inline code is: `<code>&#96;&#96;&#96;</code>`.

<hr />

Here is where my explanations stop and your colorful posts start.

![](https://thepracticaldev.s3.amazonaws.com/i/qo5l9o8xz3v4u5i56k58.png)

<small>The list of supported languages is impressive, though not all encompassing (check comments).</small>
Mildly interesting: Have you ever walked through a computer?
Tags: vintage, technology, culture
Published: 2018-09-10 12:06:50

---
title: Mildly interesting: Have you ever walked through a computer?
published: true
description: Running Fortran II on an IBM 1401 mainframe.
tags: vintage,technology,culture
---

Never forget that times won't stop changing, not even now.

{% youtube uFQ3sajIdaM %}
Global Terraform plugin installation
Tags: terraform, plugin, global
Published: 2018-09-10 11:38:01

---
title: Global Terraform plugin installation
published: true
description: How to install terraform plugins globally?
tags: #terraform #plugin #global
cover_image: https://thepracticaldev.s3.amazonaws.com/i/bkq805aydwv5imr31qe0.jpg
---

simply add this `TF_PLUGIN_CACHE_DIR` to your environment variables and future plugins downloaded with `terraform init` will go there:

```
TF_PLUGIN_CACHE_DIR=$HOME/.terraform.d/plugin-cache
```






links:
- cover image by geralt/Gerd Altmann https://pixabay.com/en/arrows-center-inside-middle-1426326/
- https://github.com/hashicorp/terraform/issues/15801#issuecomment-408645788
- https://www.terraform.io/docs/configuration/providers.html#provider-plugin-cache
What's your atomic bomb?
Tags: discuss
Published: 2018-09-10 10:11:42

---
title: What's your atomic bomb?
published: true
description: 
tags: discuss
---

Inspired by [Software that helps](https://dev.to/bertilmuth/software-that-helps-33ge), except I disagree with Bertil's implicit assertion that all software is helpful in the long run :) The development of the atomic bomb is the classic example of how diffusion of responsibility through a team and/or management structure helps people rationalize working on all kinds of stuff. Likely none of us have reached the ethical depths plumbed by Oppenheimer and his team, but what _aren't_ you proud of?

I worked in advertising for a few years, making it easier to waste paper and annoy people worldwide with those mailers from car dealerships you throw away without looking at. I'm never working in advertising again.
The fine line between a well designed system to an over engineered one
Tags: discuss, architecture
Published: 2018-09-10 09:44:06

---
title: The fine line between a well designed system to an over engineered one
published: true
tags: discuss, architecture
---

As developers and engineers we often try to build the perfect system that can handle every situation correctly. But building this kind of system takes a long time, it is usually involves a more complex architecture and at the end of the day you realize that you don't need this fancy design and complexity.

So how do you stop your "perfectionist you" but still maintaining a well designed system?


My two cents is that I usually map what the current challenges of the system are (e.g number of users, expected traffic, data modelling...) and if possible also to understand what is the next version, if the product roadmap is long enough. Then I am designing a system which overcome these challenges only. It has a clear downside, you can find yourself refactoring a lot but on the other hand you deliver quickly what is needed and can provide more value to the product.

Looking forward to hear your thoughts :)
TLDR GraphQL?
Tags: discuss, graphql
Published: 2018-09-10 09:14:31

---
title: TLDR GraphQL?
published: true
cover_image: https://thepracticaldev.s3.amazonaws.com/i/lq04j7osxuozm8ebo91g.png
description: Hey Friends, I am writing a Tl;Dr (Too long; Didn't read) blog post about Using GraphQL on the client side, and I need your help
tags: 
    - discuss
    - graphql
---

Hey Friends, I am writing a Tl;Dr (Too long; Didn't read) blog post about Using GraphQL on the client side.
Mainly for folks to get the information they want without getting overwhelmed with long documentation.

I have a lot in mind to write about already, like basic querying, Fragments, arguments etc... and I would like you to help me with more information.

What was the information you wished you knew when working with GraphQL and or you wished there was a better explanation for it?

I am planning to post the blog post in the next 2 days

Cheers,
Khaled
Auto backup of Databases in Postgres Container.
Tags: docker, database, learning, postgres
Published: 2018-09-10 07:11:11

---
title: Auto backup of Databases in Postgres Container.
published: true
description: 
tags: docker, databases,learning, postgres
---
**1. Create A file in Container.**
	<code>touch /path/\<file> </code>
	(ex. touch /data/bkp_cmd.sh)

**2. Write Backup command to that file.**
	<code>echo "pg_dumpall -U postgres -f /path/file" >> \<file> </code>
	(ex. eg. echo "pg_dumpall -U postgres -f 
        /data/files/backup_``date +%Y%m%d``.sql" >> bkp_cmd.sh )

**3. Make file executable.**
	<code> chmod 777 \<file> </code>
	(ex. chmod 777 /data/bkp_cmd.sh )
	
**4. Append cron file.**
	<code>crontab -e </code>
	<code>00 00 */15 * * /data/bkp_cmd.sh >> /data/logs/cron_logs.txt 2>&1 </code>
	You can generate cron command [here.](https://crontab-generator.org/)
	if no editor is installed then
	Append command to cron file via
	<code>(crontab -l && echo "00 00 */15 * * /data/bkp_cmd.sh >> /data/backup_cron_logs.txt 2>&1") | crontab - </code>

**5. Check whether cron service is running or not.**
	<code>service cron status</code>
	If it it is not running, start it by command
	<code>service cron start</code>
	
**5. Wait and check the backup file at specified time.**

Thanks for reading! 😊
Please leave a comment if you have any suggestions or you have any doubt.
Is programming considered some kind of art ?
Tags: discuss
Published: 2018-09-10 05:59:12

---
title: Is programming considered some kind of art ?
published: true
description: 
tags: #discussion
---

Everyone heard it before, Jobs can be considered art. And i am not even talking about all the creative jobs out there. I mean the normal ones.

For example, customer service agent handling the customer and making him satisfied and happy.

This can also work for all jobs like doctors, sales, teachers and many more.

This is just something that came up in a book i was reading. I wanted to ask you guys...

Do you feel like this in programming? 

Do you feel like someone is creating art while implementing an API or a Load balancer?

Do you feel like that particular snippet of server side code is beautiful?
JQ is a symptom
Tags: bashingbash, ngs, rant
Published: 2020-04-10 11:59:36

---
title: JQ is a symptom
published: true
date: 2018-09-10 05:48:49 UTC
tags: bashing-bash,NGS,Rant
canonical_url: https://ilya-sher.org/2018/09/10/jq-is-a-symptom/
---

[jq](https://stedolan.github.io/jq/) is a great tool. It does what bash can not – work with structured data. I use it. I would like _not_ to use it.

In my opinion, working with structured data is such a basic thing that it makes much more sense to be handled by the language itself. I want my shell to be capable and **I strongly disagree with the view that a shell “is not supposed to do that”. Shell is supposed to do whatever is needed to make my life easier**. Handling structured data is one of these things.

If “shell is not supposed to do that”, by that logic, bash is not supposed to do anything except for running external commands and routing the data between them. Doesn’t it seem odd that bash _does_ have builtin string manipulation then? Maybe bash shouldn’t have added associative arrays in version 4? … or arrays in version 2? How about `if` and `while` ? Maybe bash shouldn’t have them either?

![woman-698943_640](https://ilyasherdotorg.files.wordpress.com/2018/09/woman-698943_640.jpg?w=201)

**jq is a symptom that bash can’t handle today’s reality: structured data.** The world is increasingly more about APIs. APIs consume and return structured data. I _do_ work with APIs from shell. Don’t you guys use AWS CLI or any other API that returns JSON?

The reality has changed. bash hasn’t. I’m working on bash alternative. [Please help me with it](https://github.com/ngs-lang/ngs). Or at least spread the word.

If you don’t like my project, join [Elvish](https://github.com/elves/elvish) . Elvish is another shell that supports structured data.

* * *

Happy coding! Hope it’s not in bash.
Serverless Alexa Skill with DynamoDB
Tags: alexa, serverless, dynamodb, aws
Published: 2018-09-10 05:45:10

---
title: Serverless Alexa Skill with DynamoDB
published: true
description: My first Alexa Skill built to be dynamic and friendly non-technical people. 
tags: Alexa, serverless, dynamodb, aws
---

As the rise of personal assistants grow, I thought I’d learn a new skill and attempt to roll my own. I’ve seen various different example of users using Alexa to report on metrics, as well as different maintainability models. Of what I could find, none combined both - dynamic sentence return with ease of maintainability. 

My first Alexa skill was created as a reporting tool, where I have different appliances report in different numeric values, such as how many users have clicked on an event, or the total network packets sent through my router for a given period of time. I then used these metrics and through regex replacement, have Alexa report back to me, in a clean, easy to understand, database defined sentence. 

In my DynamoDB table I have three attributes, the metric, the total_count, and the response. When an intent is called I take the name of the intent, call it `MyExampleIntent`, and look for “my example” (casing to space) within the database. If it is there, I then take the response value - ex. `The total number of my example is {total_count}` - and return that with the numeric value from the total_count attribute. Therefore, when anyone wants to add a new intent, they can update the serverless file with the intent name and sample utterances, and then add a new item to the table with that metric. On the next deploy of the skill, you’ll see the new metric. It’s as simple as that!

Check out the project on my <a href="https://github.com/danquack/Serverless-Alexa-with-Dynamodb">GitHub</a> and let me know what you think. 

{% github https://github.com/danquack/Serverless-Alexa-with-Dynamodb %}
Ruby: class methods vs. instance methods
Tags: ruby, learning
Published: 2018-09-10 00:31:47

---
title: Ruby: class methods vs. instance methods
published: true
description: What is the difference between a class method and an instance method in Ruby?
tags: ruby, learning
---

In Ruby, a _method_ provides functionality to an Object. A _class method_ provides functionality to a class itself, while an _instance method_ provides functionality to one instance of a class.

Consider the following Ruby class:

```ruby
class SayHello
  def self.from_the_class
    "Hello, from a class method"
  end

  def from_an_instance
    "Hello, from an instance method"
  end
end
```

This would yield the following:

```
>> SayHello.from_the_class
=> "Hello, from a class method"

>> SayHello.from_an_instance
=> undefined method `from_an_instance' for SayHello:Class


>> hello = SayHello.new
>> hello.from_the_class
=> undefined method `from_the_class' for #<SayHello:0x0000557920dac930>

>> hello.from_an_instance
=> "Hello, from an instance method"
```

We cannot call an instance method on the class itself, and we cannot directly call a class method on an instance.

[Railstips](http://www.railstips.org/blog/archives/2009/05/11/class-and-instance-methods-in-ruby/) has a nice article with more detail and a discussion of alternative ways of creating both class methods and instance methods.

---
Was this helpful? Did I save you some time?

## {% cta https://www.adamlombard.com/support-me %} 🫖 Buy Me A Tea! ☕️ {% endcta %}

---

See also: [Python: class vs. instance vs. static methods ](https://dev.to/adamlombard/python-class-vs-instance-vs-static-methods-2cd0)
Working as software tester. How to start?
Published: 2018-09-09 21:35:42

---
title: Working as software tester. How to start?
published: true
description: I'm trying to work as a software tester. There is many sites where I can read how to start testing. Now I work in goverment, i have some expierence with managing new software, I program some easy applications, I know SQL and many other things but I can't be good with all.
 There is many jobs where I must have some experience witch i don't have. Can I find some Companies where they are looking to do some test for free and I will have some experience in software testing? I had read about some courses like ISTQB.PS. Sorry for my English, I learning English now.
tags: 
---
How do you commit in GitHub ?
Tags: discuss, opensource
Published: 2018-09-09 20:45:32

---
title: How do you commit in GitHub ?
published: true
description: A general method
tags: discuss, opensource
---

I don't know if it's me or my dudeist attitude but when I start a project on GitHub, the first thing I do is to create a project on my profile on the site

After that I clone the repo then I code for example a [Phaser](http://phaser.io) game to participate in a gamejam on [itch.io/jams](http://itch.io/jams) with one of my fake accounts

Then :

- git add .
    I use precisely the dot nothing else 

- git commit -m "First Commit"
    I don't know the diffrence with "Initial Commit"

- git push origin main
    OFC I use git config user.name/user.email before all this to use my fake accounts

I repeat these steps ... and never finish a project
Can editor make you a better developer?
Tags: editor, ide, vim, emacs
Published: 2018-09-09 19:27:56

---
title: Can editor make you a better developer?
published: true
description: 
tags: editor, ide, vim, emacs,
cover_image: https://i0.wp.com/tuxtweaks.com/wp-content/uploads/2011/03/Vim_Show_Line_Numbers_wm.png
---


I was attending a tech talk the other day. The speaker was an experienced developer from Silicon Valley working at a fancy company. Mostly it was a very interesting and informative talk.

One of his thoughts make me think a lot and write this post. 

"The best persons/developers I've ever met were using vim of emacs."

Whenever I tried to use vim or emacs I ended up thinking that instead of memorizing dozens of key combinations I could sharpen my skills as a developer.

So does vim or emacs really make you a better developer? 
Does it mean that preferring IDEs makes you less curious about how technologies work?
Web development boot camp grad, ask me anything.
Tags: ama, bootcamp, webdev
Published: 2018-09-09 17:32:21

---
title: Web development boot camp grad, ask me anything.
published: true
description: AMA of recent coding boot camp grad.
tags: ama, bootcamp, webdevelopment
---

I completed a 5 month full-stack web development boot camp this past August. I was self-teaching for about 2 years on the side and working in the medical field before committing to the program.

Ask me anything.
Moving from Ghost to Jekyll
Tags: tutorial, jekyll, beginners
Published: 2019-09-03 08:42:36

---
title: Moving from Ghost to Jekyll
published: true
tags: tutorial, jekyll, beginners
canonical_url: https://nervewax.com/ghost-to-jekyll/
---

Every so often I like to redo my site, while experimenting with something new. In the past i’ve used Tumblr, WordPress and Ghost, but this time i’m trying out Jekyll.

![Jekyll](https://nervewax.com/content/images/2018/03/jekyll.png)

[Jekyll](https://jekyllrb.com/) is a fairly well established static site generator, and it’s been really fun learning something new. I’m also a big fan of how neat and minimal the process has been building my site around it. I started out by watching [this video](https://www.youtube.com/watch?v=iWowJBRMtpc), which is a nice introduction to the basics of Jekyll.

## Converting my content

Transitioning from ghost to Jekyll was surprisingly easy. I used a program called [jekyll\_post\_importer](https://github.com/eloyesp/jekyll_ghost_importer) to convert my content from the ghost backup file to Jekyll’s markdown files.

After that, there was a little manual work needed to make sure all the images and tags worked ok. Luckily I’ve not written that much actual content!

## Where are my tag pages??

![Where are my dragons?!](https://nervewax.com/content/images/2018/03/wamd.gif)

So moving over from Ghost and Wordpress, I expected Jekyll to have some kind of tag structure, which it does… however Jekyll taxonomies don’t actually come with their own pages as you would expect.

In order to generate tag archive pages in the same way you’d get with a traditional blog CMS, something extra is needed.

While searching, I found [this blog](http://charliepark.org/tags-in-jekyll/), which I couldn’t quite get working, but reassured me it’s possible. I then checked out [this Jekyll plugin](https://github.com/pattex/jekyll-tagging), and that pretty much solved the problem with only a little tweaking. 🙌

So [as you can see](https://nervewax.com/tag/project/), i’ve got a page for each of my tags, and even managed to get it to pull the most recent post’s image using a bit of good old [interpolation](https://stackoverflow.com/a/41721856/2351788).

## Related content

Since all my content is tagged, I thought it might be cool to grab a related post if one is available. With very little searching I found [this clever snippet](https://blog.webjeda.com/jekyll-related-posts/), which I ended up modifying for my own use.

## So that’s it!

It’s not the CMS for everyone, but so far i’m liking it and it certainly does the job. Bonus points for fulfilling my developer need for a performant and lean codebase.

It’s also nice to be writing this directly in Atom too, now to figure out [the best way to push this to live](https://dev.to/nervewax/one-command-deploy-with-github-pages-2bf6)… 👋
What is your number 1 advice to newbies.
Tags: beginners, learning
Published: 2018-09-09 15:59:02

---
title: What is your number 1 advice to newbies.
published: true
description: 
tags: beginners,newbies, learning
---

Mine is that, don't approach programming as a reading subject. Learn the technology or language but practice more, more and some more.