teleren/devto huggingface dataset:
User Roles and Permissions Tutorial in Laravel without Packages
Tags: acl, laravel, permission, roles
Published: 2019-12-14 11:26:08

Roles and permissions are an important part of many web applications. In this tutorial we will see how we can implement user roles and permissions system in laravel. We will see it from scratch. We can use spatie/laravel-permission package for doing it. But in this tutorial we will do user roles and permissions in laravel using our own custom code. So let's start how to implement & setup roles and permissions in Laravel.

https://www.codechief.org/article/user-roles-and-permissions-tutorial-in-laravel-without-packages
Laravel 6 Ajax Form Submit With jQuery Validation
Tags: laravel, form, validation, jquery
Published: 2019-12-14 11:25:14

In this tutorial i will show you how to insert data using ajax in laravel with datatables. In this tutorial we will also do form validation using ajax in laravel. We will insert our data into database without refreshing our web page. For doing it we will use Ajax request. For doing laravel ajax form submit with validation do the following steps. Let's start our laravel 6 jquery ajax insert data tutorial. Preview of this tutorial. If we click submit button before giving required data, it will show those error message.

https://www.codechief.org/article/laravel-6-ajax-form-submit-with-jquery-validation
Delete Record using Ajax Request in Laravel
Tags: laravel, ajax
Published: 2019-12-14 11:24:18

Today i will show you how to delete data ajax request in Laravel. you have to simply follow few things to make done delete record from database using ajax request.we will create delete route with controller method(we will write delete row code using database model) and write jquery ajax code with delete post request. we also pass csrf token in jquery ajax request, otherwise it will return error like delete method not allowed.

https://www.codechief.org/article/delete-record-using-ajax-request-in-laravel
Update User Status Using Toggle Button Example in Laravel
Tags: laravel, ajax, toggle
Published: 2019-12-14 11:23:25

In this tutorial i will show you how to create user active and inactive status using bootstarp toogle button.i would like to show you how to create functionality to active and inactive status in laravel 6 application.It is pretty simple and very easy. we can implement change status using ajax with bootstrap toggle button in laravel 6. here we will update user status active inactive with boolean data type with 0 and 1. you can do it this toggle stuff using jquery ajax.

In this tutorial example i will create users listing page and give bootstrap toggle button using bootstrap-toggle js. so you can easily enable and disabled it. using bootstrap-toggle js change event we will write jquery ajax code and fire get or post request to change user statue field on database.

So, let's see follow few step and get status change functionality with example, bellow also attach screen shot of layout.

https://www.codechief.org/article/update-user-status-using-toggle-button-example-in-laravel
Import and Export CSV file in Laravel
Tags: csv, import, export, laravel
Published: 2019-12-14 11:22:23

import export excel or csv from database is a primary requirement for admin project. In this tutorial i will show you how to import csv or excel file and export csv or excel file using maatwebsite/excel version 3 in laravel 6 application. In this export excel or csv from database tutoril we will simple create import data to csv, xls file and also we can import data to database using csv file in laravel 6 application.

In this tutorial we will use maatwebsite/excel composer package for import and export task. maatwebsite/excel provide easy way to import and export using database model. maatwebsite/excel updated version 3 and they provide great way to import export data from database, so first follow few step to get example.

https://www.codechief.org/article/import-and-export-csv-file-in-laravel
Laravel Auth: Login With Email Or Username In One Field
Tags: laravel, auth
Published: 2019-12-14 11:20:51

A quick amazing tip for you guys. What if in your project users can login not only with email but also with some other field, like “username” or “user_id” or whatever? By default Laravel allows only one field like ’email’. That’s actually easy to change.In this tutorial, we will see how we can login with only two fields login and password. Login can either be email or username.

Let’s imagine that you already have a field username in your users table and need to check the login form result. So there are only two input fields – login and password. And login may be either email or username. How can we check both? In this tutorial now we are going to show how a user can log in using username or password in a one field. Let's see.

https://www.codechief.org/article/laravel-auth-login-with-email-or-username-in-one-field
We are moving
Published: 2019-12-14 10:36:39

