teleren/devto huggingface dataset:
The best Laravel repositories solution in 30 lines of code
Tags: laravel, architecture, codequality
Published: 2019-09-13 14:31:35

### How a 30 lines piece of script can finally provide a good solution for a repository pattern in Laravel apps.

### __The problem__

Laravel provides a beautiful way to query your database through Eloquent, an Object Relational Mapping. The moment your project becomes larger there starts to rise a problem. The difference between entities and models start to become vague. Let me give you an example:

We have two methods, one called `findByName` and one called `concatName`.

{% gist https://gist.github.com/MrAtiebatie/ad998e3738db2a63849c80027cdfb650 %}

> What we are actually doing here is mixing methods for retrieving (collections of) Products, with methods for instances of 1 Product.

A much cleaner approach would be to separate them into 2 different classes. One for obtaining instances and collections of models and one for the model definition itself. You might call this the repository pattern.

![Wanted situation](https://cdn-images-1.medium.com/max/800/1*fNIlVlYebCX6im41PTsx6A.png)

There are several libraries for Laravel to start using the repository pattern. One thing that's a huge disadvantage to me is that you can't use Eloquent functions on your repositories. Since Eloquent is a huge reason why I am using Laravel I still wanted to be able to use Eloquent on repositories for obtaining models.

### __The solution__

I created a very simple piece of code which enables __all the features of Eloquent__ on your repositories. This way you can use the repository pattern in a way which is fun and keep your models and your repositories clean! A repository with the use of `laravel-repositories` would look like this:

{% gist https://gist.github.com/MrAtiebatie/9e0a22f6cf132d6f17837d5ee28e1d49 %}

By the use of the Repository trait and the `$model` property, `laravel-repositories` knows which model to query and where to use Eloquent and where to use your own repository methods. 

With this definition of the repository we can now use it in our controllers, jobs, commands etc:

{% gist https://gist.github.com/MrAtiebatie/bf647e982f5b45e56dee3c0e4d5e96e2 %}

> Go try it out and leave me some feedback for improvement!

[Link to Github repository](https://github.com/mrAtiebatie/laravel-repositories)

---

__Tired of writing copy that doesn't convert? Try [https://targetaudience.app](https://targetaudience.app)__
Daily Challenge #65- A Disguised Sequence 
Tags: challenge
Published: 2019-09-13 14:30:17

---
title: Daily Challenge #65- A Disguised Sequence 
published: true
series: Daily Challenge
description: [add a brief description of task]
tags: challenge
---

Given `u0 = 1, u1 = 2` and the relation `6unun+1-5unun+2+un+1un+2 = 0` calculate un for any integer `n >= 0`.

**Example:**
`fcn(n) returns un: fcn(17) -> 131072, fcn(21) -> 2097152`

**Note:** 
You can look at this as

-Purely algorithmic from the definition of u^n
-the second one - not at all mandatory, but as a compliment - is to get a bit your head around and find which sequence is hidden behind u^n 

***
_This challenge comes from g964 at [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!_
What would you want the most in Python 4?
Tags: python, discuss
Published: 2019-09-13 14:27:52

Now that python 3 has hit 3.8 we can expect that python 4 will come out pretty soon.

Please put in the comment the **most important single feature** that you wish python 4 will have.

To start, for me it would be a stricter typing: typing is currently just a **hint** and not enforced in runtime. In a big project it helps a lot to have typing for everything (variables, functions).  
Would be perfect if python can have a **static typing** mode that enforces this.
What was your win this week?
Tags: discuss, weeklyretro
Published: 2019-09-13 14:16:32

---
title: What was your win this week?
published: true
description: Got to all your meetings on time? Started a new project? Fixed a tricky bug?
tags: discuss, weeklyretro
cover_image: https://cl.ly/188e843c2985/download/Image%202019-02-15%20at%202.36.37%20PM.png
---

👋👋👋👋

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
- Contributing to OSS
- Cleaning your house...or whatever else that may spark joy 😄

![cool-friday-cat](https://media.giphy.com/media/xUPN39xtlB15k469TW/giphy.gif)
Matplotlib Python Tutorial
Tags: matplotlibpython, whatismatplotlibinpython, matplotlibtutorial, matplotlibpythontutorial
Published: 2019-09-13 14:03:21

You can learn Python much faster than any other programming language and this Python tutorial helps you do just that. Python programming is one of the best languages that is finding increased applications for machine learning. Our Python tutorial has been created with extensive inputs from the industry so that you can learn Python Programming and apply it for real world scenarios like machine learning and data science.

Watch Now: https://www.youtube.com/watch?v=w7kYqg_uS50&t=15s
Using Google Chrome Console On Any Mobile Device!
Tags: chrome, devtools
Published: 2019-09-13 13:39:19

---
title: Using Google Chrome Console On Any Mobile Device!
tags: #chrome, #devtools
published: true
---

Google Chrome is my default web browser in all my devices, in this post I'll share with you how to use the console on your mobile devices.

Let's Start.

## Android

1 - Enable **Developer mode** by going to **Settings** > **About phone** then tap on **Build number** 7 times.
2 - Enable **USB Debugging** from **Developer Options**.
3 - On your desktop, open **DevTools** click on more icon then **More Tools** > **Remote Devices**.

![Chrome Remote Devices](https://thepracticaldev.s3.amazonaws.com/i/6ep4ik8wlb308gopmr4b.png)

4 - Check on **Discover USB devices** option.
5 - Open chrome on your phone.
6 - Plug your phone via USB, then you will see an authorization popup click OK.
7 - You will be able to see your phone tabs and **Inspect** them.

![Chrome Remote Devices Debugging](https://thepracticaldev.s3.amazonaws.com/i/vvndbo98uq2onn9033f7.png)

## iOS And Others

Just open new tab and type: ``chrome://inspect``, then click on **Start logging** button, then visit the page that you want to debug.

I hope this helps you 🙏
redial - Terminal Based SSH Session Manager for Unix Systems.
Tags: python, devops, ssh
Published: 2019-09-13 13:35:12

Features:

- Add Folder
- Add Connection
- Browse over mc (Midnight Commander)
- Remove Connection
- Edit Connection
- Move sessions and folders
- More features coming soon..

https://github.com/taypo/redial

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/852fxwbum1fj39j3115m.gif)
How do I play a hidden video within a react app?
Tags: react, javascript
Published: 2019-09-13 13:33:08

I'm learning React by converting a previous jQuery based web app, over to React. However I have hit a snag. I'm trying to get a hidden video to play after x seconds using react-simple-idle-monitor. The I can get the video frame to play, and if I add the controls attribute the video can be played but I work out how to access the video using react. 

I have tried using refs, and accessing the document.getElementById('video').

This is my Screensaver component in Screensaver.js
```javascript
import React, { Component } from 'react';
type Props = {};

export default class Screensaver extends Component<Props> {
  props: Props;

  render() {
    return (
      <div className="screensaver">
        <video muted loop>
          <source
            src="../assets/video/my-video.mp4"
            type="video/mp4"
          />
        </video>
      </div>
    );
  }
}
```
Here is my render function in App.js
```javascript
render() {
    return (
      <IdleMonitor
        activeClassName="appActive"
        idleClassName="appIdle"
        timeout={30000}
        onActive={stopScreensaver}
        onIdle={startScreensaver}
      >
        <div className="panels">
          <Home />
          <Screensaver />
        </div>
      </IdleMonitor>
    );
  }
```
And here are the functions to start and stop the screensaver in actions/screensaver.js
```javascript
export function startScreensaver() {
   const videoFile = document.getElementById('screensaver-video');
   videoFile[0].play();
}
export function stopScreensaver() {
  const videoFile = document.getElementById('screensaver-video');
  videoFile[0].pause();
  videoFile[0].currentTime = 0;
}
```

After the timeout triggers, the video container is shown via CSS but the video does not play.

At the moment I get the error that videoFile[0] is undefined.
Pig Tutorial 
Tags: pigtutorialhadoop, whatispiginhadoop, apachepigtutorial, pigtutorial
Published: 2019-09-13 13:31:15

Data is being generated hugely in each and every industry domain and to process and distribute effectively hadoop is being deployed everywhere and in every industry. Taking the Intellipaat big data hadoop training can help professionals to build a solid career in a rising technology domain and get the best jobs in top organizations.

Watch Now: https://www.youtube.com/watch?v=PY3TpaZiCGQ
Neural Network Tutorial 
Tags: neuralnetwork, howneuralnetworkswork, whatisaneuralnetwork, neuralnetworktutorial
Published: 2019-09-13 13:16:51

Artificial Intelligence is taking over each and every industry domain. Machine Learning and especially Deep Learning are the most important aspects of Artificial Intelligence that are being deployed everywhere from search engines to online movie recommendations. Taking the Intellipaat deep learning training & Artificial Intelligence Course can help professionals to build a solid career in a rising technology domain and get the best jobs in top organizations.
Bit, Bit Manipulation and Bitwise Operations — Codility
Tags: career, codenewbie, python, replit
Published: 2019-09-13 13:11:02

Preparing for an interview led me to my first Codility test. In preparation for the test, I had to refresh my knowledge of data structures and algorithms. The first lesson on Codility discusses Iterations and the first exercise, classified as “painless” (really), is a question to find the longest Binary Gap in a positive integer.


The first attempt, I got a 66% score, which to me is poor, and also my algorithm failed some of the other tests, shown later in the final results. In conclusion, this test kicked my ass, and it was supposed to be ‘easy’.

Like any curious programmer, I snapped out of it and decided to start publishing my thought-process through my attempts at making sense of data structures, algorithms, and basically all things programming. The result was phenomenal. 

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/5xmli98p6q8whqtq6hdx.gif)

Read about all of it on [Medium](https://medium.com/@ijayoa/bit-bit-manipulation-and-bitwise-operations-codility-13053175ec4d?sk=b37ea8b9c84dfa4bcfa951e7377a7615).
SQL Interview Questions and Answers
Tags: sqlinterviewquestions, sqlquestions, sqlinterview
Published: 2019-09-13 13:00:38

The SQL is one of the most important programming languages for working on large sets of databases. Thanks to the Big Data explosion today the amount of data that enterprises have to deal with is humongous.  If you are looking to clear the SQL interview then this SQL interview questions and answers is a must watch for you. In this SQL interview questions video you will learn what are the most probable questions that will be asked in the interview.
Around the Web – 20190913
Tags: blog
Published: 2019-09-15 03:29:05

---
title: Around the Web – 20190913
published: true
tags: Blog
canonical_url: https://wipdeveloper.com/around-the-web-20190913/
cover_image: https://wipdeveloper.com/wp-content/uploads/2017/07/WIPDeveloper.com-logo-black-with-white-background.png
series: Around the Web
---

And now for somethings to read (or watch) over the weekend, if you have some spare time that is.

## [Way Basic](https://www.gooddaysirpodcast.com/229)

**Good Day, Sir! Show**  – Jeremy Ross – In this episode, we discuss Salesforce’s new ad campaign, WeWork IPO, Uber continuing to invest in their Uber Freight division, Larry Ellison lawsuit over NetSuite acquisition, JetBrains developer survey, and the recent Apple Event announcements.

## [Logitech MX Master 3 Advanced Wireless Mouse](https://www.amazon.com/gp/product/B07S395RWD/ref=as_li_qf_asin_il_tl?ie=UTF8&tag=wipdevelope05-20&creative=9325&linkCode=as2&creativeASIN=B07S395RWD&linkId=4977e7c13aaa6a8e1c11ac6e259b8f35)

I’ve been getting annoyed by my Magic Mouse so I think I will give this one a try when it becomes available. I have the first generation of it and still use it occasionally so I have high hopes for it.

## [Caniuse and MDN compatibility data collaboration](https://css-tricks.com/caniuse-and-mdn-compatibility-data-collaboration/)

**CSS-Tricks**  – Sep 10, 12:51 PM – Easily manage projects with monday.com Second only to ‘silly GIFs,’ I’d guess screenshots of caniuse are the most common slide graphic at web conferences. It’s become the ultimate source for looking at web compatibility data in the hearts and minds…

## [Command Line Tools](https://www.netlify.com/docs/cli/)

**Netlify**  – Netlify’s command line interface (CLI) lets you deploy sites or configure continuous deployment straight from the command line. The new 2.0 version of our Node-based CLI was rebuilt from the ground up to help improve the site building experience.

## [Simplify your JavaScript – Use .some() and .find()](https://medium.com/poka-techblog/simplify-your-javascript-use-some-and-find-f9fb9826ddfd)

**poka-techblog**  – Etienne Talbot – Sep 4, 4:10 AM – Following the insane amount of views on my article on.map(),.reduce(), and.filter(), I thought I should share two more array methods that are useful tools in a JavaScript developer’s arsenal:.some() and.find(). This array method helps you determine…

## Till Next Week

Want to share something? Let me know by leaving a comment below or emailing [brett@wipdeveloper.com](mailto:brett@wipdeveloper.com)  or following and tell me on [Twitter/BrettMN](https://twitter.com/BrettMN).

Don’t forget to sign up for **[The Weekly Stand-Up!](https://wipdeveloper.com/newsletter/)** to receive free the [WIPDeveloper.com](https://wipdeveloper.com/) weekly newsletter every Sunday

The post [Around the Web – 20190913](https://wipdeveloper.com/around-the-web-20190913/) appeared first on [WIPDeveloper.com](https://wipdeveloper.com).
Can you give some tips for conducting an outreach program on engineering ?
Tags: discuss
Published: 2019-09-13 12:50:01

---
title: Can you give some tips for conducting an outreach program on engineering ?
published: true
description: We are planning to conduct an outreach regarding engineering, so it would be nice if you share some tips. 
tags: #discussion
---

Hi everyone,

I am a college student from India and we are planning to conduct an outreach program to inspire interested high school students into engineering and also educate on what should be expected from an engineering job mainly in the electrical and computer domain as we are students in those domains. 

Our initial plan includes a sort of a workshop and talk. Workshop would be to teach them to build something, maybe something using an Arduino. And the talk to point them to further resources. Feel free to add in anything.

Thank you
Git: Exclude a folder when diffing
Tags: git, gittips
Published: 2019-09-13 12:22:42

---
title: Git: Exclude a folder when diffing
published: true
description: How to exclude a folder when doing a git diff
tags: git, git-tips
---
When doing a `git diff`, especially between branches, you may be greeted with a mountain of changes that you have to sift through to find what you're looking for. 

Consider excluding certain folders:

```bash
git diff -- ':!<folder-name>'
```

You can also exclude multiple folders:


```bash
git diff -- ':!<folder-name>' ':!<other-folder>'`
```
Mevn-CLI, Light Speed setup for MEVN stack based apps
Tags: javascript, showdev, node, mongodb
Published: 2019-09-13 11:55:12

I'm pretty sure all of you guys would have gone through the pain of setting up your local environment just while getting started. The transition from Vanilla JavaScript to the modern day frameworks is a bit difficult for sure. This was the thought that led us to create [Mevn-CLI](https://github.com/madlabsinc/mevn-cli)

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/s41b3zbbsz7tb0rldcxi.png)

As from the docs, it is basically a CLI tool for getting started with the MEVN stack. It offers a super simple boilerplate template and additional utilities for building a MEVN stack based webapp. It takes away the hassle of setting up the local development environment which may become a nightmare especially for beginners who are just starting out.

## Quicklinks

- [GitHub Repo](https://github.com/madlabsinc/mevn-cli)
- [Docs](https://mevn.madlabs.xyz)
- [Other Guidelines](https://github.com/madlabsinc/mevn-cli/wiki)
- [Twitter](https://twitter.com/mevn_cli)
- [Open Collective](https://opencollective.com/mevn-cli)

We would love to hear out from the community. Take it for a spin and leave your thoughts down in the comments section. Also, contributions of any kind are warm welcome. Feel free to reach out :)
TypeScript: How to set a new property on the window object
Tags: typescript, interfaces, declarationmerging, globalaugmentation
Published: 2019-09-13 11:40:02

---
title: TypeScript: How to set a new property on the window object
published: true
description: Augmenting global interfaces in TypeScript
tags: TypeScript, interfaces, declaration-merging, global-augmentation
---
When merging global interfaces in TypeScript, you have to declare the interface in the `global` scope.


```ts
export declare global {
  interface Window {
    // add you custom properties and methods
    YT:(videoID: string, options?: {}) => Observable<YtResponse>
  }
}
```

TypeScript supports [declaration merging], the premise is the same for global objects. The difference is to declare the interface as part of the global scope.


[declaration merging]: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
Flutter- Whts-app like 3 tabs.
Tags: flutter
Published: 2019-09-13 10:46:24

import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {

  @override
  _MyHomePageState createState() => new _MyHomePageState();

}

class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {

  TabController _tabController;
  void initState() {
    _tabController = new TabController(length: 3, vsync: this);
    super.initState();
  }


  @override
  Widget build(BuildContext context) {
    return new Scaffold(

      appBar: new AppBar(
          title: new Text("WhatsApp", style: TextStyle(color: Colors.white, fontSize: 22.0, fontWeight: FontWeight.w600),),
          actions: <Widget>[
            
            Padding(
              padding: const EdgeInsets.only(right: 20.0),
              child: Icon(Icons.search),
              
            ),
            Padding(
              padding: const EdgeInsets.only(right: 16.0),
              child: Icon(Icons.more_vert),
            ),
          ],


      bottom: TabBar(
      tabs: [
        new Tab(icon: new Icon(Icons.chat)),
        new Tab(
          icon: new Icon(Icons.photo_library),
        ),
        new Tab(
          icon: new Icon(Icons.call),
        )
      ], indicatorColor: Colors.white,
      controller: _tabController, 
      ),
      ),
      

      body: TabBarView(      
      children: [
        Text("Chat Screen", textAlign: TextAlign.center,style: TextStyle( fontSize: 22.0, fontWeight: FontWeight.w600)),
        Text("Status Screen", textAlign: TextAlign.center,style: TextStyle( fontSize: 22.0, fontWeight: FontWeight.w600)),
        Text("Call Screen", textAlign: TextAlign.center,style: TextStyle( fontSize: 22.0, fontWeight: FontWeight.w600)),
      ],
      controller: _tabController,       

      ),

    );
  }
}
Imported IdGenerationAlgorithm
Tags: replit, java
Published: 2019-09-13 10:44:41

User Id Generation :
Joseph’s team has been assigned the task of creating user-ids for all participants of an online gaming compition. Joseph has designed a process for generating the user-id using the participator’s First_name  , Last_name  ,PIN code and a number N. The process defined by Joseph is as below-
STEP 1:-
Compare the lengths of first_Name abd Last_Name of the participant.
The one that is shorter will be called “Smaller Name “  and  the one that is longer will be calles “Longer Name”. If both first_Name and Last_name are of equal Length , then the name(assume the fullname) that appears later in alphabetical order will be called the “LongerName “.
STEP 2:
The user –id should be generated as below-
Last Letter of the smaller name +Entire word of the longer name +Digit at position N in  the PIN when traversing the PIN from left to right +Digit at position N in the PIN when traversing the PIN from right to left.
STEP 3:
Toggle the alphabets of the user-id generated in step-2 i.e upper –case alphabet should become lower-case and lower-case alphebets should become upper –case.
Lets see a few eamples;
Example 1 := if the participates detail as below
First_name=Rajiv
Last_name =Roy
PIN = 560037
STEP1 : Length of Last_Name is less than the Length of first_Name , so the smaller  Name is “Roy” and the Longer Name is “Rajiv”
Step2: The user_id will be =”Last Letter of the smaller name +Entire word in the longer name +Digit at position N in the PIN when traversing the PIN from left to right + Digit at Positin N in the PIN when traversing the PIN from right to left =Last Letter Of “Roy” +Entire word  in “Rajiv” +6th Digit of PIN from left+6th Digit iof PIN from right.
STEP 3:
Toggle the alphabets of the user-id generated in step-2 i.e upper –case alphabet should become lower-case and lower-case alphebets should become upper –case.



{% replit @VikasTomar/Id-Generation %}
Flutter Installation steps.
Tags: flutterinstall
Published: 2019-09-13 10:43:27

Steps:-
1. Download Flutter SDK :-
Link:- “https://flutter.dev/docs/get-started/install/linux”
2. Extract Flutter:-
command:- tar xf ~/Downloads/flutter_linux_v1.7.8+hotfix.4-stable.tar.xz
3. Path export for perticular terminal:-
export PATH="$PATH:`pwd`/flutter/bin"
4. Permenent Path export :-
Open bashrc file :- Go to home directory terminal -> nano ~/.bashrc
Write at end of file :-
export PATH=" [PATH_Where_Flutter SDK Extracted] /flutter/bin:$PATH"
example :-export PATH="/home/sid/0_aaa_iauro/Flutter/s/flutter/bin:$PATH"
5. Run the following command to see if there are any dependencies you need to
install to complete setup:-
command :- flutter doctor -v
6. Add Flutter extension to vs-code.
7. Locate Flutter SDK.
8. Make New project in flutter:-
command:- flutter create Project_name

» Impportant Links:-
1. https://flutter.dev/docs/get-started/install/linux
2. https://jonathanmh.com/getting-started-with-flutter-on-linux-for-android-
beginner-tutorial/
3. https://www.techomoro.com/how-to-install-and-setup-flutter-on-ubuntu-18-04-1-
lts-bionic-beaver/
4. http://flutter-tutorials.com/install-flutter-in-windows/
5. Check for path variable (bashrc file):-
https://www.tutorialkart.com/flutter/flutter-install-on-linux-ubuntu/