teleren/devto huggingface dataset:
What I learned today(Ruby/Rails): Splat operator 
Tags: ruby, rails, wiltrr
Published: 2020-05-08 17:47:11

---
title: What I learned today(Ruby/Rails): Splat operator 
published: true
description: A series that picks and explains something about ruby or rails
tags: #ruby #rails #wiltrr
---

Hello everyone

I have noticed recently that in my short journey as a Rails developer, there is still a lot I don't know about Ruby and Rails. I want to know more about them but the problem is just taking a course or reading a book won't help much if I don't practice. Plus I admitted that I can be overwhelmed with the loads of things things I need to learn and just prefer to sleep or watch a movie instead of learning. So I have decided to apply James Clear's advice from his book Atomic Habits and start small.

### Introduction
Today, I will be talking about the splat(*) operator in ruby.

The splat operator is mostly used to define the arguments that can be passed to a method when you don't want to specify the number or arguments you want to pass or when you don't know the number of arguments you want to pass. It comes in 2 types, the single splat(*) and the double splat(**).

The single splat works as expected while the double splat takes key/values pairs as arguments.

### Use cases

```ruby
def splat_single(*numbers)
  puts "#{numbers}"
end

splat_single(1, 2, 3)

# => [1, 2, 3]
```

```ruby
def splat_double(**numbers)
   puts "#{numbers}"
end

splat_double('a': 1, 'b': 2, 'c': 3)

# => {:a=>1, :b=>2, :c=>3}
```