So i just realized, my account isn't linked to my github page. And as a lack of other options i decided to create a new dev.to account that links to my github repos.

You can follow me through this link https://dev.to/vvilliam5 which is where i would be most active now, and my github account https://github.com/vvilliam5 i post awesome stuffs :)
The Ultimate React Redux debugger
Tags: react, redux, beginners, tutorial
Published: 2019-12-14 10:29:59

I like me, you are also new to using Redux, you would agree with me, things can get complicated real quickly, and to make matters worse, the conventional google debugger isn't much helpful.

But i found a google chrome extension to help make your life a lot easier and make your coding more of a pleasant experience. 

The name of the debugger is Redux-devtools-extensions, below is a link to my forked version of it

https://github.com/vvilliam5/redux-devtools-extension.git

It is awesome because it has a really nice GUI that shows you all your action creators and reducers, and your store as a whole, and you can click on actions to revisit the state of your app at that particular point in time, i am still exploring it, but these are still the cool features ive discovered so far. I be sure to update on my new findings.

It works as a chrome extension, just download, import your applyMiddleware and compose objects from the redux library and add this line of code to your App component

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(reducers, composeEnhancers(applyMiddleware()));

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

And your all done :)
wc-rs: A faster port of unix wc in Rust
Tags: rust, unix, commandline
Published: 2019-12-14 10:06:58

---
title: wc-rs: A faster port of unix wc in Rust
published: true
description: 
tags: #Rust #Unix #command-line
---

