teleren/devto huggingface dataset:
Subdomain Routing and Namespace Prefixes in Laravel
Tags: laravel, beginners, excerpts
Published: 2020-04-28 12:52:51

_Excerpts from the book Laravel Up and Running by Matt Stauffer_


Subdomain routing is like route prefixing yet with scope only within the subdomain.

*Two primary uses of subdomain routing*
- Present different section of the application to different subdomain
- Set part of the subdomain as parameter

Eg.
`Route::group(['domain'=>'api.myapp.com'],function(){
Route::get('/',function(){
//
});
});`

`Route::group('domain'=>{account}.myapp.com'],function(){
Route::get('/',function($account){
//
});
Route::get('users/{id}'function($account,id){
//
});
});`

The subdomain here is parameterized and *will be passed as the first parameter to every grouped routes*

**Namespace Prefixes**
Grouping routes by subdomain mean their controller may have similar PHP namespace.
Eg. for different APIs the namespace can be `App\Http\Controllers\API\ControllerA`
and for different subdomains, the namespace can be `App\Http\Contollers\account\ControllerB` etc.

These long controller references can be avoided with namespace prefixes

Eg.
__//App\Http\Controllers\ControllerA
`Route::get('/','ControllerA@index');`

`Route::group(['namespace'=>'API'],function(){
//App\Http\Controllers\API\ControllerB
`Route::get('api/','ControllerB@index');
});`

**Name Prefix**
Prefix can also be used for route groups. Route group name prefixes help define that every route within this group should have a given string prefixed to its name.
Ex.
`Route::group(['as'=>'users.,'prefix'=>'users'],function(){
ROute::group(['as'=>'comments.,'prefix'=>'comments'],function(){
//Route name will be users.comments.show
Route::get('{id}',function(){
//do something 
}}->name('show');
});
});`
Inflating views and passing variable in Laravel
Published: 2020-04-28 12:48:04

_Excerpts from the book Laravel Up and Running by Matt Stauffer_


**View Formats**
There are two formats of views in Laravel right out of the box:
__example.blade.php__
__example.php__

The first one is rendered by the Blade engine, while the latter is rendered by the PHP engine. They both reside in `resources/views/`.

**View Loading Mechanism**
Three ways to load view;
-view()
-View::make()
-Injecting with Illuminate\View\ViewFactory

Simple View Usage:

`Route::get('/,function(){
return view('home');
});`


**Passing variable to view**
`Route::get('work',function(){
return view('tasks.index')
->with('tasks',Task::all());
});`

The above closure loads the `resources/views/tasks/index.blade.php` or `resources/views/tasks/index.php` view and passes a single variable name `tasks` with the result of the result of the `Task::all()` eloquent method.

**Using View Composers to share variables with every view**
`view()->share('view_variable','view_value');`
React Native libraries for 2020
Tags: react, javascript, beginners, webdev
Published: 2020-04-28 12:46:35

React native is an open-source mobile application framework created by Facebook. It is used to develop applications for Android, iOS, Web & UWP by enabling developers to use React along with native platform capabilities.

Here are some React Native component libraries that will help you while developing React based applications.

https://avocode.com/nachos-ui
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gqd2idy31bvqdjw00cqz.png)

https://oblador.github.io/react-native-vector-icons/
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/az4tj0gcikc2z5nq2z53.png)

https://nativebase.io/ 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4wdirjyz69y2saaqrzfn.png)

https://github.com/FaridSafi/react-native-gifted-chat
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/i5mhg8o0yajyk0297x6w.png)

https://akveo.github.io/react-native-ui-kitten/
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/luf4dhj61h0lsb41ckun.png)

https://shoutem.github.io/ui/
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/a2nbo42v0sxokxgc9e96.png)
What is a preferred way to communicate Python (can be short-lived) and Node.js server (long running)
Tags: discuss, node, python, javascript
Published: 2020-04-28 12:38:35

I know there are multiple ways.

- Python/CLI script, and pipe stdin/stdout (which might be able to make long running as well.)
- ZeroMQ
- Full blown web server (HTTP) Falcon looks nice.

I might have to fear about startup time of Python scripts as well.

What I want,

- [MeCab](https://pypi.org/project/mecab-python3/)
- [Jieba](https://pypi.org/project/jieba/). I know there is nodejieba, but I am not sure about performance...

Actually, I have tried MeCab directly (in Docker), but there is a little complication.

```js
const { spawn } = require('child_process')

