teleren/devto huggingface dataset:
Redirecting users to their intended url via the session hash in rails after signing in.
Tags: rails
Published: 2020-12-27 18:13:03

As you have probably done before inside of a rails app, requiring users to be signed in before being able to access certain pages in the application is a pretty common task. Typically, you would have a method that runs as a before action inside of a controller.

So a user visits your app, tries to access say, their own profile page and since they didn't sign in first, the are kicked to the sign in page and hopefully politely told that they must sign in first. Pretty standard stuff here.

But depending on where you redirect the user to after they sign in, that my not align with where the user was trying to go to in the first place before being sent to the sign in screen.

Image this case, say you have a blogging application and a user visits the app, and immediately tries to edit a blog post they wrote, perhaps a friend pointed out a typo to them and they want to address the typo. So the user initially set out to land on a specific posts page so that they could then click an edit button to edit the post. 

However, the user is redirected to the sign in screen as a result of a before action you have to require sign in. The user signs in successfully but is then routed to their profile page, which is not where the user originally wanted to go though. How can we provide a helping hand to the user so that we get them back to their original target of a specific posts page?

Our good friend the session hash is here to help us! We can modify our require sign in method to grab the intended url that the user was attempting to go to by using the request object that is passed along when a user navigates around the application. Then we can grab the url property out of the request object and store that inside the session hash for later use. So our require sign in method may look something like this:

```ruby
  def require_signin
    unless current_user
      session[:intended_url] = request.url
      redirect_to new_session_url, alert: "Please sign in first!"
    end
  end
```

Here we are saying that unless there is a current user we want to store that url in the session hash and redirect the user to the sign in page.

Now after the user signs in we can use the `:intended_url` property of the session hash, if it's there to get the user back to where they originally wanted to go. That could look something like this:

```ruby
	def create
		if user = User.authenticate(params[:email_or_username], params[:password])
			session[:user_id] = user.id
			flash[:notice] = "Welcome back, #{user.name}!"
			redirect_to(session[:intended_url] || user)
			session[:intended_url] = nil
		else
			flash.now[:alert] = "Invalid email/password combination!"
			render :new
		end
	end
```

There is a bit going on here but the important line is the fourth line inside the create action. What happens here is that after successfully being authenticated, the user will be redirected to their intended url if that property is set or instead they will be redirected to their profile page. 

Mission accomplished!

Happy Rubying!!!
Best sites for free Website templates
Tags: webdev, webdesign, design
Published: 2020-12-27 18:00:16

#These are the 5 best websites#