Hey there. I tried to rewrite wc in Rust and compared its performance with the GNU coreutils wc and it turned out to be much more efficient. In case anyone is interested check out the benchmarks in the [README](https://github.com/palash25/wc-rs)

Install it and play around with it. I am new to Rust so if there is any room for improvement in my code kindly point it out here or raise issue. Oh and consider giving it a :star: if you like what you see.
WordPress post view count
Tags: wordpress, php, webdev
Published: 2019-12-14 09:57:42

There are lots of articles over the web regarding "WordPress post view count" and "Creating a custom column for Post table". But unfortunately, most of them are not bug-free. In this article, I'm going to cover both of them.

#### At first, let's see how to create post view count and stored as metadata.

``` php
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );

function wp_set_post_views( $postID ) {
    $count_key = 'wpb_post_views_count';
    $count = get_post_meta( $postID, $count_key, true );
    
    if( $count == '' ) {
        $count = 0;
        delete_post_meta( $postID, $count_key );
        add_post_meta( $postID, $count_key, '0' );
    } else {
        $count++;
        update_post_meta( $postID, $count_key, $count );
    }
}

function wp_get_post_views() {
    if ( is_single() ) {
        wp_set_post_views(get_the_ID());
    }
}
add_filter( 'the_content', 'wp_get_post_views' );
```


#### Now let's create a custom column for Post table and show post view counts.


``` php
function wp_posts_columns( $defaults ) {
    $defaults['wpb_post_views_count']  = esc_html__( 'Post Views', 'text_domain' );
    return $defaults;
}
add_filter( 'manage_post_posts_columns', 'wp_posts_columns' );


function wp_post_custom_column( $column_name ) {
    if ( $column_name == 'wpb_post_views_count' ) {
        $count = get_post_meta( get_the_ID(), 'wpb_post_views_count', true );
        $view_count = $count == '0' ? '1' : $count;
        echo esc_html__( $view_count, 'text_domain' );
    }
}
add_action( 'manage_post_posts_custom_column', 'wp_post_custom_column', 10, 2 );


function wp_post_column_sortable() {
    $columns['wpb_post_views_count'] = ['wpb_post_views_count', true ];
    return $columns;
}
add_filter( 'manage_edit-post_sortable_columns', 'wp_post_column_sortable' );


function wp_sortable_custom_column_query( $query ) {
    $orderby = $query->get( 'orderby' );

    if ( 'wpb_post_views_count' == $orderby ) {

        $meta_query = array(
            array(
                'key' => 'wpb_post_views_count',
                'value'   => '',
                'compare' => '>',
            ),
        );

        $query->set( 'meta_query', $meta_query );
        $query->set( 'orderby', 'meta_value' );
    }
}
add_action( 'pre_get_posts', 'wp_sortable_custom_column_query' );
```
npm Problem
Published: 2019-12-14 09:32:15

hi,i have problem in react application npm ,any one help me please:
my problem is :

F:\React\routdemo>npm i
npm ERR! code EINVAL
npm ERR! syscall mkdir
npm ERR! path F:\React\routdemo\'C:\Users\Asadn\npmrc'\_cacache\tmp
npm ERR! errno -4071
npm ERR! EINVAL: invalid argument, mkdir 'F:\React\routdemo\'C:\Users\Asadn\npmrc'\_cacache\tmp'

F:\React\routdemo>
How people think in the game of love island
Published: 2019-12-14 07:51:32

This makes people fall into contradiction in Love Island game: on the one hand, you can't help but understand the meaning of your existence; on the other hand, in modern society designed in Love Island, you need to choose all the time, but these choices have no meaning. This kind of contrast oppresses your nerves, makes you find ways to escape, makes many people abandon their old beliefs after reaching the peak of power, and turn to "think like a Love Island player"; it is also this kind of mentality that makes us dive into strategic games and make a response different from the normal. "Shouldn't we choose to run away from the dignified Love Island users? Or protest against a cannibal industrial society By acquiring another identity, human beings in Love Island game can obtain some kind of self comfort, and then get a chance to breathe. " Not only that, you will also notice that in another world, "right" can have different forms of expression, which makes us more calm about abandoning the original position. In a word, although it doesn't help the reality, it can be said responsibly that "giving up thinking like a Love Island game player" is actually the product of human's pursuit of benefits and avoidance of disadvantages. After all, in the virtual Love Island gaming world, doing so can make your every move full of meaning, and then get some simple satisfaction(especially using [Love Island The Game cheats](http://loveislandcheat.club/)): not only that, but also the rules are very easy to master, which give us different from the reality Heart feeling. In the same way, politicians who give up principles must have similar impulses - all out of frustration with reality, all for personal satisfaction, although the final result may be that they will become more severe and callous in their attitude towards the public.
How do I make react app bundled in electron see the images
Tags: react, electron
Published: 2019-12-14 07:50:13

---
title: How do I make react app bundled in electron see the images
published: true
description: Not all images shows on navigation by react router, but only on first app load
tags: react, electron
---

I build a react app which is currently hosted on evagiantgroups.com; and works as expected. Then, I bundled in in electron, but it only works fine on first load (i.e, before react router actions is set in; any clicks on any link). Once I navigate the app, some images won't show again, just like in the photos.

I tried debug and found out the below:

 - on first load:
file:///C:/Users/MY_PC_NAME/AppData/Local/Programs/app-evagiantgroup/resources/app.asar/build/static/media/thumb_d2.db671513.png

 - on reload or navigation:
file:///C:/static/media/thumb_d2.db671513.png

Please kindly help. Thank you.
Flutter 1.12 some of the cool features
Tags: flutter
Published: 2019-12-14 07:49:08

Flutter 1.12 some of the cool features that have introduced on #FlutterInteract

1. Flutter 1.12

This new release brings some cool features.

iOS 13 Dark mode available | Cupertino app now support with dark mode.

AndroidX included | All flutter projects are now AndroidX supported so you don’t need to worry about.

Add-to-App support | With Android Studio you can add fully Flutter module/screen/feature in your Android and iOS apps.

Google Fonts Support | Now you can use google fonts in a flutter, the new package is published with amazing font reload like hot relead capability.

Flutter Galley | The app is updated with new widgets so you can have a look at the codebase.

2. Flutter for Web

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/2coszjppmrdfdv7wjpq3.jpeg)

Flutter for the web is now in beta, which means it’s ready to forget your hands dirty. Page routing, native text controls, and mobile accessibility are new features and many cool plugins.

3. Flutter for Desktop

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

Flutter For Desktop is now in alpha for macOS. Flutter Gallery app also has Desktop support. Plus there are a lot of improvements for keyboard accessibility and more

4. Supernova