Resource/More reading
[Everything you should know about Ruby Splats](https://alexcastano.com/everything-about-ruby-splats/)

### Not related extras
Create a file with command line in Mac, simply run 
`touch <name_of_file>.<extension>`
Inline and External CSS: Readability and Performance in React

Published: 2020-05-08 15:32:13

Inline CSS gives developers a way to see their styling in the same place as their functionality. As ridiculous as it is, being able to minimize the number of open files in an IDE is a way to improve developer's quality of life. Adding more windows, files, and complexity is a form of poor performance. The few seconds of context shifting between files or programming languages slows down the amount of code a programmer can write. It adds to the amount of unhappiness they experience as they write. So the solution is write your CSS inline even at the expense of some performance. 

External CSS allows some performance gains. It's a way to keep your file lengths lower and compartmentalized. If your focus is to cordon off portions of your code in such a way that each file does a single thing or you need to keep styling away from functionality External is the way to go.
Did MySpace Get You Interested in Coding?
Tags: discuss, myspace, codenewbie, career
Published: 2020-05-08 17:00:00

One thing that I keep seeing over and over again... 
a generation of developers inspired by... **MYSPACE.** 


If that's you, I want to hear about it!

Did you go to school for development, are you attending a boot camp, are you totally self-taught? What do you do now? What was your favorite MySpace memory? Share your story!

![tom from myspace](https://www.laweekly.com/wp-content/uploads/2019/05/tom_anderson_myspace_smjpg_jpeg_image_230x228_pixels.png)
<figcaption>the face that launched a thousand coders</figcaption>
TIL you can reference PowerShell object properties using a variable containing the name
Tags: powershell, quicktip, todayilearned
Published: 2020-05-08 16:49:56

---
title: TIL you can reference PowerShell object properties using a variable containing the name
published: true
description: Need to reference a property dynamically by a name stored in a variable? There's an easy way to do that!
tags: powershell,quicktip,til
canonical_url: https://blog.rousseau.dev/posts/get-powershell-property-by-var
cover_image: https://firebasestorage.googleapis.com/v0/b/blog.rousseau.dev/o/images%2fbackgrounds%2ftip.jpg?alt=media
---

## Song recommendation of the day <a name="song"></a>

Screaming Females put on some of the best live shows I've been to.
{% spotify spotify:track:5cHmo7M7CpO4UJiKuOPCko %}

## The problem

I wrote a PowerShell script to generate markdown tables for the [default permissions](https://octopus.com/docs/administration/managing-users-and-teams/default-permissions) of Octopus Deploy's built-in user roles.

I ran into a snag matching the permissions granted to a role to their descriptions.

The object holding the descriptions looks like this:

```powershell
$permissionDetails = @{
    EnvironmentEdit = @{
        Description = "Edit environment information"
    }
    EnvironmentView = @{
        Description = "View environment information"
    }
    TeamView        = @{
        Description = "View team information"
    }
    UserView        = @{
        Description = "View user information"
    }
}
```

The role has an array of permissions granted to it.

```powershell
$grantedPermissions = @("TeamView", "UserView")
```

I need to iterate over this array and access the `Description` property of the permission property that matches the name.

## The solution

How to do this was a gap in my PowerShell knowledge. My first few attempts did not work _at all_.

After a few searches, I found this [solution](https://stackoverflow.com/a/14406385/65560). You can reference a property name using a string.

```powershell
$obj."SomeProp"
```

If you can reference it using a string, maybe you can reference it using a variable?

```powershell
foreach ($name in $grantedPermissions) {
    Write-Output $permissionDetails.$name.Description
}
```

That works!

I will definitely be using this trick in the future.

_This post was originally published at [blog.rousseau.dev](https://blog.rousseau.dev/posts/get-powershell-property-by-var). Cover photo by [Sam Dan Truong](https://unsplash.com/@sam_truong) on [Unsplash](https://unsplash.com/)._
Web devs: before JavaScript, learn the fundamentals!
Tags: beginners, webdev, javascript, html
Published: 2020-05-08 15:53:55

> This video is a talk from [*Byteconf React 2020*](https://www.bytesized.xyz/react-2020), a free, live-streamed React conference that aired on May 1st-2nd, 2020. Join our newsletter at the [conference website](https://www.bytesized.xyz/react-2020) to stay in the know about future conferences, videos, and more!

Seasoned and beginner alike, developers have a habit of jumping right into a framework or new technology that makes a lot of promises while also glazing over important fundamentals that without, tend to hold back a website or application’s potential. Without some basic knowledge of HTML, you might inadvertently exclude people from learning about your company through your website due to poor accessibility. Lacking an understanding or simply being afraid of CSS, you might be more prone to add unnecessary libraries on top of libraries that just add to the weight of the page, impacting how quickly your app can load.

In this talk, we’ll go over some basic HTML and CSS strategies that can immediately be used right along side of your favorite Javascript frameworks like React that will provide another range of benefits like better accessibility, simpler code, and ways you can improve SEO by letting search engines like Google more easily figure out what your page is about.

Thanks to [Colby Fayock](https://twitter.com/colbyfayock) who presented this talk at [Byteconf React 2020](https://www.bytesized.xyz/react-2020)!

{% youtube MwrQC-zaxdE %}

If you enjoyed the video, give it a thumbs-up, and [subscribe to our channel](https://www.youtube.com/channel/UC046lFvJZhiwSRWsoH8SFjg?sub_confirmation=1) for more web dev content every week. We also have a newsletter where we send out what's new and cool in the web development world, every Tuesday – [join here](https://www.bytesized.xyz/newsletter)!
One Chapter Ends, Another One Begins 
Tags: motivation, bootcamp, datascience, flatironschool
Published: 2020-05-08 15:41:36

# Chapter One - The Journey
In the beginning of bootcamp, it felt as if this fast paced learning would never end! For the first month all I could do was sleep. This was the only way I could process all of the information from the day.

![laying-on-the-floor-to-sleep](https://media.giphy.com/media/Ii4dvuRs9WSCszbCcF/giphy.gif)

As the second month of bootcamp progressed, the corona virus had spread across the states and rumors of going remote started to flood the school. Eventually that became our reality and I was back at home struggling to learn new material in an environment I had kept separate from educational and income based work.

With the constant battle of new challenges I faced, I chose to keep my head down and keep working. I will admit I had my bad days but I kept pushing forward! I had a goal, and a student loan sooooo......yeah. 

![crying-about-student-loans](https://media.giphy.com/media/syBlSgDbjsMHC/giphy.gif) 

Now we are in the last month of our Data Science Bootcamp here at Flatiron School, I am currently working on my final project and graduation is set to be on May 29, 2020. It doesn't feel real.  

# Words Of Wisdom
When you are starting something new, imagine yourself as a child. Remember how scared you were to ride your bike without training wheels, or jump in the pool without your floaties? That fear is still with us in adulthood, so be gentle with yourself. It's ok if you do not get things right the first time, you've never done it before!

![dust-yourself-off-try-again](https://media.giphy.com/media/3o6MbaH9LYlaVpHWBa/giphy.gif)

Know that you will face some challenges along the way, and while you are facing them it will feel like you are getting no where.

Keep pushing, because when you reach the end you will see just how far you have come and that fear that I mentioned before will be replaced with confidence and skill.

# Final Words
My plan for this blog post wasn't to go into detail about my personal journey through the bootcamp. It was more so to acknowledge that I did it, I made it to the end of the program (well, not really I still have my final project but that should be easy). 

![sarcastic-laugh](https://media.giphy.com/media/LOuFH5FMwy3yzKU6U9/giphy.gif)


I wanted to share that, as well as some kind words to encourage anyone thinking of doing a coding bootcamp or embarking on a new journey themselves. Hopefully this reaches someone in need of it. Happy coding, and stay well. 

# Chapter Two - Job Hunting Post Corona Virus ...

![a-squirrel-looking scared](https://media.giphy.com/media/XhcSIUIkgbmuY/giphy.gif)
100daysofcode Flutter
Tags: 100daysofcode, flutter
Published: 2020-05-08 15:24:22

day 60/100 of #100daysofcode #Flutter
Learning Flutter , courses Udemy from
@maxedapps

Today learn about Matrix, dart.math, implements some UI in authscreen
https://github.com/triyono777/100-days-of-code/blob/master/log.md
React Hook around Apollo GraphQL mutation 
Tags: react, webdev, javascript, graphql
Published: 2020-05-08 14:57:33

Here is an example of custom hook around Apollo mutation, which includes error and loading states to keep UX in sync with what is happening.
BTW you can check <code>[React Hook around Apollo GraphQL query](https://dev.to/max_frolov_/react-hook-around-apollo-graphql-query-2nl6)</code> here.
```jsx
import * as RH from "@apollo/react-hooks";
import gql from "graphql-tag";

// activate user query
export const ACTIVATE_USER_MUTATION = gql`
  mutation ActivateUserMutation($input: ActivateUserInput) {
    activateUser(input: $input) {
      firstName
      lastName
      online
      id
    }
  }
`;

// entity mutation hook
export const useActivateUserMutation = () => {
  // gql hook
  const [activateUser, { data, loading, error }] = RH.useMutation(ACTIVATE_USER_MUTATION);

  const handleActivateUser = async (variables) => {
    try {
      const {
        data: {
          activateUser: { id }
        }
      } = await activateUser({ variables });
      // call fn to show some success box in the interface
      
      return id;
    } catch (error) {
      // parse error here
      console.log(error.graphQLErrors)
    }
  };

  return {
    activateUser: handleActivateUser, // mutation handler
    result: data, // mutation result
    isLoading: loading, // loading state
    error // mutation error state
  };
};
```

More tips and best practices on my [twitter](https://twitter.com/max_frolov_).

Feedback is appreciated. Cheers!
Announcing new tools to debug your Cloudflare Workers applications
Tags: serverless, webdev, opensource, cloudflareworkers
Published: 2020-05-08 14:52:02

With the addition of `wrangler dev` and `wrangler tail` in recent versions of Wrangler, the Workers command-line tool, developers now have a ton of tooling to debug and inspect their applications. 

In this video, Workers developer advocate Kristian Freeman walks through how to use `wrangler dev` and `wrangler tail` to debug an issue in a deployed application. 

Learn more about how to use these new commands in the Workers documentation: https://developers.cloudflare.com/workers/tooling/wrangler/commands

Read more about the newest release of Wrangler, and how to install it, on GitHub: https://github.com/cloudflare/wrangler/releases/tag/v1.9.0

{% youtube 8iPmy7ePYDE %}
Montimark - Web Monetization for images with a Watermark
Tags: gftwhackathon, webmonetization, opensource
Published: 2020-05-08 14:48:22

Hello friends

i got up today at 9.15.
Browsed to  Dev.to and saw that a Hackathon is going on about a great new technology.

So I thought to myself: oh I'm on short time work anyway so I can do something with it, sounds interesting.

What is Montimark?

Montimark is nothing else than :

Monetization Watermark for and creatives to protect their images.

It should be very easy to add a watermark to pictures.

How does it work?

Just Do a simple
<pre>
new Montimark('.selector', 'watermarkpath.jpg')
</pre>
and you are good to go.

Requirements :
You need the monetization enabled with e.g Coil Chrome plugin
https://chrome.google.com/webstore/detail/coil/locbifcbeldmnphbgkdigjmkbfkhbnca/related?hl=en

direct demo :
https://nokol.net/montimark


Visit early stage here
https://github.com/DomEscobar/montimark
help with docker compose
Tags: help, docker
Published: 2020-05-08 14:46:17

hey I am working on a project using docker compose. I need one image to use the other images' 5001 port and its not working... if I run this outside a docker container using standard version of these services it seems to work fine.
here is my docker compose file:
```
version: "3"
services:
  web:
    image: fulton/pegasus
    ports:
      - 8000:8000
    depends_on:
      - ipfs
  ipfs:
    image: ipfs/go-ipfs
    ports:
      - 5001:5001
      - 8080:8080
```

and here is the code that is giving the errors (its kotlin)

```
val response =
            Unirest.post("http://0.0.0.0:5001/api/v0/add?chunker=size-262144&hash=sha2-256&inline-limit=32")
                .field(file_name,file_data)
                .asString()
```

I am pretty new to compose and any help will be awesome :]
Libraries are Killing Me
Published: 2020-05-08 14:34:58

Something that's been infuriating is adding libraries to any project that I've been working on. NPM and Ruby make it all to easy to add someone else's knowledge and bad habits to your projects. I've used a few great libraries before, but recently I used a library that allowed me to raise the technical floor of my project, but also lowered the ceiling of what I could include as a feature.
 
Google Maps is a pretty decent API. It's easy to get started with and has some very deep features to play around with. A recent project I started working on had a strict time limit that did not allow me to learn how to build out my own implementation of those APIs in React. Enter libraries. I was up and running in less than a day. Everything was going smoothly until I needed to get into deeper parts of the API. The great library I was using started to fight me.
 
This is the most frustrating impotent feeling of learning something new. I could make my own tools, but it would take far too long. Since the goal is to complete a project, to ship, I've had to cobble together other code bases into a configuration I want. Sometimes those pieces don't quite exactly fit and I have to tape them together. If I had more skill I could build my own bespoke tools, but that would take me far too long. It's a complete mess and the compromise I've come to is: "I'll come back later."
Vercel (Zeit's Now) builders cache for docker-compose
Tags: vercel, docker, tips, zeit
Published: 2020-05-08 14:34:19

If you happened to use *Vercel* (formely *Now* from Zeit.co) and *docker-compose*, there's a simple tweak to decrease  startup times when launching multiple components which are running `now dev` inside the container.
```yaml
version: "3"
services:
  next_frontend:
    context: ./next-app
    volumes:
      - now_cache:/root/.cache/co.zeit.now/dev/builders
  serverless_backend:
    context: ./now-app
    volumes:
      - now_cache:/root/.cache/co.zeit.now/dev/builders
volumes:
  now_cache:
```
This allows docker to reuse installed builders in a similar way it's done on Vercel's platform, when building new versions of the component.

Startup times before the tweak:
```
 ▾ ~/code/app
   docker-compose up | ts -s '%.S'
yarn run v1.22.4
$ /app/node_modules/.bin/now dev
02.670810 > Now CLI 19.0.0 — https://zeit.co/feedback
10.620778 > Ready! Available at http://localhost:3000
```

Startup times after the tweak:
```
 ▾ ~/code/app
   docker-compose up | ts -s '%.S'
yarn run v1.22.4
$ /app/node_modules/.bin/now dev
02.580774 > Now CLI 19.0.0 — https://zeit.co/feedback
02.886081 > Ready! Available at http://localhost:3000
```
It won't help with the startup time for your first build, but will speed up all the consequent starts.

Below is a brief explanation on why and how this works.

---

The way `now dev` works is by emulating a build "sandbox" similar to that which builds your projects in the Vercel's cloud. This sandbox does a lot of heavy lifting for such things as turning your `/api` or `/public` folder to a deployable serverless app and enrich your dev experience with such hooks as `now-build` or `now-start` in a package.json, providing an identical zero-config environment regardless if you're running your app locally or in the cloud. 

Some of these features, though, are quite heavy in terms of the start costs. So, as usual, caching is involved. The cache is centralised for all the projects using `now` on your machine, regardless of CLI version. The cache itself contains a couple of interesting things: `yarn` executable and builders which has been previously detected in use by `now` CLI.

As this cache is global, `docker-compose` knows nothing about it and each and every app start is a *cold* one. Mounting a persistent volume to that folder allows the cache to function exactly as intended.

It's also possible to mount your `~/.cache/co.zeit.now` to reuse the already existing cache for your currently logged-in user. That'll likely not work for your CI/CD pipeline though.

Please, be aware that this builders cache is not explicitly documented, so the behavior may potentially change in future.
Daily Challenge #239 - Graceful Tipping
Tags: challenge
Published: 2020-05-08 14:20:56

---
title: Daily Challenge #239 - Graceful Tipping
published: true
series: Daily Challenge
description: Adding tip to a restaurant bill in a graceful way can be tricky.
tags: challenge
---
Adding tip to a restaurant bill in a graceful way can be tricky, that's why you need make a function for it. The function will receive the restaurant bill (always a positive number) as an argument. 

You need to: 
1) add at least 15% in tip
2) round that number up to an elegant value and 
3) return it.

What is an elegant number? It depends on the magnitude of the number to be rounded. Numbers below 10 should simply be rounded to whole numbers. Numbers 10 and above should be rounded like this:
10 - 99.99... ---> Round to number divisible by 5
100 - 999.99... ---> Round to number divisible by 50
1000 - 9999.99... ---> Round to number divisible by 500
And so on...

Examples
 1  -->    2
 7  -->    9
12  -->   15
86  -->  100

Tests
99 -->
114 --> 
1149 --> 

Good luck!
***
_This [challenge](https://www.codewars.com/kata/5eb27d81077a7400171c6820) comes from viktorostlund on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
Get started with Git
Tags: github, git, beginners
Published: 2020-05-08 14:16:03


# How to search for issues
- Search for tags such as beginner, low-hanging fruit, low-priority, up-for-grabs
- If the org doesn't have labels on it then go for issues that have less discussion and comments in it.

# How to search for resolving the issue
- First check in which all files does the issue has connection with
- Use grep for searching through the files
- Read the portion of documentation where the issue has connection with
- Google search through and check stack-overflow

# Now, let's solve a real-world issue.

# Search for relevant projects and join the community

Search for relevant projects on GitHub based on your skills. You can use GitHub Explore for this purpose or sign-up for Code Triage to get an email on a different issue every day.

While choosing a project to start on, look for a project that is actively maintained (loads of commits) and has a lot of issues. Once you have found your relevant projects, Star & Fork the project, subscribe to its mailing list and slack channel. This is the best way to get help if you are stuck in setting up the project or making your first contribution.

# Play with software(Find bugs)
Explore existing issues
Help explore documentation
Suggest new features

# - Introduction about Git Workflows
A Git Workflow is the best way to work with git locally and on cloud without messing up the branches or creating merge conflicts.

# A Git Workflow I follow :

- git fetch --all --prune
- git co master
- git reset --hard upstream/master
- git push origin master/specified branch

# Thank You
What was your win this week?
Tags: weeklyretro
Published: 2020-05-08 14:08:00

👋👋👋👋

Looking back on your week -- what was something you're proud of?

All wins count -- big or small 🎉

Examples of 'wins' include:

- Getting a promotion!
- Starting a new project
- Fixing a tricky bug
- Knitting a sweater...or whatever else that may spark joy 😄

![knitting-cat](https://media.giphy.com/media/eJKom2gOpHjTpjords/giphy.gif)

Happy Friday!
Can you find documentation for an old codeigniter version?
Tags: help, php, codeingiter
Published: 2020-05-08 14:07:20

Hello, I am maintaining a legacy php application with codeigniter 2.7 . What I want is to locate its documentation because it is not available any more. Can you elaborate with that. AFAIK there's a `./documentation` folder on a ci project containing the documentation does somebody have that?
Chingu Voyage 20 Starts on June 1st
Tags: development, education, career, collaboration
Published: 2020-05-08 13:56:54

Chingu Voyages are a way for you to get out of **_Tutorial Purgatory_** by turning what you've learned into expertise.

Get yourself _job ready_ by applying your tech skills on a team project while also practicing the soft skills and team workflows you will need on the job. Our project-based learning community will help you aim higher and achieve more than you could alone.


In a six week Voyage you'll work on a team to **_design, build, test, & deploy_** a project.

Learn more at https://chingu.io