async function main () {
  const p = spawn('mecab')

  p.stdout.on('data', (data) => {
    const s = data.toString().split('\n').map(row => row.split('\t')[0])
    console.log(s)
  })

  p.stdin.write('日本語です')
  p.stdin.write('\n')
  await new Promise(resolve => p.stdout.once('data', resolve))
  p.stdin.write('すもももももももものうち')
  p.stdin.end()
}

main()
```
Những mẫu thiết kế kiến trúc ngôi nhà đẹp giá rẻ
Published: 2020-04-28 12:36:46

Những mẫu thiết kế kiến trúc ngôi nhà đẹp giá rẻ và hiện đại nhất hiện nay. Nội Thất Triệu Gia chuyên thiết kế nhà, thiết kế nội thất theo yêu cầu tạo sự độc đáo, mới lạ cho không gian của bạn
https://noithattrieugia.vn/thiet-ke-nha.html
Learning new things on the fly for the Hackthon
Tags: twiliohackathon, wecoded
Published: 2020-04-28 12:31:12

Good morning!

As I mentioned before, I decided to participate in the Hackthon Dev is doing with Twilio but started a bit to late. 
With my Brothers help I decided what I was going to do, and on Sunday the 26th, I made the webpage for the project.
I decided to go real simple there, because I don't have much time and I have lots to learn.

My project will use Twilio SMS services so I am studying about that, as well as learning some nodeJS for the back end. I confess at times I feel overwhelmed, confused and not sure I can finish it. But I refuse to give up!!! I want I new Dev badge for my profile lol

I have a little less than 3 days to learn all I need and finish the project.
I problem will delivery something real simple but done is better than nothing right?

My hopes are to end this Hackthon with some new tools, a new project for my portfolio and even some back-end experience. In my books I just have to delivery and I am already a winner!!!


Good luck to everyone else participating.
And to everyone else, You can do it! Whatever you are doing, I bet you can finish it!!!

XOXO,
pachi
Roadblocks and a Big Mindset Shift x Twilio Hackathon Project Update
Tags: devjournal, twiliohackathon, codenewbie, womenintech
Published: 2020-04-28 12:29:00

_This post was originally published on April 28, 2020 on [my blog](https://alexlsalt.github.io/blog)._

Okay. So I'm definitely facing a depletion in motivation from before. I spent a large part of the yesterday hung up and going around and around in circles on how to implement a Twilio API into my wellbean app to gather information from the database itself.

Now, after coming up against so many dead ends, I'm wondering if I should just hook up the API in a very basic 'Welcome, here are instructions for getting started with wellbean...' way.

Luckily, I have a virtual meetup tonight where I'm going to work on the app and hopefully talk through this roadblock with other coding ladies.

The thing is, though - as much as I want to submit this project to the hackathon with the full Twilio functionality, I *also* need to stay aware of the fact that even if I don't end up submitting it, I still have an absolutely epic project I've built up from scratch!

I learned and set up Firebase! I learned how to set up user accounts and databases! I finally learned how to use CSS Grid! Seriously, that's already more than amazing!

My plan for today is to spend some time learning about setting up Firebase Rules for data privacy and then implementing that into my app.

I may also work on a color/time function for wellbean to keep track of who needs to be contacted based on how much time has passed. I started in on it yesterday, but it needs a little bit more tinkering around :)
NodeJS - Connected account is required to transfer money from stripe account to another stripe account?
Tags: node, stripe, payments
Published: 2020-04-28 12:09:19

This is my use case:

First, the user pay 100$ with react-stripe-checkout https://www.npmjs.com/package/react-stripe-checkout


I handle the logic on NodeJS server:

So! i want like this:

1- Create a charge (100$) to primary account stripe (A).

`await stripe.charges.create({
 amount: 100000, currency: 'USD', source: args.token, 
});
`
Then i want to create a transfer of $30 to another stripe account 

`await stripe.paymentIntents.create({ 
payment_method_types: ['card'], amount: 3000, currency: 'USD', }, { stripe_account: 'acct_xxx ', 
});
`

or 

` await stripe.transfers.create({
        amount: 3000,
        currency: 'USD',
        destination: 'acct_XXX',
        transfer_group: 'ORDER_95',
      });
