teleren/devto huggingface dataset:
Hide and Keep your API key out of GitHub repository
Tags: programming, android, github, java
Published: 2020-12-13 15:12:43

When you upload your Android app on GitHub, you need to hide it as no one has access to it except you. It is considered a security glitch, so that’s why it is important to hide your API key. I am going to show you how you can do that easily.

Some Developers store their API key in a String variable like this.

`private static final String APK_KEY = "asjsdakf4d3ggs2ytm4x";`

It is not good to push your secret things into public repository as other people could use up your limited API calls. That’s probably the least concerning situation. Sharing of API keys becomes more of a concern if the API key authenticates someone for access to a subset of data.

So, let’s see how we can do that.

####1- Create a file called gradle.properties in .gradle folder.

```
   -Drive C
    -Users folder
     -your user folder
      -.gradle folder
      Create it here
      -gradle.properties
```

Then, write your APPNAME_API_KEY = "asjsdakf4d3ggs2ytm4x" inside it. Save it as PROPERTIES File by enclosing with double quotes like this "gradle.properties"

####2. Next step, Go to module level build.gradle file in your project

Then, put your API key for debug and release purposes under buildTypes tree.

`buildConfigField ‘String’, “ApiKey”, APPNAME_API_KEY`

It will be like that

```
buildTypes {
        debug{
            buildConfigField 'String', "ApiKey", APPNAME_API_KEY
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            buildConfigField 'String', "ApiKey", APPNAME_API_KEY
        }
}
```

Sync it

####3. Last Step, access your APK key in your Java file like that

```
private static final String API_KEY = BuildConfig.ApiKey;
```

If ApiKey goes red, press Make Project button or use **Ctrl+F9**

##**Another Way to do that:**##


**1. Add the API key to your local.properties file:**

```
apiKey="Your Key"
```
**2. Add these two lines to the root level of your app-level build.gradle file:**

```
def localProperties = new Properties()
localProperties.load(new FileInputStream(rootProject.file("local.properties")))
```
**3. Add this following line to your app-level build.gradle file:**

```
android {
  
  defaultConfig {
      // ...   
   
      buildConfigField "String", "API_KEY",localProperties['apiKey']

  }   
}
```

**4. Sync Gradle and build the project. You can now reference the key:**

```
String apiKey = BuildConfig.API_KEY;
```
Sounds pretty easy, does it?. Whenever you upload your Android project on GitHub, the person that uses your repository will not be able to figure out what your API key is. Therefore, you are secure NOW.