1. [nicepage.com](https://nicepage.com/website-templates)

2. [colorlib](https://colorlib.com/wp/templates/)

3. [webflow](https://webflow.com/free-website-templates)

4. [templated.co](https://templated.co/)

5. [freewebsitetemplates.com](https://freewebsitetemplates.com/)

Thanks for checking my post :)
Reverse Engineering The Saboteur game for Xbox360 with Linux
Tags: reverseengineering, lua, xbox, linux
Published: 2020-12-30 17:29:15

---
title: Reverse Engineering The Saboteur game for Xbox360 with Linux
published: true
date: 2020-12-27 17:54:44 UTC
tags: reverseengineering,lua,xbox,linux
canonical_url: https://daniele.tech/2020/12/reverse-engineering-the-saboteur-game-for-xbox360-with-linux/
---

I spent my Christmas hoildays on reverse engineering some files of this game Xbox 360 version just for fun with not an happy conclusion...

The post [Reverse Engineering The Saboteur game for Xbox360 with Linux](https://daniele.tech/2020/12/reverse-engineering-the-saboteur-game-for-xbox360-with-linux/) appeared first on [Daniele Mte90 Scasciafratte](https://daniele.tech/eng).
Creating a Modal in Ionic Vue
Tags: ionic, vue, javascript, typescript
Published: 2020-12-27 17:46:29

#Create a component you want to render inside the ionic modal.
*@/components/modal.vue*
```vue
<template>
  <ion-header>
    <ion-toolbar>
      <ion-title>Modal</ion-title>
    </ion-toolbar>
  </ion-header>
  <ion-content class="ion-padding">
    This is a modal
  </ion-content>
</template>

<script>
import { IonContent, IonHeader, IonTitle, IonToolbar } from "@ionic/vue";
import { defineComponent } from "vue";

export default defineComponent({
  name: "Modal",
  components: { IonContent, IonHeader, IonTitle, IonToolbar },
});
</script>
```

#Create a modal instance and method to open the modal
*@/views/Home.vue*
```vue
<template>
  <ion-page>
    <ion-header :translucent="true">
      <ion-toolbar>
        <ion-title>Ionic Vue Modal Example</ion-title>
      </ion-toolbar>
    </ion-header>

    <ion-content :fullscreen="true">
      <ion-button @click="openModal">Open Modal</ion-button>
    </ion-content>
  </ion-page>
</template>

<script lang="ts">
import {
  IonContent,
  IonHeader,
  IonPage,
  IonTitle,
  IonToolbar,
  IonButton,
  modalController,
} from "@ionic/vue";
import { defineComponent } from "vue";

import Modal from "@/components/modal.vue";

export default defineComponent({
  name: "Home",
  components: {
    IonContent,
    IonHeader,
    IonPage,
    IonTitle,
    IonToolbar,
    IonButton,
  },
  setup() {
    const openModal = async () => {
      const modal = await modalController.create({
        component: Modal, //Modal is name of the component to render inside ionic modal
      });
      return modal.present();
    };

    return { openModal };
  },
});
</script>

```
1. Import modalController from @ionic/vue.
2. Import component Modal from @/components/modal.vue.
3. Create method openModal to present the modal when "Open Modal" button is clicked.

#Create method to close the modal
*@/components/modal.vue*
```vue
<template>
  <ion-header>
    <ion-toolbar>
      <ion-title>Modal</ion-title>
    </ion-toolbar>
  </ion-header>
  <ion-content class="ion-padding">
    This is a modal <br />
    <ion-button @click="closeModal">Close Modal</ion-button>
  </ion-content>
</template>

<script>
import {
  IonContent,
  IonHeader,
  IonTitle,
  IonToolbar,
  IonButton,
  modalController,
} from "@ionic/vue";
import { defineComponent } from "vue";

export default defineComponent({
  name: "Modal",
  components: { IonContent, IonHeader, IonTitle, IonToolbar, IonButton },
  setup() {
    const closeModal = () => {
      modalController.dismiss();
    };

    return { closeModal };
  },
});
</script>
```
1. Import modalController from @ionic/vue.
3. Create method closeModal to dismiss the modal when "Close Modal" button is clicked.
All about Control-Flow in Modern Js (2)
Published: 2020-12-27 17:26:39

### Hoo-AH , In this article we will go throw Control-flow in js and learn how to use , As i mentioned before in [ES6 vars&dataTypes](https://dev.to/rahmanii/intro-to-modern-js-es6-1-variables-newkeywords-data-types-in-one-code-file-58g5) all codes will be in one Js file with examples and results, So,enough videos just take 5 mins to read it.

> File will contain topics like:

* For loops
* Looping throw data like arrays
* Wile loop
* Do While loop 
* If statements
* If else & else if statement

```js
                Code Written by Abd-Elrahman
// for loops

for (let i = 0; i < 5; i++) // here we gonna print the numbers from 0 and stop at 4 because the condition is i is lessthan 5
{
    console.log(i); // output  0 1 2 3 4  
    
}

//looping throw data like array
const friends = ['Ahmed','hameed','hassan','ragab'];

for(let name = 0; name < friends.length; name++)
{
    console.log(friends[name]); // output 'Ahmed','hameed','hassan','ragab'
}

//======================================================================================

// while loop

let i = 0; //here we define the start point

while (i < 5) //here we define the condition
{
    console.log('in loop: ',i); // ouput is 
    i++; //here we iterating throw the the condition till it reach 4 
    
} 
let name = 0 ;
while (name < friends.length) 
{
    console.log(friends[name]); // output 'Ahmed','hameed','hassan','ragab'
    name++;
}

//======================================================================================


// do while loop  it's guarantee that the condition gonna excute one time at least even the condition isn't true!

let x = 5;
do {
    console.log('val of i: ',x); // output is val of i:  5
    x++
} while (x < 5);



let y = 0;
do {
    console.log('val of i: ',y); // output is 0 1 2 3 4 
    y++
} while (y < 5);

//======================================================================================

// if statements

const age = 25 ;

if (age > 20) {
    console.log('your are over 20 years'); // your are over 20 years

}
 
//======================================================================================

// if else & else if statement
const password = 'password';

if(password.length >= 12)
{
    console.log('that password mighty be strong');
}
else if (password.length >= 8 ) 
{
    console.log('password is long enougha');
}else{
    console.log(' password is not long enough');
}

```
#Day 17: Web development day 2, DSA stack
Tags: 100daysofcode, codepen
Published: 2020-12-27 17:40:34

I studied about hyperlink,images, videos, embed(iframe) and Tables. In tables I learnt about things like heading, columns, rows, border,border-collapse,rowspan and colspan.
I'm attaching the link for Tables here for your reference.
https://www.w3schools.com/html/html_tables.asp
I'm sharing my today's work here.

{% codepen https://codepen.io/_mahimasingh_/pen/GRjObNr %}

I was just so engorssed in web development that I did not pay heed to the time so I only solved 1 problem of "Game of 2 stacks" on HacerRank.
How the Amazon interview set me thinking about my soft skills
Tags: developer, skills, algorithms, programming
Published: 2020-12-27 17:38:12

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/izrprdmjxygq79kezhv3.jpg)

I decided to share here the experience I had when I did the job interview at Amazon. I didn't spend, but I have some learning about that. 

I thought about my career and my soft skills, and I don´t know if you will agree with me, but let´s go. The Amazon test that I did, I had problems to solve, I don´t know the details but that I remember, I had to use some kind of algorithm and I separated a time to study this algorithm, it´s wasn't easy for me. 

Anyway, I knew it would be difficult to move to that position, but I wanted to try. So I was studying for two days about the algorithm: BigO, Diijkastra, and QuickSort. I still didn't get the job, but I got the chance to try and about what I want.

The biggest companies like Amazon, Google, Facebook, etc, most likely the tests for a job opportunity they are looking for people that have a domain in the algorithm, data structure because they look for minds that know how to solve complex problems. I'm not saying it is impossible, no I don´t. What I want to say is you need to prepare more if you want to work for the biggest companies technology.

**Developers and Work**

Today we know how the IT area has a lot of job opportunities, has a lot of people changing the area, because the salary, opportunity, change etc.

In my opinion, all programmers need to have some knowledge of algorithms and data structure. When I say algorithms and data structure I mean say basic knowledge for example BigO, Binary search algorithm, Recursion, QuickSort anyway to understand data structure and how things work underneath the framework.

If you want to work with the biggest companies for example Google, Facebook, Amazon, LinkedIn whatever you need a broad domain of it. I thought a lot about the job test that I made the Amazon. I think why didn't I have this domain before? I don't know, maybe I think about the framework that made them work for us for underneath. Do not be a slave your framework!

Okay, if you want only a great salary and do your job without worrying about it, you can to continue working normally. But, if you want to grow, you need to change your habits.

**My focus**

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

I decided to focus more on algorithms and data structure and better my skills. So I wrote some tips, my opinion and feel free to follow these tips:

* **BigO Notation** 
* **Binary Search**
* **Recursion**
* **QuickSort**
* Understand how the framework works
* Some Knowledge of Architecture
* Some Knowledge Designer Patterns
* Some Knowledge Unit Test
* Some Knowledge DevOps

**Conclusion**

Don't be dependent on your framework, to understand how things work. You don't need to digest all the existing data structures, but you do need to know how things work under your framework.
Head start with CSS Transitions and Transform
Tags: css, html, beginners
Published: 2020-12-27 17:07:58

Another good way to add great effects with CSS is using transitions, it helps to transform CSS properties from one to other smoothly with duration between them.

The two keys properties to get it are:
- `transition-property`: set which property we want to add the transitions for example width, height or border.

The transition property can mix up more than one property like:
```css
transition-property: width, height
```

- `transition-duration`: set time spend between them. 
```css
transition-duration: 0.6s, 
```
On my example 2 boxes one with transition over change his properties on hover smoothed and other not.

{% jsfiddle https://jsfiddle.net/danywalls4/kfdmo8q6/43/ result,html,css %}

We can add 2 optional parameters `transition-delay` it set time to start and `transition-timing-function` set speed form start or end, for example, the animation wait 2 second to start.

By default, is `easy` but you can set other types like `ease-in` it has a slow start or `linear` it set the same speed from start to end.

{% jsfiddle https://jsfiddle.net/danywalls4/kfdmo8q6/14 result,html,css %}

## transform

The transform help us to change position, size and shape of elements and can be mixed with transition to get great effects.

The transform accepts other functions like to `translate`, `rotate`, `scale`. 

Like other CSS properties like width and height, we can apply transition on the transform to get a great effects:

My first example is with transform using rotate, it will move the element on hover 65 deg.

```css
main:hover {
	transform: rotate(65deg);
	border: 8px solid red;
	background-color: yellow;
}
```
{% jsfiddle https://jsfiddle.net/danywalls4/kfdmo8q6/28 result,html,css %}

Transform accept other options like:
- translate(x , y) move elements using the coordinates x and y.
-rotate: rotate the element using deg like example `rotateY(180deg)` or `rotateX(180deg)`;

-scale: scale an element between x and y.

And we can use all of them together like:
```css
transform: scale(4) translate(50px, 50px) rotate(90deg);
```
{% jsfiddle https://jsfiddle.net/danywalls4/kfdmo8q6/37 result,html,css %}

If you want to read more about transform feel free to check the full list in [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/transform).

# That's it!
Hopefully, that will give you a bit of help with Transitions and Transform in CSS. If you enjoyed this post, share it!
#10 DevOps Diary: #100DaysOfKubernetes Let's go
Tags: devops, 100daysofkubernetes, kubernetes, cloud
Published: 2020-12-27 17:07:24

Hey everyone,

I hope you are doing well and thank you for joining me to week 10 of the DevOps Diary newsletter 🎉

If you are celebrating Christmas, I hope you have/had a lovely time. 

Now for the news that I mentioned in my last newsletter, here it comes:

## The News 📢

In this week's newsletter, I would like to share with you my new challenge:

✨#**100DaysOfKubernetes** ✨

My goal is to learn something new about Kubernetes each day. Every day (except weekends), I will be posting a video on my YouTube about the new content that I came across.

I would love for you to join me on this challenge. If you have any suggestions on what I should spend some time learning, please do let me know. 

My goal is to inspire others to start exploring topics they are interested in; whether those are related to DevOps or not, there is so much to learn and to explore.

- [Follow my journey on YouTube](https://www.youtube.com/channel/UCb4mfRT5UWpjoUQRcIE2qOQ?sub_confirmation=1)
- [All of my notes on my public notion page](https://www.notion.so/researchandstudy/DevOps-Diary-2e5c82e48d374442858fc8295070a4b8)
- [Reach out to get involved or with suggestions](https://anaisurl.com/contact)

And now to this week's content.

## Podcast 🎤

StackRox launched a [Kubernetes-focused podcast: ‘Screaming in the Cloud’](https://www.stackrox.com/post/2020/12/screaming-in-the-cloud-eliminating-security-risks-in-kubernetes/)

The first episode is focused on Eliminating Security Risks in Kubernetes.

## [Read the full newsletter here](https://blog.anaisurl.com/10-devops-diary/)
Placeholder title
Tags: dohackathon
Published: 2020-12-27 16:42:39

## What I built

### Category Submission: 


### App Link


### Screenshots


### Description
 

### Link to Source Code

### Permissive License


## Background
(What made you decide to build this particular app? What inspired you?)

### How I built it 
(How did you utilize DigitalOcean’s App Platform? Did you learn something new along the way? Pick up a new skill?)


### Additional Resources/Info
2D Top-Down Aiming Using the Mouse in Unity3D
Tags: unity3d, gamedev, csharp
Published: 2020-12-27 16:36:20

Originally published on my blog: [Here](https://alessiofranceschi.me/2020/04/02/unity2d-make-a-sprite-face-the-mouse-cursor.html)

I would like to show you how to make a sprite face the mouse cursor. This is quite useful for aiming in top-down shooters and similar games.

I tried various solutions found on the web, but most of them don't work, work sometimes or work badly. Luckily the easiest solution is also the best one! I found it on [YouTube](https://www.youtube.com/watch?v=_XdqA3xbP2A) and it is made by Danndx.

### The code
Here's the full code:
``` cs
Vector3 mousePosition = new Vector3 (Camera.main.ScreenToWorldPoint(Input.mousePosition));

Vector2 directionToLookAt = new Vector2(
    mousePosition.x - transform.position.x,
    mousePosition.y - transform.position.y
    );

transform.up = directionToLookAt;
```

If you are in a hurry you can just copy-paste this code into a script on the object you want to rotate and then call it in the function Update. 
But what does this code actually do?

### Explaining the code
``` cs
Vector3 mousePosition = new Vector3 (Camera.main.ScreenToWorldPoint(Input.mousePosition));
```
Here we get the current mouse position, we translate it into "world coordinates", which are actually usable, and then store it in a Vector3 variable. 

``` cs
Vector2 directionToLookAt = new Vector2(
    mousePosition.x - transform.position.x,
    mousePosition.y - transform.position.y
    );
```
Create a new Vector2 and store the difference between the mouse position and the object position. We don't actually need the z axis, so we won't use a Vector3 this time.

``` cs
transform.up = directionToLookAt;
```
[transform.up](https://docs.unity3d.com/ScriptReference/Transform-up.html) *"Manipulates a GameObject’s position on the Y axis (green axis) of the transform in world space"*, according to Unity's Docs. 
Basically, we rotate the Y axis of the object.

That's all!
Run robot framework test using Puppeteer
Published: 2020-12-27 16:32:32

<sub><span>Photo by <a href="https://unsplash.com/@denisseleon">Denisse Leon</a> on <a href="https://unsplash.com/s/photos/robot">Unsplash</a></span></sub>

# Running Robotframework tests using Puppeteer

A [framework](https://qahive.github.io/robotframework-puppeteer.github.io/) has been developed as an alternative to SeleniumLibrary, to run tests using Puppeteer.

The [framework](https://github.com/qahive/robotframework-puppeteer) can use Playwright as well.
As the Azure Function support [running puppeteer and playwright](https://anthonychu.ca/post/azure-functions-headless-chromium-puppeteer-playwright/), the benefits are obvious.

But, all keywords developed by SeleniumLibrary is not available in PuppeteerLibrary (such as **Page Should Contain Element**).

# Running Playwright on WSL


A [Dockerfile](https://raw.githubusercontent.com/microsoft/playwright/master/docs/docker/Dockerfile.bionic) for ubuntu / WSL is available to test playwright, but be aware of some issues in headless mode !

A [Support](https://github.com/microsoft/playwright/blob/master/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-linuxwsl) page is available.


Hope this helps !
Hackers VS Admins (Part 2) - DEV + DO Hackaton
Tags: dohackathon, writing, codenewbie
Published: 2020-12-27 16:26:28

# Intro

Hi all, initially this was supposed to be my third post but due to my need to put the official submission as the last post, I am writing this post now as second. In this post, I will share my final thoughts on the hackathon and the state of my programming skills after it.

# My thoughts about the hackathon

This was my first hackathon and I am highly motivated to attend others in the future. I never imagined how much stuff I am able to learn in the span of two (or so) weeks. My concentration is boosted by a lot and I learned if I am lazy, I should just hop into the code and eventually get dragged deep into it. I also learned that however way a person is stuck, he can always get out of the hole with the proper method. For me personally, this was to take a break, or even sleep it through and continue on the next day. I am also thankful to all the people who post answers on the web and boost the IT industry with their knowledge.

On the technical side, I learned the following:

* How to use array.filter in JS
* How to use array.map in JS
* How to use classes in JS
* How to use constructors in JS
* How to set Socket.IO to not reconnect after some time
* How to make Socket.IO use the socket instead of HTTP polling from the start
* How to use JSON.parse
* A lot of small JS details

There may be more but I cannot currently remember and I am a little exhausted to go through all of my code again.

In general, this was a unique experience that I am highly looking forward to experiencing again.

# My takeaways

What I can take away from this hackathon is the following:

* Always google your problem
* Do not give up if you are stuck, just let the moment pass for a bit
* Don't assume something is too hard for you to learn
* Learn with projects
* Don't rush into the 'easy way'
* Whatever you build, it is going in your portfolio, so make use of every opportunity you have.

# Thank you section

Once again thank you to the people who post on the web. Your content is highly appreciated. Also, thank you to all the people who keep the community active and make hackathons like this one possible. And one big thank you to all the people who build open-source frameworks and software that make hard tasks easier for us.

# Side note

If I remember correctly, I said I will comment on my code and try to explain how some parts of it work. However, I am really exhausted after nearly two weeks of non-stop coding and I want to get some rest. Once I rest, I will comment on all of my code, format it, and make a post about it. If you were looking forward to it and feel betrayed (I doubt it), sorry, and keep an eye out for my post. 👀