teleren/devto huggingface dataset:
Set Editing Restrictions in Word using a free Java API
Tags: java, word, api
Published: 2021-03-26 06:13:35

In order to protect a Word document, except the general method of encrypt the entire document with passward, we could also set editing restrictions to prevent the content from being modified by others.This article will demonstrate how to set editing restrictions in Word document using a Free Java API.

**1# Installation**
**Method 1:** Download the free API ([Free Spire.Doc for Java](https://www.e-iceblue.com/Download/doc-for-java-free.html)) and unzip it, then add the Spire.Doc.jar file to your project as dependency.

**Method 2:** You can also add the jar dependency to maven project by adding the following configurations to the pom.xml.
```xml
<repositories>
   <repository>
      <id>com.e-iceblue</id>
      <name>e-iceblue</name>
      <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
   </repository>
</repositories>
<dependencies>
   <dependency>
      <groupId>e-iceblue</groupId>
      <artifactId>spire.doc.free</artifactId>
      <version>3.9.0</version>
   </dependency>
</dependencies>
```

**2# Relevant Code Snippet:**
```java
import com.spire.doc.Document;
import com.spire.doc.FileFormat;
import com.spire.doc.ProtectionType;

public class RestrictEditing {
    public static void main(String[] args){
        //Create a Document instance
        Document document = new Document();
        //Load the Word document
        document.loadFromFile("Input 1.docx");

        //No changes (Read only)
        document.protect(ProtectionType.Allow_Only_Reading, "123456");

        //Allow only comments
        //document.protect(ProtectionType.Allow_Only_Comments, "123456");

        //Allow only filling in forms
        //document.protect(ProtectionType.Allow_Only_Form_Fields, "123456");

        //Allow only tracked changes
        //document.protect(ProtectionType.Allow_Only_Revisions, "123456");

        //Save the result document
        document.saveToFile("RestrictEditing.docx", FileFormat.Docx_2013);
    }
}
```

**3# A screenshot of the output Word document after setting editing restrictions as no changes (read only):**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqyron79vq2qhmtcfmgp.png)
Today's GOING TODOs
Tags: todo
Published: 2021-03-26 06:07:17

---
title: Today's GOING TODOs
published: true
description: 3 points 26.03.2021
tags: todo
//cover_image: https://direct_url_to_image.jpg
---

* TODO comment of all the refactorings i need
* Clean functions
* Refactor bomberman Game.ts and Update.ts
Material-UI Select with React Hook Form
Tags: javascript, react, programming, tutorial
Published: 2021-03-26 05:55:49

My experience with React hook Form (RHF) is amazing so far. When you are using external css libraries with react hook form, you have to make few adjustments for example in place of **ref**, you have to use **inputRef** to pass the register method of RHF.

In this post, I would like to share a solution to the problem of **adding validation to Select component of Material-UI*** with RHF. Implementing select box is not hard. You can do that with TextField and also with Select component of Material-UI but adding validation can give you a headache. 

This is solution I implemented for adding select box with validations.

```javascript
<Controller
  as={
    <Select>
     {options.map((option, index) => (
      <MenuItem key={index} value={option}>
        {option}
      </MenuItem>
     ))}
    </Select>
    }
  name={options_name}
  control={control}
  defaultValue=""
  rules={{ required: true }
/>
```
So validation worked for me by adding the following attribute to the controller.  

```javascript
rules={{ required: true }}
```

I hope this will be helpful.
A quick tip for frontend developers
Tags: chrome, devtools, frontend, testing
Published: 2021-03-26 05:39:37

When we click on any part of the chrome dev tools, the main page loses focus. It is a problem in some cases, for example when inspecting dropdowns and stuff.
To prevent this, press `Shift + Ctrl + P`, type `Emulate a focused page`, then press `Enter`. Now the main page will not lose focus while interacting with the dev tools.
VSCode: Tips and tricks
Published: 2021-03-26 05:39:36

## Exclude folders:

- Tính năng này cho phép chúng ta ẩn đi những folder không cần thiết phải hiển thị trên folder tree.
- Vào phần settings: search excludes và thêm folder cần ẩn vào. Ví dụ muốn ẩn folder node_modules, hãy nhập vào `**/node_modules`
NFTs of Streamed Coding Sessions
Tags: monetisation, nft, streamcode
Published: 2021-03-26 05:39:06

---
title: NFTs of Streamed Coding Sessions
published: true
description: I can haz Monet
tags: monetisation, nft, streamcode
//cover_image: https://direct_url_to_image.jpg
---

IDEA: Use your coding session as a piece of art and sell it on streaming market, monetising as an NFT.
This way, live coding may garner a weird paywall again but the pure act of coding may also raise money without needing to be effective necessarily. The market may need to deal with novel problems like what if superstar coding and pompous code eccentricities take the floor and garner more interest and price than effective and efficient and novel coding.
Javascript tổng hợp
Published: 2021-03-26 05:37:51

# ARRAY

## Array filter

```js
const people = [
  { name: 'Jon', age: 23 },
  { name: 'Daenerys', age: 23 },
  { name: '﻿Arya', age: 17 }
]

const children = people.filter(person => person.age < 18)
// Returns [ { name: 'Arya', age: 17} ]
```

## Array filter

```js
const people = [
﻿  { name: 'Jon', age: 23 },
  { name: 'Daenerys', age: 23 },
  { name: '﻿Arya', age: 17 }
]

const adult = people.find(person => person.age >= 18)
// Returns { name: 'Jon', age: 23 }
```

## Array forEach

```js
const people = [
﻿  { name: 'Jon', age: 23 },
  { name: 'Daenerys', age: 23 },
  { name: '﻿Arya', age: 17 }
]

people.forEach(person => sendNotification(person))
```
Random Seed in JavaScript and Node.js
Tags: javascript, node
Published: 2021-03-26 05:13:43

---
title: "Random Seed in JavaScript and Node.js"
published: true
description: "Random seed is a method of initializing random number generators using an initial seed value. Random generators with the same seed will output the same pseudo-random results. I found this method to be particularly useful when developing a game I'm working on, which has a random 'Daily Challenge'. In this case, random seed can be useful to select a random game using the current date as a seed. Seed random is one of a few features that is present in most major programming languages but is not available out-of-the-box in JavaScript. It can be incredibly useful in a wide array"
tags: #javascript, #nodejs
cover_image: "https://xtrp.io/api/content/static_files/random-seed-in-javascript-and-nodejs/photo_dev.jpg"

---

## Introduction

Random seed is a method of initializing random number generators using an initial seed value. Random generators with the same seed will output the same pseudo-random results.

I found this method to be particularly useful when developing a game I'm working on, which has a random 'Daily Challenge'. In this case, random seed can be useful to select a random game using the current date as a seed.

## Code

So, here's how to create a random seed in Node.js, using the seedrandom NPM package:

```javascript
// In Node.js
const seedrandom = require('seedrandom');
const generator = seedrandom('[your seed here]');
const randomNumber = generator();
```

And if you're on the client-side:

```javascript
// On The Browser
const generator = new Math.seedrandom('[your seed here]');
const randomNumber = generator();
```

In both of these code snippets, the `generator` function will return a new random number each time, given the seed the generator was initialized with. In this case, it will be formatted as a numerical value, although 

## Dependencies

If you're running on Node.js, download the seedrandom package as follows:

```
npm install seedrandom
```

Or using Yarn:

```
yarn add seedrandom
```

If you're writing client-side code without webpack, you can either download the file from seedrandom's GitHub repository, or use a CDN by adding the following code snippet at the end of your `<body>` tag:

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/seedrandom/3.0.5/seedrandom.min.js"></script>
```

## Conclusion

Random seed is one of a few features that is present in most major programming languages but is not available out-of-the-box in JavaScript. It can be incredibly useful in a wide array of cases, both on the web and running on the server-side using Node.

I hope this helps, and thanks for scrolling.

*&mdash; Gabriel Romualdo, March 26, 2021*
$whoami
Tags: security
Published: 2021-03-26 05:12:51

---
canonical_url: https://sankalp.me/about
---
My name is Sankalp, and welcome to my humble web-abode!
I am a 21 years old student(?) and more importantly a "[Hacker](https://sankalp.me/Hacker/)
". Not the type you’re probably thinking of!

While watching Star Trek, I heard Spock say- 
*“Insufficient facts always invite Danger!”*

Thus, I have a simple goal; albeit a strenuous goal: to educate myself and then help others unlearn the misconceptions and misinformation that misguide people, and act as a cobweb all over the internet. 

I am not an expert in any domain but want to share my thoughts from the perspective of a curious learner who is out there seeking the true essence of knowledge. You’ll find me writing about a variety of subjects- CyberSecurity, Psychology, Finance, Philosophy, and anything that intrigues me. 
I hope you find something interesting and meaningful here. Happy reading!
This article is also published on my personal blog https://sankalp.me

P.S.- If you have some ideas to discuss or any kind of constructive criticism to share, please feel free to reach out to me
Some youtube-dl aliases
Tags: tips
Published: 2021-04-03 23:44:07

---
title: Some youtube-dl aliases
published: true
date: 2021-03-26 05:00:00 UTC
tags: tips
canonical_url: https://ianmuchina.com/blog/youtube-dl-aliases
---

## defaults

```
alias ydl='youtube-dl -o "./%(title)s.%(ext)s"'

```

- Doesn’t change much of the defaults. Only removes unnecessary info from filename eg: `video-title-dQw4w9WgXcQ.mp4 ` to `video-title.mp4`

## 720p single video

```
alias yhd='youtube-dl -f "[height<=720]" -o "~/Videos/%(uploader)s/%(title)s.%(ext)s" --no-playlist '

```

- 720p
- Single video. No playlist
- Saves to `~/Videos/Uploader/Title.mp4`

## 720p video playlist

```
alias ypl='youtube-dl -f "[height<=720]" -o "~/Videos/%(uploader)s/%(playlist)s/%(title)s.%(ext)s" '

```

- 720p
- Downloads entire playlist
- Saves to `~/Videos/Uploader/Playlist/Title.mp4`

## Audio

```
alias ymp3='youtube-dl -f "bestaudio" -o "~/Music/%(uploader)s/%(title)s.%(ext)s" --no-playlist -x --audio-format mp3 --embed-thumbnail ' 

```

- mp3
- Single audio. No playlist
- Saves to `~/Music/Uploader/Title.mp3`
- Adds thumbnail as cover art

## Audio Playlist

```
alias ypl3='youtube-dl -f "bestaudio" -o "~/Music/%(uploader)s/%(playlist)s/%(title)s.%(ext)s" -x --audio-format mp3 --embed-thumbnail'

```

- Downloads entire playlist
- Saves to `~/Videos/Uploader/Playlist/Title.mp3`
- Adds thumbnail as cover art
Laying down ground work for a Bytecode Virtual Machine
Tags: 100daysofcs, c
Published: 2021-03-26 04:13:35

Missed writing an entry yesterday, didn't miss coding though. Already done with laying down the foundation of `clox`, our Bytecode VM.

(I'm gonna be making this post very brief, because well, Bob already walks us through the entire code in the book -- https://craftinginterpreters.com/chunks-of-bytecode.html)

All we can do with `clox` right now is make a chunk and write to it. There is no front-end to the compiler, no interpretation of the code. Heck, we don't even have the full  list of opcodes (each opcode is a unique byte which corresponds to a special instruction of our language, e.g., `OP_RETURN` for returning from a function.) yet.

## Chunk. What chunk?

Consider a chunk as a sequence of codes, each a byte long. Now, these bytes might _mean_ different things: either opcodes or pointers to the data those opcodes need. But, that's all a chunk is: A sequence of bytes.

How do we know which is which?

To interpret the meaning of these bytes, we need to iterate through the entire sequence, and match it against a list of values:

1. Say, the first value we encounter is `0x10`. Let's assume that we had mapped it to `OP_RETURN`. (It is very unlikely for the _first_ opcode to be `OP_RETURN`, but bear it for it makes the example easy).

2. Next byte in the chunk might correspond to `OP_CONSTANT`.  Whenever we store a `OP_CONSTANT`, we also need to store the value this constant holds. By convention, the next byte holds the address of this value.

You can see a pattern here. Each opcode may have zero or more operands -- so our compiler can easily figure out which is which.

For now, all it does is exactly that. We hand-write a bunch of values in the chunk, like this, and let it "disassemble" it:

```c
initChunk(&chunk);

int constant = addConstant(&chunk, 1.2);

// 122 is an arbitrary line number I passed.
writeChunk(&chunk, OP_CONSTANT, 122);
writeChunk(&chunk, constant, 122);

int constant2 = addConstant(&chunk, 456);
writeChunk(&chunk, OP_CONSTANT, 123);
writeChunk(&chunk, constant2, 123);

writeChunk(&chunk, OP_RETURN, 123);

disassembleChunk(&chunk, "Test Chunk");
```

Our disassembler outputs this:

```
== Test Chunk ==
0000  122 OP_CONSANT          0 '1.2'
0002  123 OP_CONSANT          1 '456'
0004    | OP_RETURN
```
Laravel 8 CRUD Tutorial by Example
Published: 2021-03-26 04:49:32

Laravel is one of the most popular PHP-based framework for creating database-driven apps.

Laravel is described by its creators as the framework for web artisans. It's based on the MVC (Model-View-Controller) pattern and can be used for easily creating apps for making CRUD (Create, Retrieve, Update, Delete) operations against a database.

Laravel has a large community of worlwide developers around it that creates packages for common web development problems so other developers don't need to re-invent the wheel.

The Laravel team releases a new version each six months. At the time of writing this tutorial, the latest version is Laravel 8 which was released on the 8th Sept 2020.

https://codingspoint.com/laravel-8-crud-tutorial-from-scratch/
Skills To Increase Your Pay As A .NET Developer
Tags: dotnet, webdev, javascript, cloudskills
Published: 2021-03-26 04:35:25

In this video, I have listed the skills that could boost up your pay as a .NET developer.

More Info:
✔ Blog: [https://dotnetcrunch.in​](https://dotnetcrunch.in​)
✔ Instagram: [https://instagram.com/dotnetcrunch](https://instagram.com/dotnetcrunch)​
✔ Facebook: [https://facebook.com/dotnetcrunch​](https://facebook.com/dotnetcrunch)
✔ Twitter: [https://twitter.com/@dotnetcrunchh](https://twitter.com/@dotnetcrunchh)
Multiple Github accounts conveniently
Tags: github, git
Published: 2021-03-26 04:09:05

I use several github accounts, and wanted a way to use them without constantly tweaking remote urls and stuff for each repo.

The good news is at some point, it seems git started to traverse directories upwards, looking for `.gitconfig` files. So it makes it easy to setup several directories, each of which uses different credentials automatically.

So, for my *voboda* account on github:
```
mkdir ~/repos/voboda
cd ~/repos/voboda
```
And there I added a `.gitconfig` file containing:
```
[core]
	sshCommand = ssh -i ~/.ssh/id_rsa_voboda
[user]
	name = Voboda
	email = voboda@mygithubemail.com
```

Now, anything I need to work on in my voboda account, I just clone that under the ~/repos/voboda directory. For example `~/repos/voboda/onelineforyourmind` and `~/repos/voboda/underlinery`. Both will use the above user information automatically. That specific ssh command references the ssh key I setup for my `voboda` github account.

### Sidenote: separate ssh keys
On Linux, I setup that ssh key using `ssh-keygen -f id_rsa_voboda` and then copying the 2 outputted keyfiles to my `~.ssh` directory.
Chill With Searching and Loading
Tags: php, programming, discuss, showdev
Published: 2021-03-26 03:45:34

If you have 50,000,000 or more records contained in a variable and you want to look up the data from array by key and get a value similar to what you are looking for. What would you do?

Are you going to use untested code like this

```php
<?php

$lotOfData = ['name' => 'I am stupid', ... , 'name' => 'Yes, I Am'];
$searchTerm = 'am';

foreach ( $lotOfData as $key => $value ) {
   if ( strpos($value, 'am') ) {
      return $value;
   } else {
      return "What ur looking for?!";
   }
}
```

Or using code like this?

```php
<?php

function search( $array, $key, $value ) {
    $search = "/$value/i";
    $results = array_filter( $array, function( $a ) use( $search )  {
        unset( $a[$key] );
        return preg_grep( $search, $a );
    });
    return $results;
}

$lotOfData = ['name' => 'I am stupid', ... , 'name' => 'Yes, I Am'];
$searchTerm = 'am';

$search_result = search($lotOfData, 'name', $searchTerm);
```

Which code will you choose? If you have your own way to find similar data in arrays, please tell us how. It looks stupid, but YES that's ME. Spreading ignorance in orderly disorder.
LeetCode 49. Group Anagrams (javascript solution)

Tags: javascript, algorithms
Published: 2021-03-26 03:27:11

###Description:
Given the root of a binary search tree, and an integer k, return the kth (1-indexed) smallest element in the tree.

###Solution:
Time Complexity : O(n^2log(n))
Space Complexity: O(n^2)

```javascript
var groupAnagrams = function(strs) {
    // define output array
    const output = []
    // define map
    const map = {}
    // loop through strs
    for(let i = 0; i < strs.length; i++) {
       // sort current str
        const strSorted = strs[i].split('').sort().join('')
        // if sorted string is present in map
        if(map[strSorted]!==undefined) {
           // get index of output array to push current str
            output[map[strSorted]].push(strs[i])
        } else {
             // push current str into output array
            output.push([strs[i]])
            // add sorted str to map
            // set map[sorted str] = output array length - 1 
            map[strSorted] = output.length-1
        }
            
    }

    // return output array
    return output 
};
```
Lookup SOA Records using Rust & trust-dns-resolver
Tags: rust, dns, soa, crate
Published: 2021-03-26 03:10:09


This is a second article on using the **trust-dns-resolver** crate  
**Warning: This code is not intended to be used in production. You should review and adjust to your own needs.**

## Getting Started
First we will need to create our development environment.
```zsh
cargo new trust-dns-resolver && cd $_
```
This will give us our standard rust directly structure. We need to add our crate to the `Cargo.toml`  
```zsh
-snip-
[dependencies]
trust-dns-resolver = "0.20.1"
```

Next edit the `src/main.rs` as follows.

{% gist https://gist.github.com/Bas-Man/b869526dc3bf085e7c5de14f3fa57494 %}

Compile and run the code to make sure everything is ok.
```zsh
cargo run
```

This outputs the following
```zsh
Admin: dns-admin.google.com.
Admin Email: dns-admin@google.com
Primary: ns1.google.com.
Serial: 364996005
```

### Explaining the code
Documentation for the SOA RData can be found [here](https://docs.rs/trust-dns-proto/0.20.1/trust_dns_proto/rr/rdata/soa/struct.SOA.html)  
Let's take a look at what we are doing here.  
Like the first example we create a resolver which will do the work of doing the DNS lookups.  
Next we use the resolver to call `soa_lookup()` and store the result into `soa_response`  
`soa_response` will contain either and `SoaLookup` or an `Err`. For this reason we need to handle these two cases. I have changed things up a little this time and I am passing a reference to the `display_soa()` function. So I am allowing `display_soa()` to borrow the data. In doing this I am saving on memory and I am also promising that I am not going to mutate `soa_response` within this function. I will cheat a little and `clone()` some data later.  
Within `display_soa` I again use `match` to handle my two cases.  
In the case of `Err`. I do nothing and just report there were no records.  
In the case of `SoaLookup`, I will need to do some more processing.
- First lets make an `iter()` out of `soa_response` and loop over it.
- In the loop we get the `rname()` or the administrative contact and the `mname()` or primary name server for this domain as well as `serial()` and access to a few more elements.  

Line  26 is just a cobbled together function to redisplay `rname()` as a more valid email address which is what it really represents. If anyone can point in the direction of a better way to handle this it would greatly appreciated.

I hope you find this interesting and useful.
Post-Modern CSS (In-Depth on CSS Grid, Flexbox and Other New Properties)
Tags: css, webdev
Published: 2021-03-26 03:02:55

CSS has changed. It’s moving away from the mired mess of its origin and toward a bright future of interesting layout and easy design. If you’ve been focused on other important skills in the past 5 years, you’ve missed out on a lot of new, helpful techniques, including Flexbox and CSS Grid Layout.

{% youtube Vgdcub3URHQ %}

**Further reading:**
☞ [HTML6 is Coming – What’s new in HTML6](https://morioh.com/p/6d422fc49bd2 "HTML6 is Coming – What’s new in HTML6")

☞ [How To Convert HTML To PDF using JavaScript](https://morioh.com/p/48f03acd7ec6 "How To Convert HTML To PDF using JavaScript")

☞ [Animated Counter using JavaScript with HTML & CSS](https://morioh.com/p/bd6b4702d394 "Animated Counter using JavaScript with HTML & CSS")
March 25th, 2021: What did you learn this week?
Tags: weeklylearn, discuss, weeklyretro
Published: 2021-03-26 02:55:31

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>

![Information flowing through your brain](https://media.giphy.com/media/qKltgF7Aw515K/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 %}

<center>

<!--

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-391j %}

![Someone feeling like "Yaaas!"](https://media.giphy.com/media/zBhZiVNNQjfTG/giphy.gif)
</center>

-->
How to grow your web development career?
Tags: webdev, javascript, programming
Published: 2021-03-26 02:35:40

Hi guys, I have been working as a Web Developer, specially with WordPress, since 2011,for different clients around the globe.

I am neither a complete developer, nor a designer. I just create WordPress websites with the help of themes and plugins, adding/customizing some code with the help of Google.

I tried to learn full stack development with the help of some online courses, but I really don't know which way should I go to.

I am posting here because I need a mentor, who can guide me either I should learn Javascript or PHP or Python etc, and some guidance on how to stick with what you are learning, and stop change of mind.

Thanking you in advance for your time and help.