teleren/devto huggingface dataset:
Remove/Hide Columns While Export Data In Datatable
Tags: jquery, datatable, export, hide
Published: 2021-12-03 03:08:00

In this tutorial we will see how to remove/hide columns while export data datatable in laravel. When we are using jquery datatable for displaying data in datatable and export datatabel information into PDF, Excel or CSV we might be exclude or hide some columns. So, here I will give you demo how to remove or hide columns when exporting data when using jquery laravel.

In this example the copy button will copy data of column index 2 and all visible columns, the Excel button will export only the visible columns and the PDF button will export column indexes 2, 4 and 6.

---

> **_[Read Also : How To Create Custom Middleware In Laravel](https://techsolutionstuff.com/post/how-to-create-custom-middleware-in-laravel)_**

--- 

So, let's see remove hide columns export data datatable using exportoptions jquery.

Column visibility controls are also included so you can change the columns easily and see the effect of the export options.

```
$(document).ready(function() {
    $('#demo').DataTable( {
        dom: 'Bfrtip',
        buttons: [
            {
                extend: 'copyHtml5',
                exportOptions: {
                    columns: [ 2, ':visible' ]
                }
            },
            {
                extend: 'excelHtml5',
                exportOptions: {
                    columns: ':visible'
                }
            },
            {
                extend: 'pdfHtml5',
                exportOptions: {
                    columns: [ 2, 4, 6 ]
                }
            },
            'colvis'
        ]
    } );
} );
```
 

You might also like :

- **_[Read Also : Line Breaks in Laravel Blade](https://techsolutionstuff.com/post/line-breaks-in-laravel-blade)_**

- **_[Read Also : How To Convert PHP Array To JSON Object](https://techsolutionstuff.com/post/how-to-convert-php-array-to-json-object)_**

- **_[Read Also : Crop Image Before Upload Using Croppie Plugin](https://techsolutionstuff.com/post/crop-image-before-upload-using-croppie-plugin)_**
To improve your technical skills, become a concept collector!

Tags: beginners, codenewbie, webdev, javascript
Published: 2021-12-03 03:07:44


One of the best pieces of engineering advice my dad ever gave me was: "𝐅𝐨𝐜𝐮𝐬 𝐨𝐧 𝐭𝐡𝐞 𝐜𝐨𝐧𝐜𝐞𝐩𝐭𝐬 𝐚𝐧𝐝 𝐛𝐞𝐜𝐨𝐦𝐞 𝐚 𝐜𝐨𝐧𝐜𝐞𝐩𝐭 𝐜𝐨𝐥𝐥𝐞𝐜𝐭𝐨𝐫. 𝐈𝐟 𝐲𝐨𝐮 𝐥𝐞𝐚𝐫𝐧 𝐡𝐨𝐰 𝐭𝐨 𝐫𝐞𝐚𝐝 𝐚 𝐦𝐚𝐩, 𝐞𝐯𝐞𝐧 𝐰𝐡𝐞𝐧 𝐭𝐡𝐞 𝐜𝐢𝐭𝐢𝐞𝐬 𝐜𝐡𝐚𝐧𝐠𝐞 𝐲𝐨𝐮 𝐜𝐚𝐧 𝐬𝐭𝐢𝐥𝐥 𝐟𝐢𝐧𝐝 𝐲𝐨𝐮𝐫 𝐰𝐚𝐲".


I love this so much because it's easy to get overwhelmed in tech with all the coding languages and tools available to us. But when you think of yourself as a concept-collector you can start to identify patterns in the things you're learning.


For example, I noticed that no matter what framework I use, web development is essentially made up of these building blocks:

🌄 Views -> What's being displayed to the user

🎢 Events -> The different things that a user 'causes to happen'

🚨 Event Handling -> What we do after the user causes things to happen

🗳 Storage -> Data/information needs to be stored and retrieved

🚏 Routing and Controllers -> Allows us to create conceptual locations for where data/information should live

⚒ Optimization -> Making things run as smoothly as possible


In other words:

- The user needs to see something
- The user needs to interact with what they see and make things happen
- When they cause something to happen I need to decide what occurs next
- My data needs to be stored somewhere, and I need to be able to access it
- I use routes to allow the user to access data kept in different locations
- I optimize to make things run smoother

When you learn something new, try to grasp the deeper meaning of what's being done. 𝘊𝘰𝘥𝘪𝘯𝘨 𝘭𝘢𝘯𝘨𝘶𝘢𝘨𝘦𝘴 𝘢𝘯𝘥 𝘴𝘺𝘯𝘵𝘢𝘹𝘦𝘴 𝘢𝘳𝘦 𝘰𝘯𝘭𝘺 𝘢 𝘮𝘦𝘢𝘯𝘴 𝘵𝘰 𝘢𝘯 𝘦𝘯𝘥, 𝘢 𝘸𝘢𝘺 𝘵𝘰 𝘢𝘤𝘤𝘰𝘮𝘱𝘭𝘪𝘴𝘩 𝘢 𝘱𝘶𝘳𝘱𝘰𝘴𝘦. If you notice these patterns you'll be able to switch between frameworks and languages much more easily and confidently!

---

If you liked this blog post feel free to check out more of my tech content on [Instagram](https://www.instagram.com/brinascode/), [YouTube](https://www.youtube.com/channel/UCYrIYDWuz0LZbIuOazb-5FQ) and [Twitter](https://twitter.com/brinascode) and [TikTok](https://www.tiktok.com/@brinascode)!
Enum in Go ?
Tags: go
Published: 2021-12-03 02:52:00


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rmm4r6hj61gs6xlr4zzy.jpg)

Golang don't have Enumerators!

I show you the simple way for **simulate** enum in go.

```go
package domain

type Status uint8

const (
	Creating Status = iota
	Pending
	Expired
	Paid
	Canceled
	Error
	Unknown
)

func (s Status) ToString() string{
	switch s {
	case Creating:
		return "Creating"
	case Pending:
		return "Pending"
	case Expired:
		return "Expired"
	case Paid:
		return "Paid"
	case Canceled:
		return "Canceled"
	}
	return "Unknown"
}
```
Using:
```go
  statusCanceled := Canceled.ToString()

   // in another package
  statusCanceled := domain.Cenceled.ToString()
```

The tests:
```go
package domain

import (
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestToString(t *testing.T) {
	type test struct {
		description string
		input       Status
		expected    string
	}

	tests := []test{
		{description: "should return Creating", input: Creating, expected: "Creating"},
		{description: "should return Pending", input: Pending, expected: "Pending"},
		{description: "should return Expired", input: Expired, expected: "Expired"},
		{description: "should return Paid", input: Paid, expected: "Paid"},
		{description: "should return Canceled", input: Canceled, expected: "Canceled"},
		{description: "should return Error", input: Error, expected: "Error"},
		{description: "should return Unknown", input: Unknown, expected: "Unknown"},
	}

	for _, item := range tests {
		t.Run(item.description, func(t *testing.T) {
			assert.Equal(t, item.expected, item.input.ToString())
		})
	}
}

```
Hoisting: Some exercises.
Tags: javascript, webdev, beginners, programming
Published: 2021-12-03 00:28:16

Hello! 

This time we will review the hoisting and the scope, one more time. Previously, we check them as concepts. But now, we going to realize come exercises to see how the hoisting and scope work inside the JS engine.

Remember in JS we have three ways to make a declaration: var, let and const. 

```JS
console.log(variable) // undefined
var variable = "Hi";
console.log(variable) // Hi
```
In this case, if we call the variable with the keyword "var" before the initialization, JS returns an undefined value. That's happened because, with the hoisting, anything variable with a "var" keyword has been moved at the top. So, JS moves the initialization, but not the value or the assignation. The value has been assigned in line 2. 

What happens if we try to call our variables with the keywords "let" and "const" before the initialization?
Let's see below:

```JS
console.log(variable2)
console.log(anotherVariable)

let variable2 = "Hi, i'm a let"
const anotherVariable = "Hi, i'm a const"

//ReferenceError: Cannot access anotherVariable' before initialization
//ReferenceError: Cannot access 'variable2' before initialization
```
In this case, we see that JS gives us an error, a specific error called: Reference Error, that's means that JS does not hoist the declarations with those keywords.

Another issue with the hoisting happens in the functions. In this case, we must see some examples as to how the some of functions can be affected by the hoisting.

```JS
console.log(sum(2,3)) //5
function sum(num, num2) {
    return num + num2
}

console.log(sum2(2,3)) //ReferenceError: Cannot access 'sum2' before initialization
const sum2 = function(num1, num2) {
    return num1 + num2
  }


console.log(sumNumbers(2,3)) // ReferenceError: Cannot access 'sumNumbers' before initialization
const sumNumbers = (num, num2) => num + num2
```
In this case and always all the functions as function declaration have moved at the top like the variable with "var", but with a small and important difference, in this case, the function work. Why?  The reason is that JS moves not just the initialization as a variable, JS moves the scope too. Meanwhile, a function expression and the arrow functions never will be moved at the top, and JS shows us a reference error if we invoke them before an initialization.
December 2nd, 2021: What did you learn this week?
Tags: weeklylearn, discuss, weeklyretro
Published: 2021-12-03 02:49:46

It's that time of the week again. So wonderful devs, what did you learn this week? It could be programming tips, career advice etc.

<center>

![Boss from the Office Space movie sipping his coffee in front of a cubicle](https://media.giphy.com/media/lSVL6vdhdZVPW/giphy.gif)

</center>

Feel free to comment with what you learnt and/or reference your TIL post to give it some more exposure.

{%tag todayilearned %}

And remember, if something you learnt was a big win for you, then you know where to drop it as well.👇👇🏻👇🏼👇🏽👇🏾👇🏿

{%link https://dev.to/devteam/what-was-your-win-this-week-4l7b %}

<center>

![A show host dancing a winning in their seat](https://media.giphy.com/media/l3q2Z6S6n38zjPswo/giphy.gif)
</center>
Peak Index in a Mountain Array
Tags: leetcode, javascript, binarysearch
Published: 2021-12-03 02:30:30

---
title: Peak Index in a Mountain Array
published: true
description: Leetcode | Binary Search | Brute Force
tags: leetcode, javascript, binarysearch
//cover_image: https://direct_url_to_image.jpg
---

### Problem
Let's call an array arr a mountain if the following properties hold:
arr.length >= 3

There exists some i with 0 < i < arr.length - 1 such that:
arr[0] < arr[1] < ... arr[i-1] < arr[i]
arr[i] > arr[i+1] > ... > arr[arr.length - 1]
Given an integer array arr that is guaranteed to be a mountain, return any i such that arr[0] < arr[1] < ... arr[i - 1] < arr[i] > arr[i + 1] > ... > arr[arr.length - 1].

### Brute Force Approach
```
var peakIndexInMountainArray = function(arr) {
    let count =0;
    
    for(let start=0; start < arr.length; start++){
        if(arr[start] < arr[start+1]){
            count+=1;
        }
    }
    return count;
};
```
Day 489 : December
Tags: hiphop, code, coding, lifelongdev
Published: 2021-12-03 01:35:51

_liner notes_:
- Professional : Meetings. That's it. That was my day. haha.

- Personal : Went through a bunch of tracks for the radio show. Planned out version 2 of a website I've got. Played around with my camera some more. Think I'm going to pick up an iPad Mini to be able to connect and operate my streaming cameras. These companies always seem to put more effort into the iOS apps. haha The iPad Mini seems like it will be a good size for what I'll be using it for. We'll see. Hoping for a sale. haha.

![Overhead photo of a beach at Big Sur, CA, USA with large rock formations sticking out of the ocean](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ewl85tsl2q4im1nhl3ka.jpg)

Came across this challenge where if you deploy a site with a certain provider in December, they will donate money to an organization that helps people get into tech. I've got a project / demo I used for a talk earlier in the year. I may get a domain name and deploy it this weekend. Tonight, I'm going to go through some more tracks and then watch another episode of "Cowboy Bebop". It's pretty good.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube cjaf9N54cAk %}
Intersection of Three Sorted Arrays
Tags: leetcode, binarysearch
Published: 2021-12-03 00:43:13

---
title: Intersection of Three Sorted Arrays
published: true
description: Leetcode | Binary Search 
tags: leetcode, binarysearch
//cover_image: https://direct_url_to_image.jpg
---
### Problem:
Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, return a sorted array of only the integers that appeared in all three arrays.

```
var arraysIntersection = function(arr1, arr2, arr3) {
    let p1=0;
    let p2=0;
    let p3=0;
    
    let ans = [];
    
    while(p1 < arr1.length && p2< arr2.length  && p3 < arr3.length){
        
        if(arr1[p1] === arr2[p2] && arr2[p2] === arr3[p3]){
            ans.push(arr1[p1]);
            p1++;
            p2++;
            p3++;
        }else{
            if(arr1[p1] < arr2[p2]){
                p1++;
            }else if(arr2[p2] < arr3[p3]){
                p2++;
            }else{
                p3++;
            }
        }
    }
    return ans;
};
```
Set your NodeJS version in Netlify
Tags: node, javascript, jamstack, netlify
Published: 2021-12-10 14:37:57

---
title: Set your NodeJS version in Netlify
published: true
date: 03/12/2021
tags: 
  - NodeJS
  - Javascript
  - JAMStack
  - Netlify
canonical_url: https://www.elian.codes/blog/12-03-21-set-your-node-version-in-netlify/
---

A couple of times I needed to fix the [NodeJS](<https://nodejs.org>) version on a [Netlify](<https://www.netlify.com>) site, I found myself googling it a couple of times, so this little how-to is basically a note-to-self.

The solution to setting a fixed NodeJS version is actually quite easy:

1. go to your desired website
1. go to Site Settings
1. under *Build & deploy*
1. scroll down to *Environment*
1. add a new environment variable named `NODE_VERSION`
1. set it to your desired version (major or minor)

![setting the Node version environment variable in Netlify](https://i.imgur.com/dHA6d8B.png)

When you set it to `16`, it will automatically use the latest `16.xx.xx`.

More information over on the [Netlify documentation](<https://docs.netlify.com/configure-builds/manage-dependencies/>)
Root Reducer
Tags: rails, react, redux, beginners
Published: 2021-12-02 22:49:35

In order to create a store for redux, you need to use the createStore method. This method takes in three arguments. One argument, the reducer, is required while the other two (initial state & middleware) are optional.

![create store](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5omm64c327ece09qpsjl.png)

Today I will be talking about the required argument, the reducer. In my project I only have one reducer but have created a root reducer in case I decide to add more reducers in the future.

A root reducer is necessary when you have more than one model in your code. More than one model is more than one reducer and the create store method does not take in multiple reducers. So what needs to be done is to create a root reducer that holds multiple reducers. 

Here I show you how I created my root reducer using the combine reducers method. This method is what allows me to combine multiple reducers to one main reducer. 


![combineReducers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ezkok6subvry0nutnckh.png)

When I decide to add another model, I will simply import the file to my root reducer and add it inside my combine reducers method, right below the reducer you see there.

And just like that you're able to have multiple reducers in your store. 


![done](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/coqz0qprs83j9b5hd1la.gif)
Would you opt to have your consciousness live forever on a computer? Tell us for an upcoming episode of our podcast! 🎧
Tags: podcast, discuss
Published: 2021-12-02 21:50:50

---
title: Would you opt to have your consciousness live forever on a computer? Tell us for an upcoming episode of our podcast! 🎧  
published: true
description: 
tags: podcast, discuss
---

The [DevDiscuss Podcast](dev.to/devdiscuss) begins with an interview and ends with commentary from listeners — and we like to feature the _actual_ voices from our community!

To inform an upcoming episode of the show, we'd like to know...

> ### **Would you opt-in to have your consciousness live forever on a computer? Why or why not?**


For your chance to hear your actual comments on an upcoming episode, answer the question above by:

- Calling our Google Voice at +1 (929)500-1513 and leave a message 📞

- Sending a voice memo to pod@dev.to 🎙

- OR, leaving a comment here (we'll read your response aloud for you) 🗣

Please send in your recordings by Wednesday, December 8th at 9 AM, ET (1 PM UTC, 6 AM PT)

#### Voice recordings will be given priority placement 😉

Catch up on recent episodes of the show [here](https://dev.to/devdiscuss) 👀
Advent of Code 2021 - Day 1
Tags: adventofcode, java
Published: 2021-12-02 21:48:39

Hi all!

 This is my solution of the first puzzle of Advent of Code on Day 1, in Java.



```java
package main;

import java.io.File;
import java.util.*;

public class Puzzle {

    public static void main(String[] {
        try {
            File input = new File("/Users/files/input.txt");
            Scanner scanner = new Scanner(input);
            List<Integer> numbers = new ArrayList<>();

            while (scanner.hasNextLine())
                numbers.add(Integer.parseInt(scanner.nextLine()));

    
            int count = 0;

            for (int i = 1; i < numbers.size(); i++) {
                if (numbers.get(i) > numbers.get(i - 1)) {
                    count++;
                }
            }

            System.out.println(count);
        } catch (Exception e) {
            System.out.println("Exception!");
        }

    }

}
```
[Python] TypeError 'module' object is not callable in Python
Tags: python, typeerror
Published: 2021-12-02 21:42:31

 'module' object is not callable

-> when module name and class name are confused, this error raised

For example,

I have DBCM class inside dbcm.py and import DBCM class like this,

```
import dbcm

# do something with dbcm
with dbcm(slef.db_name, sql):
 .....
```

It will raise that typeerror. 

How to solve it,

Be clear which one is module and which one is class

```
from dbcm import DBCM as db_cm

with db_cm(self.db_name, sql):
 ....
```

Modified by Keoni Garner - Thank you!:

```
from dbcm import DBCM

with DBCM(self.db_name, sql):
 ....
```


Resource: https://www.stechies.com/typeerror-module-object-is-not-callable/
Record User Sessions on Carrd.co
Tags: webdev, startup, beginners, javascript
Published: 2021-12-02 21:37:03

If you are an indiehacker or a maker, you may have already heard/used [Carrd.co](https://try.carrd.co/x7c7k77p). For those who haven’t, it’s a No-Code landing page builder that allows you to create responsive landing pages in minutes!

With the help of [TrueStory](http://truestory.ink/) analytics you can now add the ability to capture and replay user sessions of your visitors. Before you get started, make sure you have a paid plan with Carrd.co

- Go to your Carrd web site editor and add an “**Embed**” component
- Change the type to “**Code**” and give the label a name ('TrueStory')
- Change the style to “**Inline**” and copy your TrueStory script tag into the code field.
- Save and Publish your site. That’s it!

Your TrueStory dashboard should already start showing you stats and screen recordings that’ll help you better understand your users.
Solving day 2 of Advent of Code 2021 in JavaScript
Tags: challenge, adventofcode, javascript, video
Published: 2021-12-02 21:17:32

---
title: Solving day 2 of Advent of Code 2021 in JavaScript
published: true
description: JavaScript walkthrough of Advent of Code 2021 (day 2)
tags: challenge, AdventOfCode, javascript, video
series: Advent of Code 2021 in Javascript
---

{% youtube 13qSFid9HKM %}
✉️ Easily setup OhMySMTP for your Laravel application
Published: 2021-12-02 21:10:29

When I was launching my new website, I was looking for an email provider. That's when I came across [OhMySMTP](https://ohmysmtp.com), a simple and privacy-friendly transactional email service. My web framework of choice, Laravel, unfortunately doesn't support OhMySMTP by default. Luckily, OhMySMTP does provide a swiftmailer transport plugin! This can be installed in any Laravel project, and can be configured like official transports.

## Example setup

First, open up or create your project:
```
$ laravel new ohmysmtp_demo
```

And install the swiftmailer transport:
```
$ composer require ohmysmtp/ohmysmtp-swiftmailer
```

### Configure Laravel

Create `OhmysmtpServiceProvider.php` under `app/Providers`:

```php
<?php

namespace App\Providers;

use Illuminate\Mail\MailManager;
use Illuminate\Mail\MailServiceProvider;
use Ohmysmtp\OhmysmtpSwiftmailer\OhmysmtpSwiftmailerTransport;

class OhmysmtpServiceProvider extends MailServiceProvider
{
    protected function registerIlluminateMailer()
    {
        $this->app->singleton('mail.manager', function ($app) {
            $manager = new MailManager($app);
            $this->registerOhMySmtpTransport($manager);
            return $manager;
        });
    }

    protected function registerOhMySmtpTransport(MailManager $manager) {
        $manager->extend('ohmysmtp', function ($config) {
            if (! isset($config['token'])) {
                $config = $this->app['config']->get('services.ohmysmtp', []);
            }
            return new OhmysmtpSwiftmailerTransport($config['token']);
        });
    }
}
```

Remove Laravel's own `MailServiceProvider` from `config/app.php`, and add our own:

```php
'providers' => [
        //Illuminate\Mail\MailServiceProvider::class,
        App\Providers\OhmysmtpServiceProvider::class,
],
```

Now add our custom transport to the `mailers` array in `config/mail.php`:
```php
'ohmysmtp' => [
    'transport' => 'ohmysmtp',
],
```

And add our OhMySMTP API token field to `config/services.php`:
```php
'ohmysmtp' => [
    'token' => env('OHMYSMTP_API_TOKEN'),
],
```

### Environment variables

To enable the OhMySMTP transport, configure the following variables in your `.env` file:
```env
MAIL_MAILER=ohmysmtp
OHMYSMTP_API_TOKEN=<Add your token from the OhMySMTP dashboard>
```

And that's it! 🎉 Laravel will pick up the mailer variable automatically, and route all emails through the custom transport.
What is the best way to implement a WYSIWYG editor?
Tags: webdev, react, javascript, saas
Published: 2021-12-02 17:19:18

Hi! I'm building a react app that needs a very powerful and customizable WYSIWYG editor. I will start by implementing things that  Ghost, Medium, Typora, and Gitbook editor can do, and then maybe need to add other powerful features including collaboration. My project is in early prototype stage, so I don't even know what kind of features I may need to build in the future.

What are my best options, which libraries should I consider?

Did anyone experiment with Slate.js, ProseMirror, Tiptap, other libraries I may not be aware of? Which ones are the most flexible/powerful, and future proof enough to build a long term project around?

Also, a side question - how hard is it to implement google-docs-like pagination in a WYSIWYG web text editor? I've asked on Slate.js chat, and apparently it's very hard, although I don't quite understand the reasons and details. Any tips on tackling that?
JDK 18: What to expect in Java 18
Tags: java
Published: 2021-12-02 20:59:22

**Due in March 2022, Java 18 has attracted recommendations to hatch the vector API, preview pattern matching for switch statements, and embrace UTF-8 as the default character set. **


Due in March 2022, Java 18 keeps on adding highlights, with nine component recommendations being considered for it up until this point, including the deprecation of finalization, a capability that was intended to help avoid resource leaks but has brought with it risks of unconstrained behavior and unpredictable latency.



The OpenJDK page for Java Development Kit (JDK) 18 records the accompanying elements as authoritatively focusing on JDK 18 as of November 24: a service provider interface, a basic web server, a vector API, code snippets, a reimplementation of core reflection, a UTF-8 charset, the second incubator of a foreign function and memory API, and the second preview of pattern matching for switch statements. Deprecation of finalization is proposed to target JDK 18 in the JDK Enhancement Proposal (JEP) record.

[Upcoming feature Specifics of the JDK 18 proposals includes](https://www.javaoneworld.com/2021/12/jdk-18-what-to-expect-in-java-18.html?m=1)