`
Like this is correct or is required activate the Connected account and i have to pay for that ?

So i have a **error: No such account: acct_xxx ** 

What is the best way to achieve it?
Daily Developer Jokes - Tuesday, Apr 28, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-04-28 12:00:19

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

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

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

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

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

<!-- 
Joke text:
___Q:___ What accommodations did the JavaScript developer request at the hotel?

___A:___ A room with a Vue.
 -->
Did you move your real-life meetups online?
Tags: discuss, community, motivation, remote
Published: 2020-04-28 11:43:06

In previous life when hugging each other was a viable option we used to have developer community meetups around topics that we cared about. Often hosted at company offices or sometimes in bars. Remember those, huh? Did you org one? Did you host one?

### Did you move your real-life community meetups online?
I am asking because I did, and it has many pros and cons. The online version of a real-life meetup has a single extra word in the naming, but essentially only remotely resembles the real-life meetups we loved to attend.

* So what's your experience? 
* Did you move your real-life meetups online?
* Are you thinking about doing so?

I could probably take time to write down a kind of a guide, share my experience. But is it a problem that you people are looking for a solution to?
What are the things you found difficult while working with ReactJs ?
Tags: discuss, react, javascript
Published: 2020-04-28 11:37:49

---
title: What are the things you found difficult while working with ReactJs ?
published: true
tags: discuss, reactjs, react,javascript
---
Context - Like getting a job with React. Writing React Code. OSS solutions in React. Experience with the community. Available resources. Working as a Team with React codebase. 

For me - Not learning Redux prevented me from lot of jobs. I had a difficult time learning Redux.
HTML string to DOM
Tags: html, dom, customElement
Published: 2020-04-28 11:34:33

Awesome little snippet **toDom** from [William Malo](https://stackoverflow.com/users/1145932/)

```js
String.prototype.toDOM = function () {
    var d = document,
        i, a = d.createElement("div"),
        b = d.createDocumentFragment()
    a.innerHTML = this
    while (i = a.firstChild) b.appendChild(i)
    return b
}

const mail = (name) => `Hello ${name}`

const mailToHal = mail("Hal").toDOM()

document.body.append(mailToHal)
```
You can test it here : [toDom](https://flems.io/#0=N4IgZglgNgpgziAXAbVAOwIYFsZJAOgAsAXLKEAGhAGMB7NYmBvEAXwvW10QICsEqdBk2J4AysQBOENAHN8AB0m1iKgJ4KY+VQBEA8gFkAvGACuaasQj0AFAEpgAHTQACFwDcMklwBMjP2mpTHAYKCGc3SIoMf3xqSRgMRgBRWBDiG0cQHwh3LLsIyJcKACNY+MTGHUDgkQAxSQxZdPtCjHwZNBhJAAkAFQMAGRcjF2JCCDhCgHcJ2BsII3bISThiAGE5nzsS-AwFTTQfTegfBYLXFwTiU0lXEudWZ2chNZcsDGgRlxtMHDsRgA+FwAAx6MCgUFoLgAJMA-jBWCDnhZ6G8PtA+rQehgoG5RhioJkQDioPltLR9AZWmhnAEgul8CVaD41HsDkwzoSsaS7JQQHAITBLNY0AgeABGADMiClErYHBACLwcTgAho9EYzB4bAAulRlTxdLQsGwgA)
L is for Laravel; Routes
Tags: laravel, beginners, excerpts
Published: 2020-04-28 11:23:40

_Excerpts from the book Laravel Up and Running by Matt Stauffer_



**Route naming convention**

`resourcePlural.action`

Eg.
photos.index
photos.create
photos.edit

**Route groups**

Route groups allow grouping several routes together, and apply shared configuration settings

_Defining a route group_

`Route::group([],function(){
Route::get('hello',function){
return 'hello';
});
Route::get('world',function(){
return 'world';
});
});`

Though there is no difference in separating the routes in above group, the square brackets passed as first parameter allows to pass in various configuration that can be applied to the entire route group!

_Note: The function passed in as second parameter above is called closure; Laravel's implementation of anonymous function._

Another use of *Route Group* is the use of Middlewares. 
Ex. Restricting a group of routes to logged-in users only

`Route::group(['middleware'=>'auth'],function(){
Route::get('dashboard',function(){
return view('dashboard');
});
Route::get('account',function(){
return view('account');
});
});`

What above code does is users need to be logged in to the application to view the dashboard or the account page.

Instead of *attaching* middlewares to the *routes definition*,it is better to attach directly to the controllers.

String that is passed in the middleware() method is the middleware, which can me chained with *modifier methods* only() and except() to define *which method will receive the middleware*

Eg.
`class DashboardController extends Controller
{
public function __construct() //constructor method
{
$this->middleware('auth');
$this->middleware('admin-auth')->only('admin'); //or ->except('admin');
}
}`

**Path Prefixes**
Route groups can also be used to simplify path prefixes.
Eg. if the site's api is prefixed with /api:
`Route::group(['prefix'=>'api'],function(){
Route::get('/',function(){
//Handles the path /api
});
Route::get('users',function(){
//Handles the path /api/users
});
});`

_Note: /api represents the root of the prefixed group in above example_
The Revealing Module Pattern in JavaScript
Tags: javascript, tutorials, designpatterns, webdev
Published: 2020-04-28 11:06:05

---
title: The Revealing Module Pattern in JavaScript
published: true
description: Use the revealing module pattern in JavaScript to maintain private information using closures while exposing only what you need.
tags: javascript, tutorials, design patterns, webdev
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/7dzdi7cr12vb5u8aa6kw.png
canonical_url: https://typeofnan.dev/the-revealing-module-pattern-in-javascript/
---

You can use the revealing module pattern in JavaScript to maintain private information using closures while exposing only what you need.

# The Problem

Let's consider the following example where we create the object `clarkKent`.

```javascript
const clarkKent = {
  name: 'Clark Kent',
  secretIdentity: 'Superman',
  introduce: function() {
    return `Hi, my name is ${this.name}.`;
  },
  issuesReport: function() {
    return `${this.secretIdentity} saves the day!`;
  },
};
```

Using this example, Clark can introduce himself and can report that Superman saved the day:

```javascript
console.log(clarkKent.introduce());
// Hi, my name is Clark Kent.
console.log(clarkKent.issuesReport());
// Superman saves the day!
```

This is great, but, oh no! We have access to Clark's secret identity!

```javascript
console.log(clarkKent.secretIdentity);
// Superman
```

# The Revealing Module Pattern to the Rescue

One way we can get around this issue is by using the _revealing module_ pattern. The revealing module pattern uses an Immediately Invoked Function Expression (IIFE) to create closure around variables we want access to within the module but don't want to expose to the world.

Let's see how this works out for Clark.

```javascript
const clarkKent = (function() {
  const name = 'Clark Kent';
  const secretIdentity = 'Superman';
  const introduce = function() {
    return `Hi, my name is ${name}`;
  };
  const issuesReport = function() {
    return `${secretIdentity} saves the day!`;
  };

  return { introduce, issuesReport };
})();