The WYSIWYG editor is here for a flutter, supernova now supports flutter, you can use your sketch of adobe xd file to generate flutter widgets.
And the awesome part is you can link your project with supernova then you can see your code changing in IDE as well as Hot Reload on emulator while you are editing UI in a supernova. Cool Yeah!

5. Rive

Rive previously know as flare making animations in flutter more powerful and added support for features like drop shadows, glows, blurs and masks to make your animations stand out. Also, you can import your adobe after effect files thanks to Lottie support.

6. Adobe XD

With Flutter Plugin for adobe xs, you can directly export your UI to DartCode plus it supports hot reload, cool year! mean when you change anything in XD the changes will take effect in your emulator in real-time.

7. Dartpad.dev

Dartpad.dev allows you to write and run pure dart, web and Flutter app directly in the browser. You don’t need to download flutter SDK, setup IDE and setup emulator, it’s all in your browser.

8. Android Studio Tools

With Hot UI tool for Android Studio, we can preview our Flutter app UI directly from Android Studio IDE, you can make changes on Hot UI and see those changes via Hot Reload without touching the code.

Check out more details about [Flutter 1.12 latest Announcement](https://medium.com/ionicfirebaseapp/flutter-the-first-ui-platform-designed-for-ambient-computing-860c5258c40c)

Check out what is the new document released on Flutter: https://flutter.dev/docs#whats-new-on-this-site

##Flutter Docs:

Official Site: [Flutter.dev](https://flutter.dev/)
Dart: [Pub.dev](https://pub.dev/)
Online Flutter and Dart compiler: [Dartpad.dev](https://dartpad.dev/)
Flutter Open-Source App & Libraries collections: [Flutterappworld.com](https://flutterappworld.com/)
Add custom operators to typeorm
Tags: node, typescript, orm, typeorm
Published: 2019-12-14 07:43:39

---
title: Add custom operators to typeorm
published: true
cover_image: https://raw.githubusercontent.com/typeorm/typeorm/master/resources/logo_big.png 
tags: nodejs,typescript,orm,typeorm
---

TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8). Its goal is to always support the latest JavaScript features and provide additional features that help you to develop any kind of application that uses databases - from small applications with a few tables to large scale enterprise applications with multiple databases.

TypeORM supports both Active Record and Data Mapper patterns, unlike all other JavaScript ORMs currently in existence, which means you can write high quality, loosely coupled, scalable, maintainable applications the most productive way.

TypeORM is highly influenced by other ORMs, such as Hibernate, Doctrine and Entity Framework.

While the framework gives you many features out of the box, it also gives you the ability to make custom operators which it might be lacking for repository . One of the operators that I use but didn't find in typeorm was ILike operator. For those who don't know what ILike operator doesn in sql is the same thing as Like operator but is case insensitive.

To make a new operator in typeorm for repository pattern is pretty straight forward,

```ts
import { Connection, FindOperator, FindOperatorType } from 'typeorm';

class FindOperatorWithExtras<T> extends FindOperator<T> {
  constructor(
    type: FindOperatorType | 'ilike',
    value: FindOperator<T> | T,
    useParameter?: boolean,
    multipleParameters?: boolean,
  ) {
    // @ts-ignore
    super(type, value, useParameter, multipleParameters);
  }

  public toSql(
    connection: Connection,
    aliasPath: string,
    parameters: string[],
  ): string {
    // @ts-ignore
    if (this._type === 'ilike') {
      return `${aliasPath} ILIKE ${parameters[0]}`;
    }

    return super.toSql(connection, aliasPath, parameters);
  }
}

/**
 * Find Options Operator.
 * Example: { someField: Like("%some string%") }
 */
export function ILike<T>(
  value: T | FindOperator<T>,
): FindOperatorWithExtras<T> {
  return new FindOperatorWithExtras('ilike', value);
}


``` 

In the example above, we are making ILike operator which is not available in typeorm by default. 


Follow me on Github: https://github.com/rubiin
Advent of Code 2019 Solution Megathread - Day 14: Space Stoichiometry
Tags: adventofcode, challenge, adventofcode2019, spoilers
Published: 2019-12-14 07:42:16

---
title: Advent of Code 2019 Solution Megathread - Day 14: Space Stoichiometry
published: True
description: The horrors of chemistry class, but in pog form!
tags: adventofcode,challenge, adventofcode2019, spoilers
series: Advent of Code 2019 Solutions
cover_image: https://i.imgur.com/46heG17.png
---

Who says we can't play god? Well, a god is probably better at combinatorics than I am.

### [Day 14 - The Problem](https://adventofcode.com/2019/day/14)
Bad news, folks. We're running out of fuel. The good news is that we're right next to a big source of ORE.

Part 1 has us trying to assemble fuel with our amazing elemental recombinator.

Part 2: will be described when I get there.

### Ongoing Meta

#### Dev.to List of Leaderboards

* `120635-5c140b9a` - provided by [Linda Thompson](https://dev.to/lindakatcodes) 

 If you were part of [Ryan Palo](https://dev.to/rpalo)'s leaderboard last year, you're still a member of that! 

If you want me to add your leaderboard code to this page, reply to one of these posts and/or send me a DM containing your  code and any theming or notes you’d like me to add. (You can find your private leaderboard code on your "[Private Leaderboard](https://adventofcode.com/2019/leaderboard/private)" page.)

I'll edit in any leaderboards that people want to post, along with any description for the kinds of people you want to have on it. (My leaderboard is being used as my office's leaderboard.) And if I get something wrong, please call me out or message me and I’ll fix it ASAP.

There's no limit to the number of leaderboards you can join, so there's no problem belonging to a "Beginner" *and* a language specific one if you want.

#### Neat Statistics

I'm planning on adding some statistics, but other than "what languages did we see yesterday" does anyone have any ideas?

##### Languages Seen On Day 12

> Under construction
Day 14 of the Visual Studio Tips Advent Calendar is now live
Tags: visualstudio
Published: 2019-12-14 07:26:45

Day 14 of the Visual Studio Tips Advent Calendar is now live. Enjoy! 

Included is a shout out to my Mum as it's her birthday today.

https://visualstudiotips.co.uk/calendar/

#VisualStudio #DevDecember #VsTipsAdvent #Advent
Basic Usage of Cache in Laravel
Tags: laravel, cache
Published: 2019-12-14 07:23:07

In this tutorial we're going to look at the basic usage of the Laravel cache. The use of Laravel cache , its makes our site more faster than only use of query builder. In this tutorial we will see how we can implement laravel cache mechanism in our application. 

Laravel makes it easy for us to switch out how we want caching to be generated. It is extremely easy for us to switch out the drivers. Just check out config/cache.php to see the available drivers which are. In this lecture we will use redis to complete our laravel cache example. For this you have to setup redis in your environment. 

https://codechief.org/article/basic-usage-of-cache-in-laravel
Form Validation with File Upload in Laravel 6
Tags: laravel, form, validation, fileupload
Published: 2019-12-14 07:21:59

How to upload file in Laravel 6: Today, i will show you how to create simple file upload in laravel 6. I write article step by step about image upload in laravel. I also added validation with image upload in laravel. So doing it you can download a fresh laravel file or you can do it in your current running project.

Example of file upload in laravel, we will create two routes one for get method and another for post method. we created simple form with file input. So you have to simple select image and then it will upload in "images" directory of public folder. So you have to simple follow bellow step and get image upload in laravel 6 application.

https://codechief.org/article/form-validation-with-file-upload-in-laravel-6
Laravel 6 : Activate Account after Email Verification using Laravel mail
Tags: auth, email, laravel, verifyemail
Published: 2019-12-14 07:19:41

Activate account after email verification:Many web applications require users to verify their email addresses before using the application. Rather than forcing you to re-implement this on each application, Laravel provides convenient methods for sending and verifying email verification requests. But here i am going to customize this basic default auth mechanism.

Laravel provides the Basic Authentication out of the box which includes the basic login, registration, and password reset functionalities. These functionalities can be easily customized. This is the beauty of Laravel framework. In this tutorial we are going to customize the basic registration functionality of the Laravel and acount activation functionality after user registration.

https://codechief.org/article/laravel-6-activate-account-after-email-verification-using-laravel-mail