**Follow me on:** [GitHub](https://github.com/Marwa-Eltayeb) and [LinkedIn](https://www.linkedin.com/in/marwa-eltayeb/)
How to use the JavaScript to Fetch API
Tags: javascript, html, css
Published: 2020-12-13 15:09:29

**XMLHttpRequest** was the thing used back then to make request and serve call , but the modern day **JavaScript** has made significant changes so has made the built-in-clean code now.

Fetching API is a basic but most important thing to do while making website more responsive, Along comes the Fetch API a new standard to make server request jam-packed with promises and all those things we learned to love over the years.

# How do we use the Fetch API?
In a very simple manner all you really do is call fetch with the URL you want, by default the Fetch API uses the GET method:

fetch(url) // Call the fetch function passing the url of the API as a parameter
.then(function() {
    // Your code for handling the data you get from the API
})
.catch(function() {
    // This is where you run code if the server returns any errors
});

*For example:*
If u want to get 10 random users, use css selectors to add a select a button.
```
<h1>Authors</h1>
<ul id="authors"></ul>
const ul = document.querySelector('authors'); // Get the list where we will place our authors
const url = 'https://randomuser.me/api/?results=10'; // Get 10 random users
```
here is how things work in background
When we input the URL in fetch command in return we get a response. 
Then we get a response but the response we get is not JSON but an object with a series of methods we can use depending on what we want to do with the information, these methods include:

* clone() - As the method implies this method creates a clone of the response.
* redirect() - This method creates a new response but with a different URL.
* arrayBuffer() - In here we return a promise that resolves with an ArrayBuffer.
* formData() - Also returns a promise but one that resolves with FormData object.
* blob() - This is one resolves with a Blob.
text() - In this case it resolves with a string.
* json() - Lastly we have the method to that resolves the promise with JSON.

I have created a small and ready to make project using **Funtranslations.com** where u give a text and using api it can be translated to diff languages

```
var inputbtn=document.querySelector("#inputbtn");
var inputtxt=document.querySelector("#inputtxt");
var outputtxt=document.querySelector("#outputtxt");
var serverurl ="https://api.funtranslations.com/translate/minion.json";

function geturltranslate(text){
  return serverurl+ "?" +"text="+ text;
}
function translate(){
    var inputtext=inputtxt.value;
fetch(geturltranslate(inputtext))
    .then(response =>response.json())
    .then(json => {
      var translatedtext=json.contents.translated;
      outputtxt.innerText=translatedtext;   //output
    }) 
};
inputbtn.addEventListener("click",translate);
```

input:  hello welcome here, have a good Day
output: Hello zhelosa stai, zinot zo zyemus diena

hence the only use of the APi is to convert the given text into translated text

checkout the site for more translation
[TranslationApi](https://funtranslations.com/)
Planning for my first Hackathon - DOHackathon
Tags: dohackathon, react, node
Published: 2020-12-13 14:56:35

---
title: Planning for my first Hackathon - DOHackathon
published: true
description: Briefs about my development and deployment decisions
tags: dohackathon, react, nodejs
series: Flixplore
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/d7ex2lxmlayvzve5zkb9.PNG
---
I decided to participate in my first ever [hackathon](https://dev.to/devteam/announcing-the-digitalocean-app-platform-hackathon-on-dev-2i1k) and made a post yesterday about why it is very important to me. The idea that I chose to work on was an app that makes it easy for you to choose a movie to watch when you have a certain genre in mind. 
***
**Flixplore**, like most other apps, will consist of
 - A **React App** as frontend. 
 - An **ExpressJS server** as backend.  

#### The frontend will be 
 - A [CRA](https://create-react-app.dev/) app
 - With [Material-UI](https://material-ui.com/). 

#### The backend will be using 
 - The [TMDB API](https://developers.themoviedb.org/3/getting-started/introduction) for movie suggestions and
 - The [Utelly API](https://rapidapi.com/utelly/api/utelly) for finding a place to watch the movie (Netflix, Prime, Disney+).

I could do this without a backend server. But I chose to have a backend because the external API's have a private key and they are rate limited. So it would be better to abstract this in a backend to keep the frontend straightforward.  

With the [DigitalOcean App Platform](https://www.digitalocean.com/docs/app-platform/), I can deploy both my react app and express server as two different [Components](https://www.digitalocean.com/docs/app-platform/concepts/component/) ([Static Site](https://www.digitalocean.com/docs/app-platform/concepts/static-site/) and [Service](https://www.digitalocean.com/docs/app-platform/concepts/service/)) of the same app. All components of an app will have the same domain but you can assign [individual routes](https://www.digitalocean.com/docs/app-platform/concepts/http-route/) for them. So I need not enable [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) in my Express app. 

Deploying the code to the app platform is very easy. Just link your Github repo. Whenever you push changes to the selected branch, the app platforms will build the new version of the app.
Advent of code - Day 12
Tags: javascript, typescript, adventofcode
Published: 2020-12-13 14:54:26

Are you participating in the [Advent of code](http://adventofcode.com) this year?

If you don't know what the advent of code is, it's a website where you'll find a daily challenge (every day it gets harder). It's a really fun event, you should participate!

I try to solve the exercises using either JavaScript or TypeScript and will share my solutions daily (with one day delay so no one can cheat!). I only share the solution for the second part.

Fun exercise today! I panicked a bit with that "angle" thing, but then I realised it was always 90°, which made it pretty straightforward.

Here is my solution for day #12:
```js
const Command = {
  North: 'N',
  South: 'S',
  East: 'E',
  West: 'W',
  Left: 'L',
  Right: 'R',
  Forward: 'F',
}

function addTo(state, command, value) {
  if (command === Command.East) return { ...state, wpx: state.wpx + value }
  if (command === Command.West) return { ...state, wpx: state.wpx - value }
  if (command === Command.North) return { ...state, wpy: state.wpy - value }
  if (command === Command.South) return { ...state, wpy: state.wpy + value }
}

function rotate(state, command, param) {
  if (param === 0) return state
  if (command === Command.Left) return rotate({ ...state, wpy: 0 - state.wpx, wpx: state.wpy }, command, param - 90)
  if (command === Command.Right) return rotate({ ...state, wpx: 0 - state.wpy, wpy: state.wpx }, command, param - 90)
}

function execute([command, param], state) {
  if (command === Command.Forward) return { ...state, x: state.x + param * state.wpx, y: state.y + param * state.wpy }
  if (command === Command.Right || command === Command.Left) return rotate(state, command, param)
  return addTo(state, command, param)
}

const resultState = input.reduce(
  (state, command) => {
    return execute(command, state)
  },
  {
    x: 0,
    y: 0,
    wpx: 10,
    wpy: -1,
  },
)
```

Feel free to share your solution in the comments!

________________________

Photo by [Markus Spiske](https://unsplash.com/@markusspiske?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText)
How To Convert Python String To Array
Tags: python3
Published: 2020-12-13 14:42:36

This tutorial help to create python string to array.Python does not have inbuilt array data type, it have list data type that can be used as array type.So basically, we are converting string into python list.

Python String to Array
We ll convert String to array in Python. The python string package have split() method. The String.split() method splits the String from the delimiter and returns as a list items. The split() method default separator is the whitespace but you can specify the separator.

Syntax
string.split(separator, maxsplit)

Where is parameters are :

separator(optional) : It used to split the String.
maxsplit(optional) : It specifies number of splits to do. The default value is -1, which is “all occurrences”.
Example:
1
#test.py
2
str = "My name is dominic toretto"
3
arr = str.split()
4
print(arr)
Output
['My', 'name', 'is', 'dominic', 'toretto']

Originally posted at - https://www.pythonpip.com/python-tutorials/how-to-convert-python-string-to-array/
Adding Methods to Prototypes, JS
Tags: javascript, webdev, node
Published: 2020-12-13 14:34:24

Let's start with a method that already exists:

**Array.prototype.reverse()**

.reverse() takes an array and reverses it:

``` js
const myNumbers = [1, 2, 3, 4, 5, 6, 7];

console.log(myNumbers.reverse()); // outputs [7, 6, 5, 4, 3, 2, 1];
```
**now lets pretend the .reverse() method doesn't exist**

Let's make the method ourselves, we will call it *.reverse2()*:

``` js
Array.prototype.reverse2 = function() {
    const reversedArray = [];
    this.forEach(item => reversedArray.unshift(item));
    return reversedArray;
}
```
If the above is confusing, here is the same thing but with comments for clarity:
``` js
Array.prototype.reverse2 = function() {
    // create an empty array
    const reversedArray = [];
    // *this* reverses to the array to the left of the
    // .reverse2() method, in our case, *myNumbers*.
    
    // Here we take each item in myNumbers and add it to the front of reversedArray
    
    // ex. [1], [2, 1], [3, 2, 1], etc...
    this.forEach(item => reversedArray.unshift(item));
    // return the reversed Array.
    return reversedArray;
}
```

Now we can use our .reverse2() method we created on any array:

``` js
const myNumbers = [1, 2, 3, 4, 5, 6, 7];
console.log(myNumbers.reverse2()); // outputs [7, 6, 5, 4, 3, 2, 1];
```
**still with me?**

Here's the crazy bit.
.reverse() doesn't exist for strings 😱 😱 😱

``` js
const myString = 'I am writing a sentence';
console.log(myString.reverse()) // error, myString.reverse() is not a function
```

**Let's add .reverse() as a prototype method for Strings.**
``` js
Array.prototype.reverse2 = function() {
    const reversedArray = [];
    this.forEach(item => reversedArray.unshift(item));
    return reversedArray;
}


const myString = 'I am writing is a sentence'

String.prototype.reverse = function() {
    return this.split('').reverse2().join('');
}

console.log(myString.reverse());
```
A brief explanation:
1. we split the string every character:
**['I', ' ', 'a', 'm'] ... etc.**

2. The string is now an array, which means we can use our .reverse2() method we made for arrays. (or you can use the built in .reverse() array method here).
**['e', 'c', 'n', 'e', 't', 'n', 'e', 's', ' ', 'a', ' ', 'g'] ... etc**

3. We then join the array back together into a string:
**ecnetnes a gnitirw ma I"

**Thanks for reading, for more tech content you can find me here:
Youtube => https://www.youtube.com/austinbeaufort
Twitter => https://twitter.com/AustinBeaufort**
I love Development But Here a Twist
Tags: javascript, node, html, react
Published: 2020-12-13 14:18:17

I started to learn development from the last 3 years ago. I learned android and web development. After learning them I want to earn money.

But here a twist 
I am a college student and here they don't see your projects , they have so call aptitude tests where there are many different types of questions that you haven't studied in your life. So in summary I was rejected here.

Secondly, when I see some company requirement they want at least 4-7-year experience person .

What's your opinion on this
Dealing with integer by different radix
Tags: java
Published: 2020-12-13 13:21:46


In Java, numbers can be written by various radix.

```java
// radix 10
int value = 255;

// radix 16
value = 0xff; // starts from 0x
value = 0xFF; // ff can be written as upper case, but not common
value = 0Xff; // x can be upper case, but not common

// radix 8
value = 0377; // starts from 0

// radix 2
value = 0b11111111; // starts from 0b
value = 0b1111_1111; // under score can be put for separation
```

These are all same values essentially and given for convenience for programmers when reading.

Reference
https://gihyo.jp/book/2014/978-4-7741-6685-8
Tool of the Week: Advent of Code
Tags: developer, christmas, tool
Published: 2020-12-13 13:12:04

---
title: Tool of the Week: Advent of Code
published: true
description: Improve as a developer within christmas time
tags: developer, christmas, tool
cover_image: https://images.unsplash.com/photo-1606482714043-600dc0b89ae0?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1652&q=80
---

# Introduction
Once a week i want to show you my personal Tool of the Week.
This week its not a real tool but its quite cool (Rhyme of the year!).
Its  [Advent of Code](https://adventofcode.com/).

# Advent of Code
Its quite a cool project (Advent Calendar) where you can solve a coding puzzle each day till christmas and improve as a developer. Each day the puzzle gets harder and more complicated.

I really enjoy it. And you dont have to do it on the same day. You can do it whenever you want and you can stop whenever you want. So you dont have to do all of them.

#  Summary
I hope you find this useful and i wish you a lot of fun by doing those puzzles. I think you can learn a lot and improve as a developer by doing even just one of them!

Stay connected to me and my content on [Twitter](https://twitter.com/danytulumidis).

I love to improve myself every single day even if its just a tiny bit!

And as always: develop yourself!
LinkedIn JavaScript Assessment Answers
Tags: javascript, test
Published: 2020-12-13 13:11:24

The LinkedIn Skill Assessments feature allows you to demonstrate your knowledge of the skills you’ve added on your profile. This new feature allows recruiters and job posters to more efficiently and accurately verify the crucial skills a candidate should have for a role.

I have put together answers to the LinkedIn JavaScript assessment (2019-2020).
 
If you are new to Frontend Development, or maybe you just want to revisit the basics and get that sweet badge, this project is for you. 

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

This multiple-choice format covers some of the most popular topics about this programming language, including, but not limited to:

- JavaScript Fundamentals
- Data Types
- Browser Integration
- Objects
- Network Requests
- Prototypes and Inheritance
- Error Handling
- Asynchronous JS

Check it out!

https://github.com/Adrinlol/LinkedInJavaScriptAssessment
Simple way to encrypt informations
Tags: python, devops, tutorial
Published: 2020-12-13 13:01:50

##Simple ways to encrypt information
A simple way of encrypting a message is to rearrange its characters. One way to rearrange the characters is to pick out the characters at even indices, put them first in the encrypted string, and follow them by the odd characters. For example, the string message would be encrypted as `msaeesg` because the even characters are m, s, a, e (at indices 0, 2, 4, and 6) and the odd
characters are e, s, g (at indices 1, 3, and 5).
Now let's write a program that asks the user for a string and uses this method to encrypt the string.
our encrypt code :
```python
def encrypt():#to put all our code in function
    strings=input('what is your message: ')
    even=strings[::2]#extract the even part 
    odd=strings[1::2]#extract the odd part
    print(even+odd)#print the result
encrypt() 
```
You can try to input anything and it will be hard for anyone to read.
Here are some different input and there encrypt message
```
>>>what is your message: kill the readers
>>>kl h edrilteraes

>>>what is your message: I am the one who encrypt the information. so don't bother to try you can't read it
>>>Ia h n h nrp h nomto.s o' ohrt r o a' edi mteoewoecytteifrain odntbte otyyucntra t
```
But what if we need to get the real message back. what do we do? Yeah, we do something called decryption and our decryption code will be 
```python
def decrypt():
    string=input('what is your message: ')
    length=len(string)#to get the length of the input
    half_length=(length+1)//2 #half of the input
    even=string[:half_length]#even part
    odd=string[half_length:]#odd part
#here we start inserting each of the part to form original
    msg=''
    if length%2==0:
        for i in range (half_length):
            join=even[i]+odd[i]
            msg=msg+join
    else:
        for i in range (1,half_length+1):
            start=i-1
            join=even[start:i]+odd[start:i]
            msg=msg+join
    print(msg)
decrypt()
```
Now you can copy the result you get in encrypt here and you will get the real message.
Here are some
```
>>>what is your message:kl h edrilteraes 
>>>kill the readers
>>>what is your message: Ia h n h nrp h nomto.s o' ohrt r o a' edi mteoewoecytteifrain odntbte otyyucntra t
>>> I am the one who encrypt the information. so don't bother to try you can't read it
```
 find it interesting? then consider to subscribe and like.
Daily Developer Jokes - Sunday, Dec 13, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-12-13 13:00:17

---
title: "Daily Developer Jokes - Sunday, Dec 13, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Sunday%2C%20Dec%2013%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258f50f7c0.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ Why did the developer go broke?

___A:___ Because they used up all their cache
 -->
How to learn efficiently as a developer
Tags: developer, building, code, learning
Published: 2020-12-13 12:58:42

---
title: How to learn efficiently as a developer
published: true
description: 
tags: developer, building, code, learning
cover_image: https://images.unsplash.com/photo-1503437313881-503a91226402?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1778&q=80
---

#Introduction
Hey there! I hope youre all healthy! I want to talk about a topic that is quite tricky and runs through my mind for quite some time. How to learn efficiently as a developer?

#Blogs, Tutorials, Videos and...
As a developer there tons (really A LOT) things you have to learn and that you can learn. I have a few subscriptions for tech newsletters. I can go to Hashnode, Dev, Twitter, Youtube, Udemy etc. On each platform you can read articels (like this here) or watch videos. You can learn a lot of things. But you will forget most things. I read and watched a lot about HTTP headers but i forgot most of it. Sure one or two things will stuck into your brain but most of the stuff will be lost. A hugh time waster if you ask me.

The worst part is that our brain tricks us and we think we are productive as we do these things but we are not.

How we can avoid this trap?

#Build stuff
Build Stuff. We learn best when we have to do it in practice. I struggled a lot (and sometimes still do) when it comes to Terraform. And after reading the docs and watching videos i forgot most of the things within days. Then i took another approach. I start to use Terraform in my AWS account and learned it while i actually used it.

Learning by doing is the key. Especially as a developer. We learn the most from mistakes. Often we are afraid of doing something because we are afraid of failing. But it should be the other way around.

Search for failure and mistakes and this will make you a better developer and you will learn new things and new technologies in no time!

#Summary
I hope this article will help one or two people out there. Just start side projects when you want to learn new topics. Its okay to watch videos. Its okay to read articles. But its not okay to stop there and then forget everything.

Think about a cool side project you may need and want to use for yourself and start building. Start failing. And finally start learning.

Stay connected to me and my content on [Twitter](https://twitter.com/danytulumidis).

I love to improve myself every single day even if its just a tiny bit!

And as always: develop yourself!