teleren/devto huggingface dataset:
Laravel enforcing strict passwords with Regex
Tags: laravel, github, gist, regex
Published: 2019-07-03 09:41:28

Recently I had someone comment on one of my gists which I created a few years ago. It was a gist to help create strict password validation with Regex. I honestly completely forgot about it until that email.

When taking a look, I thought to myself "Oh wow! Did I make this?". I then looked down at the comments which I never saw before and noticed it's helped out quite a lot of people.

I thought it was only fair I should share it to others in case they need it to. So without further ado, here's the link for your viewing pleasure.

https://gist.github.com/Michael-Brooks/fbbba105cd816ef5c016

There are some very helpful comments, so please feel free to read them and I hope it helps you out for your Laravel projects. And if you create something useful in your own code, don't forget to share it in a gist as it could help others.

If you have your very own useful gists, please feel free to share too.

UPDATE: It's been noted that this could be seen as a recommendation or "this is how I think passwords should be done". It isn't and these were requirements from a former client which had been formally agreed upon. I would recommend better password validation rules and using a password strength indicator. This can be seen on my [Reddit post here](https://www.reddit.com/r/laravel/comments/c8m9f0/laravel_enforcing_strict_passwords_with_regex/)
#PureCSS - Responsive Avengers Logo
Tags: codepen, css, purecss
Published: 2019-07-03 09:40:07

---
title: #PureCSS - Responsive Avengers Logo
published: true
tags: codepen,css,purecss
---

<p>Responsive Avengers Logo using CSS</p>

{% codepen https://codepen.io/AsyrafHussin/pen/RJrywp %}
If I could go back in time and speak to myself 5 years ago, I would say...
Tags: discuss
Published: 2019-07-03 09:24:23

---
title: If I could go back in time and speak to myself 5 years ago, I would say...
published: true
description: What would you tell your younger self 5 years ago? Any words of advice? Wisdom? Encouragement?
tags: discuss
---

If you could go back in time and approach the 5-year younger version of yourself, what would you tell yourself? Any words of advice? Some wise nuggets learned during the past five years? Something to definitely do? Something to definitely not do?
Fanfare of modern development
Tags: team, culture, productivity, workplace
Published: 2019-07-03 09:16:05

---
title: Fanfare of modern development
published: true
description: a grumpy attempt to explain my past and present work environments
tags: team, culture, productivity, workplace
---

A few months ago I hit 40. I am only mentioning this to state that I have a decent amount of experience and presence in this industry and development in general. To be honest I don't feel 40.

I love being a software engineer. I enjoy solving complicate problems and designing systems. I like trying new languages, frameworks and new concepts and generally keep being up to date. I like to explore and use new workflow methodologies (like agile) since they tend to improve the quality of work.

But that is where I stop. And that was where I always stopped (I will explain the hidden meaning behind that in a bit).

Lately (last 5 years there have been some constant changes), in most teams I've been part of, have been introduced to various changes concerning em, either the way we work or the way to keep us engaged, satisfied or in the way to make us progress through our career (not sure how those help in this one). Changes which to be honest I can categorize and describe them as.

A. Improvements
B. Pointless
C. Irritating
D. Disruptive

Agile, agile is certainly an improvement. But, it is an improvement, only if the project or the business workflow is suitable for it. Same thing applies to everything that accompanies agile (standup,   

Then there are other changes which I don't mind and are categories as pointless, those usually include perks like ping pong tables, gaming consoles, beers on fridays etc. I get them, I understand why some people like them, It just happens that they are not my definition of fun... Not to mention I already enjoy my work, I am happy designing and coding. 

I got a different definition of fun which mainly includes things that don't mingle with work, like playing music with a band or cycling or going out with friends or playing board games with my daughter and wife.

Then there are the "things" I don't understand and they function mainly as background noise to me. Like naming your team with hipster-ish names "stargazers" "rocket" "ducks" or naming your sprints with random catch phrases (Ill take a date over any name so I can easily figure out without fuss when that X ticket got first added into a sprint) but lots of devs seem to enjoy them. 

In this list I can also add, frequent project catch up, when there is nothing to catch up about, because you were working on a different project in the last two sprints.

Lastly there are things which actually extremely annoying and disruptive. Things like you need to cheer after a stand up like "go go team rocket" (I don't have that in my current work place 👍 and I am definitely quitting if we do). Or like not having a specific desk and have a sit wherever there is space type of office scheme (probably to emulate a coffee shop) (puke).
How to Rank on the First Page of Google 
Tags: seo
Published: 2019-07-03 08:55:55

In the event that you are in any way similar to me, you are at this point mistaken for all the publicity and data over-burden on the most proficient method to improve site traffic and there by rank effectively on Google's first page. The web if so over-burden with sites that private ventures experiences considerable difficulties rivaling those enormous organizations for very focused hunt terms. 

Positioning in the primary page in one of the web crawlers is an absolute necessity; on the off chance that you are to procure a good pay without begging to be spent all the while. In the event that you have millions to spend; at that point it is by and large an alternate ball game. You can re-appropriate the SEO part to an outsider and unwind; however we little clocks haven't quite a lot of cash to fire up our web advertising business and get it off the ground. 

PPC is one choice that you can use to rank on Google's first page effectively, however cost per click for focused watchwords has shot over the sky. Regardless of whether you are happy to contribute this cash there is no certification that you can recoup it with 50-100 ticks. You may not realize the amount you should spend until you begin to see even a little benefit. This is perilous first off like you and me. 

The most ideal approach to get positioned high on Google or some other web search tool so far as that is concerned is, to focus on the natural traffic or free traffic for your particular watchwords. According to web showcasing specialists; natural traffic is on the ascent by and by in 2010 and PPC and web 2.0 traffic will back off radically in 2010. 

So as to rank high in the SERP's naturally you should set up a serious remaining task at hand. This will incorporate on-page just as off-page streamlining techniques, for example, article showcasing, social book stamping, etc. In the event that you have in any event a little online encounter; you certainly would realize how dull this sort of work is? 

Hire an <a href="http://www.niteshprasad.com/">SEO Expert</a> to rank on Google 1st Page...
How does Bubble Sort work?
Published: 2019-06-27 00:02:38

---
title: How does Bubble Sort work?
published: true
description: 
tags: 
---
### What is bubble sort?

Bubble sort is an algorithm where the largest value will bubble up to the top of a list, continue sorting this way we will have an ascending sorted array or list. We will use nested loops to compare each current items with the rest of the items in the list.

###Understand how to swap two elements using Javascript
```
//swapping function takes an array, and two indexes

 function swap2(arr, index1, index2){
     let temp = arr[index1]; //let a temp variable to hold index1's value
     arr[index1] = arr[index2]; //replace index1 with index2' value
     arr[index2] = temp;//finally replace index2 with temp, which was index1
 }
```
In the ES2015 we can do swapping using this syntax
```
const swap = (arr, index1, index2) => {     
[arr[index1], arr[index2]] = [arr[index2], arr[index1]]
 }
```
###Implement bubble sort using nested array - Javascript
Sudo Code:
1.iterate the array reversely
2.create a counter variable
3.iterate the inner loop to compare each item
4.swap the items if the current item is greater
5.when swap happens, set noSwap to false so that it won't break the loop
6.when noSwap never set to false, loop breaks.

```
function BubbleSort(arr){
    for(let i = arr.length; i >0; i--){ 
        let noSwap = true; 
        for(let j =0; j < (i-1); j++){ 
            if(arr[j] > arr[j+1]){ 
                let temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j+1]= temp;
                noSwap = false;
            }
        }
        if(noSwap){break;}
    }
    return arr;
}

```

The time complexity for bubble sort is O(n^2), making it less popular compare to merge sort and other sorting algorithms.
Managing Your State Navigation Data is a Breeze Using Angular and Akita
Tags: angular, akita
Published: 2019-07-03 08:41:30

The [Akita ng-router-store](https://github.com/datorama/akita-ng-router-store) is a neat package offered to Akita users, which enables binding the Angular router state to an Akita store. The benefits of this approach are:
* The router state is stored in an Akita store named router, which serves as the single source of truth for things such as URL, state data parameters, query parameters, etc.
* Our components don’t have to be familiar with the data source. The RouterQuery can be injected in any one of the queries to create an encapsulated derived selector.
* The library exposes Akita style queries, saving you from dealing with all the required boilerplate code.
* We can examine the current router state in the Redux devtools and perform ‘time-traveling’.
To get started, install the package and add it, as well as Akita’s devtools module, to the app module:

{% gist https://gist.github.com/theblushingcrow/8c722574b07e74e43b92750ed1da15d2 %}

At this point you should see the router store in the Redux devtools, and you have at your disposal the following query API:

{% gist https://gist.github.com/theblushingcrow/c59c729baeea36c20364b9e9d2cca7a2 %}

For example, let’s say we want to query the current entity based on the URL `id` parameter, we can do the following in our `ArticlesQuery` class:

{% gist https://gist.github.com/theblushingcrow/b8819add45ffbd372bfdad71bd70c190 %}

And use it in our component:

{% gist https://gist.github.com/theblushingcrow/b5e297f211047eec7c3d50d7a16066d9 %}

Voila — easy breezy navigation management!

Last but not least: A new version of Akita just landed in Github! You can check out the breaking changes and the new features [here](https://github.com/datorama/akita/blob/master/BREAKING_CHANGES.md#400).

Follow me on [Medium](https://medium.com/@inbalsinai) to read more about Angular, Akita, JS!
SPFound is now on Product Hunt
Published: 2019-07-03 08:29:19

🎉🎉🎉 VERSION 1 is now public 🎉🎉🎉 

https://www.producthunt.com/posts/spfound

Hey

For the past year, I have been experimenting and creating new projects to release to the community. However, I felt that I kept trying to do jobs that I couldn't really do. So I decided to try and get some help but kept finding it so difficult to find anyone who could help me. I also found that there was no central location, where I could easily get help for my projects. So I decided to build SPFound, a central location where users can post their projects that they need help with and explain what help they need so that other users that come onto the site, who are looking to help others can simply choose a project and contact the Project creator.

Now, this is version 1 of the site, meaning that site is not yet fully complete with all the feature I want to integrate, but has all the core features built and is functional to start using. 

Here are some of the features I wish to integrate.

🛠Upcoming Features:
- Contact forum
- CMS ( so that users can create, edit, and delete a post)
- User Accounts
- Better looking form
- search
- User Profiles
- Sharing (so users can share the projects that need help to other people)

If you have any more ideas that you think would improve the site, please leave a comment, I will be sure to read and respond to them
Let's build a Perfect CSS Framework
Tags: discuss, css, framework
Published: 2019-07-03 08:24:50

---
title: Let's build a Perfect CSS Framework
published: true
tags: discuss, css, framework
---

This is an experiment I am doing to build a theoretically perfect CSS framework for teams. Here is how it goes:

1. You comment on this discussion with a problem/issue we currently face with writing CSS (with vanilla CSS or any library).
2. I'll reply (or anyone of you can too) with what can be the probable solutions to that issue.
3. In the end, we collect all those suggested solutions to build or search that "Perfect CSS Framework".

Sounds good? I'll start.
Daily tasks with JavaScript arrays
Tags: javascript
Published: 2019-07-03 07:59:03

Arrays are everywhere and we have to use them all the time.

I created this article specially for you, so you have a quick reference of the most common things you usually do with Arrays on a daily basis 😊

# Table Of Contents 📋
  * [Find in array 🔍](#find)
  * [Filter an array 🕵️](#filter)
  * [Loop arrays 🔁](#for-each)
  * [Sort an array of objects ⬆️ ⬇️](#sort-array-of-objects)
  * [Add an element to an array 🗳️](#add-element)
  * [Remove an element from an array 🗑️](#remove-element)
  * [Create an array from an existing array (Map) 📦](#map)
  * [Accumulate array values (Reduce) 🐝](#reduce)
  * [Combine arrays (Concat) 🍔](#concat)

## Find in array 🔍 <a name="find"></a>

{% stackblitz js-unnjzd view=editor file=index.js %}

## Filter an array 🕵️ <a name="filter"></a>

{% stackblitz js-ab23r7 view=editor file=index.js %}

## Loop arrays 🔁 <a name="for-each"></a>

{% stackblitz js-levmgn view=editor file=index.js %}

## Sort an array of objects ⬆️ ⬇️ <a name="sort-array-of-objects"></a>

{% stackblitz js-zcakfp view=editor file=index.js %}

## Add an element to an array 🗳️ <a name="add-element"></a>

{% stackblitz js-sxnaqn view=editor file=index.js %}

## Remove an element from an array 🗑️ <a name="remove-element"></a>

{% stackblitz js-zx4cyc view=editor file=index.js %}

## Create an array from an existing array (Map) 📦 <a name="map"></a>

{% stackblitz js-qz32n7 view=editor file=index.js %}
  
## Accumulate array values (Reduce) 🐝 <a name="reduce"></a>

{% stackblitz js-k8taan view=editor file=index.js %}

## Combine arrays (Concat) 🍔 <a name="concat"></a>

{% stackblitz js-c9wmqk view=editor file=index.js %}

Hope you enjoyed this reading 🥳. Feel free to save this article into your bookmarks 🔖 so you have it available at your fingertips.
Introducing the Flexbox builder tool! Build a Layout and Learn at the Same Time
Tags: webdev, css, html, vue
Published: 2019-07-03 07:39:09

---
title: Introducing the Flexbox builder tool! Build a Layout and Learn at the Same Time
published: true
description: Introducing the Flexbox tool on devinduct.com! Create your layout with ease and visually learn about flexbox while doing it.
tags: #webdev, #css, #html, #vue
---

Introducing a simple Flexbox builder tool, built with Vue!

- Build your layout with a couple of simple clicks
- Real-time output changes
- Changeable HTML output (`div`, `section`, `ul`)
- Copy & Paste the HTML/CSS for further styling
- Setup the flexbox container and each item independently
- Share the CSS between the flexbox items
- Learn as you play with it by visualizing the changes

Check it out here: [Flexbox Builder Tool](https://devinduct.com/workshop/flexbox)
Force Downloading of File instead of Opening in Browser
Tags: devops
Published: 2019-07-03 07:06:01

When you go through the link, some files will be opened in the browser. Such behavior is typical for some content types (e.g., images, pdf, etc.)

However, you can force file downloading instead of opening when an user clicks on the link though.

### 1st way (frontend):
HTML attribute *download* allows you to do this.
```html
<a href="/public/report.pdf" download="stat_report">
```
If the value of the attribute is omitted, the original filename would be used.
However, be careful. This attribute isn’t supported in some old browsers without HTML5 support.
Renaming does not work if the given file stored on another host.

### 2nd way (backend):
You can set HTTP header `Content-disposition`.

for Nginx:
```nginx
location ~* /public/(.+\.pdf)$ {
    add_header Content-disposition "attachment; filename=$1";
}
```
for Apache:
```apacheconf
<IfModule mod_headers.c>
    <FilesMatch "\.(?i:pdf)$">
        ForceType application/octet-stream
        Header set Content-Disposition "attachment"
    </FilesMatch>
</IfModule>
```
note: android command line
Tags: android, commandline
Published: 2019-07-03 07:26:50

---
title: note: android command line
published: true
description: 
tags: android, commandline
---

this is note of android command line stuff for me.

# Gradle

after booting your linux you should run below once.

```
./gradlew --daemon
```

assembleDebug is my task name so you should change it by your gradle task name

```
 ./gradlew cleanBuildCache clean assembleDebug --configure-on-demand -x test
```

# Volley
```
adb shell setprop log.tag.Volley VERBOSE
```

# reset 
```
rm -fr .idea
rm -fr ~/.gradle
```
then build

# jarsigner

```
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore /path/to/keystore -signedjar app/build/outputs/apk/release/app-release-signed.apk app/build/outputs/apk/release/app-release-unsigned.apk keystorealias
```


# How to pick up realm file
```
$ adb shell
$$ run-as ${package.name}
$$ ls -laF files/
$$ cat files/default.realm > /sdcard/Download/default.realm
$$ exit
$$ exit
$ adb pull /sdcard/Download/default.realm .
```
Keyboard input with React Hooks
Tags: react, javascript, tutorial, video
Published: 2019-07-03 07:20:47

{% youtube hdBz7irTpyk %}

Guess who's back, *it's me*!

I really enjoyed making my first youtube video, so I decided to start a series on  creating custom react hooks!

This one's about creating a `useKey` hook, that allows you to know when a certain keyboard key is pressed. I also cover some of the "rules of hooks", how short circuit evaluation violates the rules, and how to get around that..

Again, any feedback is highly appreciated, thanks for reading and/or watching!

---

```jsx
function useKey(key) {
    // Keep track of key state
    const [pressed, setPressed] = useState(false)

    // Does an event match the key we're watching?
    const match = event => key.toLowerCase() == event.key.toLowerCase()

    // Event handlers
    const onDown = event => {
        if (match(event)) setPressed(true)
    }

    const onUp = event => {
        if (match(event)) setPressed(false)
    }
    
    // Bind and unbind events
    useEffect(() => {
        window.addEventListener("keydown", onDown)
        window.addEventListener("keyup", onUp)
        return () => {
            window.removeEventListener("keydown", onDown)
            window.removeEventListener("keyup", onUp)
        }
    }, [key])

    return pressed
}

```
Safe Navigation vs Try in Rails (Part 2: Performance)
Tags: ruby, rails
Published: 2019-07-03 07:06:18

This Note is an extension of [Safe Navigation vs Try in Rails (Part 1: Basic Differences)](http://jetrockets.pro/til/posts/ats3ic6xvx-safe-navigation-vs-try-in-rails-part-1-basic-differences)

Method `try()` comes from Active Support component of Ruby on Rails. Safe Navigation Operator is Ruby native feature.

Let's check performance!
```ruby
require 'benchmark'

class Foo
  attr_accessor :name
end

foo = Foo.new
bar = nil

Benchmark.bm(35) do |x|
  x.report('Successful access: try(...): ')         { 1_000_000.times { foo.try(:name) } }
  x.report('Successful access: &.: ')               { 1_000_000.times { foo&.name } }
  x.report('Successful access: control sample: ')   { 1_000_000.times { foo.name } }
  x.report('Failed access: try(...): ')             { 1_000_000.times { bar.try(:nonexistent) } }
  x.report('Failed access: safe navigation: ')      { 1_000_000.times { bar&.nonexistent } }
end;nil
```

```
                                          user     system      total        real
Successful access: try(...):          0.498216   0.005748   0.503964 (  0.530010)
Successful access: &.:                0.062146   0.000943   0.063089 (  0.069714)
Successful access: control sample:    0.062411   0.001098   0.063509 (  0.069603)
Failed access: try(...):              0.172535   0.004374   0.176909 (  0.194386)
Failed access: safe navigation:       0.054141   0.001029   0.055170 (  0.065502)
```

Safe navigation is about 7 times faster than method `try()` for successful navigation and 3 times faster for unsuccessful.
Safe Navigation vs Try in Rails (Part 1: Basic Differences)
Tags: ruby, rails
Published: 2019-07-03 07:06:10

There are some ways of preventing errors like `undefined method for nil:NilClass`.
- Rails Method `try(...)`
- Safe Navigation Operator (`&.`)
- Logical operator `&&` (AND)

Here is how these options look like:
```ruby
user.try(:company).try(:name)
```
```ruby
user&.company&.name
```
```ruby
user && user.company && user.company.name
```

But there are some differences.

**1. If model User hasn't relation `compppany` (it may be just a typo or renamed model relation/attribute):**
```ruby
user.try(:compppany).try(:name)
=> nil
```
You will receive `nil` and never been know about this typo.
```ruby
user&.compppany&.name
=> NoMethodError: undefined method `compppany' for #<User:0x000000123456789>
```
and
```ruby
user && user.compppany && user.compppany.name
=> NoMethodError: undefined method `compppany' for #<User:0x000000123456789>
```
Looks better!

**2. If model User has relation company, but company is `false`. `User.new(company: false)`:**
```ruby
user.try(:company).try(:name)
=> nil
```
```ruby
user&.company&.name
=> NoMethodError: undefined method `name' for false:FalseClass
```
Safe Navigation recognized `false`. Awesome!
```ruby
user && user.company && user.company.name
=> false
```
Hmmm, it does not look like we want.

**3. Performance**
Read the second part [Safe Navigation vs Try in Rails (Part 2: Performance)](http://jetrockets.pro/til/posts/nswsheigth-safe-navigation-vs-try-in-rails-part-2-performance)
Sidekiq Stats in Rails
Tags: ruby, rails, sidekiq
Published: 2019-07-03 07:05:53

If you use Sidekiq in your Rails project, you can watch tasks statistics through the web interface. Usually, you can find it here: https://yourdomain.com**/sidekiq** (but in your project path may be different).
If you don't have access there, you can get the same data in Rails console.

To get statistics (number of tasks) by each queue:
```ruby
Sidekiq::Stats.new.queues
=> {"local_cache"=>0, "default"=>0, "ts_delta"=>0, "mailchimp"=>0, "recorder"=>0}
```

Global statistics are available this way:
```ruby
Sidekiq::Stats.new.fetch_stats!
=> {:processed=>61390,
 :failed=>3220,
 :scheduled_size=>0,
 :retry_size=>0,
 :dead_size=>4,
 :processes_size=>1,
 :default_queue_latency=>0,
 :workers_size=>0,
 :enqueued=>0}
```

The same stats are available separately:
```ruby
stats = Sidekiq::Stats.new
stats.processed # number of processed tasks
stats.failed # number of failed tasks
stats.enqueued # number of enqueued tasks
```
and etc.

Also `Sidekiq::Stats` allows to look historical data. You can specify period. Something like:
```ruby
s = Sidekiq::Stats::History.new(2, Date.parse('2019-02-05'))
```
- first argument: number of days,
- second argument: date until which return stats (default value is today and can be omitted)
```ruby
s.processed
=> {"2019-02-05"=>0, "2019-02-04"=>0}
s.failed
=> {"2019-02-05"=>0, "2019-02-04"=>0}
```