console.log(clarkKent.introduce());
// Hi, my name is Clark Kent.
console.log(clarkKent.issuesReport());
// Superman saves the day!
console.log(clarkKent.secretIdentity);
// undefined
```

Perfect! We've created a closure around the secret information we don't want to expose and only revealed the `introduce` and `issuesReport` methods from our module!

# Conclusion

While this is a bit of a silly example, it's important to note that we have tools and patterns at our exposure to maintain privacy and, importantly, not expose imformation beyond where it's really needed.
File Navigation in Vim — LSP, CTags, References, Definitions, and more.
Tags: vim, programming, productivity, tools
Published: 2020-04-28 10:59:50


I created a screencast detailing various workflows for navigating between files using a well-equipped modern Vim setup on my primary development machine. 

What's demonstrated works (at the very least) for development in JavaScript, Ruby, and Python 

https://www.semicolonandsons.com/episode/Fluent-File-Navigation
Free Programming Books (Updated)
Tags: python, javascript, html, css
Published: 2020-04-28 10:57:55

➕All Technical Languages PDF A to Z‼️ For Free!!

1- Algorithms book

https://books.goalkicker.com/AlgorithmsBook/

2- Android book

https://books.goalkicker.com/AndroidBook/

3- Angular 2 book

https://books.goalkicker.com/Angular2Book/

4- Angular JS book

https://books.goalkicker.com/AngularJSBook/

5- Bash book

https://books.goalkicker.com/BashBook/

6- C book

https://books.goalkicker.com/CBook/

7- C++ book

https://books.goalkicker.com/CPlusPlusBook/

8- C# book

https://books.goalkicker.com/CSharpBook/

9- CSS book

https://books.goalkicker.com/CSSBook/

10- Entity Framework book

https://books.goalkicker.com/EntityFrameworkBook/

11- Excel VBA book

https://books.goalkicker.com/ExcelVBABook/

12- Git book

https://books.goalkicker.com/GitBook/

13- Haskell book

https://books.goalkicker.com/HaskellBook/

14- Hibernate book

https://books.goalkicker.com/HibernateBook/

15- HTML5 book

https://books.goalkicker.com/HTML5Book/

16- HTML5 Canvas book

https://books.goalkicker.com/HTML5CanvasBook/

17- iOS book

https://books.goalkicker.com/iOSBook/

18- Java book

https://books.goalkicker.com/JavaBook/

19- JavaScript book

https://books.goalkicker.com/JavaScriptBook/

20- jQuery book

https://books.goalkicker.com/jQueryBook/

21- Kotlin book

https://books.goalkicker.com/KotlinBook/

22- LaTex book

https://books.goalkicker.com/LaTeXBook/

23- Linux book

https://books.goalkicker.com/LinuxBook/

24- MATLAB book

https://books.goalkicker.com/MATLABBook/

25- Microsoft SQL Server book

https://books.goalkicker.com/MicrosoftSQLServerBook/

26- MongoDB book

https://books.goalkicker.com/MongoDBBook/

27- MySQL book

https://books.goalkicker.com/MySQLBook/

28- .NET Framework book

https://books.goalkicker.com/DotNETFrameworkBook/

29- NodeJS book

https://books.goalkicker.com/NodeJSBook/

30- Objective-C book

https://books.goalkicker.com/ObjectiveCBook/

31- Oracle Database book

https://books.goalkicker.com/OracleDatabaseBook/

32- Perl book

https://books.goalkicker.com/PerlBook/

33- PHP book

https://books.goalkicker.com/PHPBook/

34- PostgreSQL book

https://books.goalkicker.com/PostgreSQLBook/

35- PowerShell book

https://books.goalkicker.com/PowerShellBook/

36- Python book

https://books.goalkicker.com/PythonBook/

37- R book

https://books.goalkicker.com/RBook/

38- ReactJS book

https://books.goalkicker.com/ReactJSBook/

39- React Native book

https://books.goalkicker.com/ReactNativeBook/

40- Ruby book

https://books.goalkicker.com/RubyBook/

41- Ruby on Rails book

https://books.goalkicker.com/RubyOnRailsBook/

42- Spring Framework book

https://books.goalkicker.com/SpringFrameworkBook/

43- SQL book

https://books.goalkicker.com/SQLBook/

44- Swift book

https://books.goalkicker.com/SwiftBook/

45- TypeScript book

https://books.goalkicker.com/TypeScriptBook2/

46- VBA book

https://books.goalkicker.com/VBABook/

47- Visual Basic .Net book

https://books.goalkicker.com/VisualBasic_NETBook/

48- Xamarin.Forms book

https://books.goalkicker.com/XamarinFormsBook/
Type thinking P1 - Types 
Tags: typescript, haskell, rust, functional
Published: 2020-04-28 10:54:52

Types addiction.. no "taxes" or bulshit ;)

Prologue: This post is the 1st of a series of short posts on comparing type exists in Haskell to their Typescript & Rust equivalents. 
For the past few months I've been on/off learning Rust and Haskell and that's an excuse to practice while wondering some fun theoretical stuff..

What are types?
Type Theory? 
What's HKT (Higher kind types) - typing types ?

#Types as explained by the Haskell perspective:

Instead of pasting the wikipedia explanation of a type system, let's review the Haskell like explanation from learnyouhaskell: 

" A type is a kind of label that every expression has. It tells us in which category of things that expression fits. The expression True is a boolean, "hello" is a string, etc. "

#Type Theory 

My guess is that I'm NOT gonna be an expert in Category, Types or Sets theories, but learning in high level and slowly deeping the knowledge is a good thing… and grasping types is an integral part of our logic.

I recently discovered nLab (kind of a wiki for our topic but not exactly..) for future digging in theories, follows is the nLab definition of type theory:
 
" Explicitly, type theory is a formal language, essentially a set of rules for rewriting certain strings of symbols, that describes the introduction of types and their terms, and computations with these, in a sensible way."


#HKT - higher kinded types

Let's start demystifying the big words…
- A *kind* is the type of a type constructor.
- A *type constructor* is a feature of a typed formal language that builds new types from old ones.

Higher Kinded Types are types who take types and construct a new type of them.
In Haskell the kind of Maybe is * -> *.

We don't have HKT on Typescript (not sure we need another abstraction, TS transpiled to JS anyway and it's not statically typed, it's gradually typed meaning we can still have untyped variable by using "any"..)
 
My first thought of HKT was: "we have Generics" but that's wrong cause *Generics* let us describe data types (values) and a Generic cannot use another Generic.
 
```typescript
interface TypeA<T> {
  foo: T
}

// I want to describe a type that is of Type A or null
// type maybe_A = TypeA<*> | null; // I can't

type maybe_any_A = TypeA<any> | null; // I can do that but I guess the point of HKT will be lost

type maybeA = <T>(t: T) => TypeA<T> | null; // now the type of maybe A is a function that maybe returns A
```

Feel free to feedback if you think I've got that wrong :)

References:

 Bartosz Milewski Category Theory series
 Dr. Erik Meijer - Functional Programming Fundamentals (C9)
 https://ncatlab.org/nlab/show/type+theory
https://gist.github.com/gcanti/2b455c5008c2e1674ab3e8d5790cdad5


Cheers,
Liron.