teleren/devto huggingface dataset:
Cleaning up markdown generated from pandoc with Python
Tags: markdown, pelican, python
Published: 2020-08-17 18:52:54

---
title: Cleaning up markdown generated from pandoc with Python
published: true
date: 2020-08-14 06:13:20 UTC
tags: Markdown, Pelican, python
canonical_url: https://blog.kevingoldsmith.com/2020/08/13/cleaning-up-markdown-generated-from-pandoc-with-python/
---

I’ve been playing around with [Pelican](https://blog.getpelican.com/) lately, using it to build my new [Nimble Autonomy, LLC](https://nimbleautonomy.com) site (more on that soon).

So far, I like Pelican as a static site generator. It seems to strike a reasonable balance between generality and power. I previously used [Hugo](https://gohugo.io/) to build the [Unit Circle Rekkids](https://www.unitcircle.com/rekkids/) site. I found it reasonably decent, but not life-changing. That site’s content doesn’t change that often, so once it was built, I have only had to make an occasional tweak. This new site will be changing a bit more often.

To get some content on the new site, I wanted to republish some posts from this blog. Using the [instructions for WordPress](https://www.inmotionhosting.com/support/edu/wordpress/export-wordpress-sites/) Export and [Pelican-import](https://docs.getpelican.com/en/4.2.0/importer.html), I was able to generate some markdown from my WordPress posts, but it was a bit underwhelming.

There was a lot of this kind of gunk in the markdown:

```
<!-- wp:paragraph -->`{=html}While I am an experienced video-conferencer and a reasonably experienced presenter, presenting to a remote audience is still something I am learning how to do. Having just given a talk this morning, I did want to share some things that are working well for me at the moment.`<!-- /wp:paragraph -->`{=html}`<!-- wp:heading -->`{=html}The Tools **---------** `<!-- /wp:heading -->`{=html}`<!-- wp:paragraph -->`{=html}
```

Only a few of my images were even referenced. I quickly realized that if I was going to try to move more than a handful of articles over, I was going to be spending a lot of time hand-editing the generated markdown.

This was an obvious problem that automation could fix. As I was using a python-based static-site generator, I decided to use python to do my cleanup. I’m sharing the code below as it may help others who are trying to solve the same problem. At some point, I might try to create a pull-request for it with Pelican, but right now I am just trying to move forward on other things.

It isn’t the best or cleanest python I’ve written, this was done quickly with a lot of iteration to catch all the corner cases. It could also be more pythonic. It is also very opinionated in the Markdown that it creates.  
  
At some point, I may clean it up, but really I’m supplying it here because I have to believe that other people have hit the same problem and I want to save those folks some time.

Feel free to fork and improve!

[see the gist here](https://gist.github.com/kevingoldsmith/9e696de6f9b07536febfb4da22661be4)
Will Vim give me more productivity!?
Tags: vim, editor, productivity, codequality
Published: 2020-08-14 06:22:04

I am very much tired using arrow keys again and again for moving my cursor back and forth, so finally i decided to learn VIM. As i heard that you are not a developer at all if you can't use vim. Or its key bindings at least.

So my question is that Should i or Should i not? 
Or there is some other alternatives are available for my problem? 

Will love to hear from here.😅🙌

Thanks
Good-first-issues: How to get contributors to your project
Tags: contour, opensource, github, go
Published: 2020-08-14 06:16:26

Last week's Open Source Friday was a treat. We spoke to Nick Young from Project Contour. He gave us tonnes of insights into building and maintaining a project, as well as getting involved.

Aside from the fact we also spoke about *Ghosts of Tsushima* and other video games, Nick told us the importance of attracting good talent. We looked at Project Contour's good-first-issues for some insights. The key to good-first-issues is they need to be easy enough for people to understand. Nick said he - or any of the other maintainers - could easily attend to the good-first-issues.

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

Instead, he tells us those issues are there as they are a great way to attract people to the project. It gives them something to work on that's not too difficult. Good-first-issues help provide an understanding of how Project Contour works, as well the culture of the team.

Nick says it's really important to check out these good-first-issues. One of the best pieces of advice Nick gave to budding contributors, is just "to start". Dive in and give it a go. Check out what language an open source project uses... hint; Project Contour uses mostly Go. If there's a project and you know the language just go for it! There's no better time to start than the present.

Check out this short [Twitch clip](https://www.twitch.tv/github/clip/SleepyKathishElephantSquadGoals) to hear some of Nick's words of wisdom.

### Tune in next time ###

If you missed out on this session, don't worry. Check out the full recording on our [YouTube Channel](https://www.youtube.com/github). Plus, tune into our lives streams on our [Twitch Channel](https://twitch.tv/GitHub) every Friday, 2pm AEST and Friday, 9.30am PT. See you there!

{% youtube 40k-pP4mc8A %}
Google Analytics With Next JS
Tags: react, nextjs, googleanalytics, script
Published: 2020-08-14 06:13:49

In the old version of Nextjs, we had to add the scripts in `_document.jsx` which would be heavy on loading performance. Thanks to the new Script Nextjs component, we can add scripts anywhere in the app, and it will also take care of optimizing the app performance. 

If you are wondering about can I implement the same strategy in other react meta frameworks, check out [https://partytown.builder.io/](Partytown) which works great with Astro, Gatsby, etc.

First, add your project to Google Analytics then copy the GA measurement id from `Admin/Date Streams/Steam Details`. 

Then create a `.env` file and add `NEXT_PUBLIC_GA_ID=YOUR_GA_MEASUREMENT ID`. Restart the app if it's already running. 

Finally, Add the code below in your global Jsx file like `_app.jsx` or `_document.jsx` etc.

```jsx
<Script
   strategy="afterInteractive"
   src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GA_ID}`}
/>
<Script
   id="gtag-init"
   strategy="afterInteractive"
   dangerouslySetInnerHTML={{
      __html: `
            window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
            gtag('js', new Date());
            gtag('config', '${process.env.NEXT_PUBLIC_GA_ID}', {
              page_path: window.location.pathname,
            });
          `,
    }}
/>
```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/khrmia4289cp2lduyo9z.png)

Make sure to add the environment variable in your hosting server too.

You can also check this Nextjs example from [Github](https://github.com/vercel/next.js/blob/canary/examples/with-google-analytics).

## Related Article
[Tailwind CSS With Next.js and Typography](https://www.alhaqi.com/blog/tailwind-css-with-next-js-and-typography).
Good first issues with dry-rb
Tags: opensource, github, dryrb, ruby
Published: 2020-08-14 05:57:27

Each Friday, we've been hosting Open Source Friday on the [GitHub Twitch Channel](https://twitch.tv/GitHub). We bring in a new maintainer to chat about their project. Recently we spoke to Tim Riley from [dry-RB](https://dry-rb.org/).

[Dry-RB](https://github.com/dry-rb) is a collection of Ruby libraries. These libraries, or Ruby Gems, help developers write better Ruby code. Tim showed us all the fun facts about the dry-rb Ruby gems.

Since this is Open Source Fridays, Tim talked through the structure of the dry-rb open source project. Tim gives his top tips for organising and maintaining your projects. This is really important when you're looking to attract new contributors.

Speaking of attracting talent, good-first-issues is a great place to start. As always on our Open Source Friday streams, we talked with dry-rb about good-first-issues. If you're a new contributor coming to dry-rb, what can you contribute to? Why are those good-first-issues, well, good? How do they help you get familiar with the project?

Check out the short [Twitch clip](https://www.twitch.tv/github/clip/CrispyAffluentHedgehogUncleNox) for some insights. 

### Tune into GitHub Open Source Friday

If you missed this session, keep an eye on our [YouTube channel]() for the full interview. Don't miss the next exciting Open Source Friday; 2pm AEST, and 9.30am PT. Tune into our [GitHub Twitch Channel](https://twitch.tv/GitHub) to watch, interact, and ask questions.
How to Use “HEX2DEC Function” in Microsoft Excel 365?
Tags: excelfunctions, hex2decfunctioninexc
Published: 2020-08-14 11:25:29

---
title: How to Use “HEX2DEC Function” in Microsoft Excel 365?
published: true
date: 2020-08-14 05:52:35 UTC
tags: ExcelFunctions,HEX2DECFunctioninExc
canonical_url: https://geekexcel.com/how-to-use-hex2dec-function-in-microsoft-excel-365/
---

## HEX2DEC Function in Excel:

In this article, you will learn how to use **HEX2DEC Function in Excel 365** with its basic syntax, description, and examples. Get official version of **MS Excel** from the following link: [https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)

## Jump To:

- [**HEX2DEC- Function Description**](#1)
- [**Basic Syntax**](#2)
- [**Examples**](#3)
- [**Wind-Up**](#4)

## HEX2DEC- Function Description:

- Using **HEX2DEC function** , you can easily convert the hexadecimal value into a decimal value.
- This function is just opposite to the **DEC2HEX Function** in Excel.

## Basic Syntax:

**=HEX2DEC(number)**

### Argument Description:

**Number** – The number you want to convert it into a decimal value.

### **Note:**

- If the input is not a valid hexadecimal number, it returns **#NUM!** Error.
- The hexadecimal numbers or values **must not contain any negative sign** in front of it.

## Examples:

Let’s see an example to understand it quickly.

![HEX2DEC Conversion](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/08/1-24.png)<figcaption id="caption-attachment-11636">HEX2DEC Conversion</figcaption>

From the above image, you can see the hexadecimal numbers and their corresponding decimal numbers. If the input value is not a valid hexadecimal number (refer to **A6** cell) it returns **#NUM!** Error.

## Wind-Up:

In this article, you can really learn the usage of **HEX2DEC Function in Excel 365** with its syntax, description, and examples. Drop your **suggestions** in the below comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!!

### Similar Functions:

- [**HEX2OCT Function**](https://geekexcel.com/how-to-use-hex2oct-function-in-microsoft-excel-365/)
- [**HEX2BIN Function**](https://geekexcel.com/how-to-use-hex2bin-function-in-ms-excel-365-with-examples/)

### Read Also:

- [Use N Function in Microsoft Excel 365 -Simple methods!!](https://geekexcel.com/use-n-function-in-microsoft-excel-365-simple-methods/)
- [How to Use BIN2OCT Function in Microsoft Excel 365? – With Examples](https://geekexcel.com/how-to-use-bin2oct-function-in-microsoft-excel-365-with-examples/)
How to Use “HEX2OCT Function” in Microsoft Excel 365?
Tags: excelfunctions, hex2octfunctioninexc
Published: 2020-08-14 11:25:22

---
title: How to Use “HEX2OCT Function” in Microsoft Excel 365?
published: true
date: 2020-08-14 05:43:21 UTC
tags: ExcelFunctions,HEX2OCTFunctioninExc
canonical_url: https://geekexcel.com/how-to-use-hex2oct-function-in-microsoft-excel-365/
---

## HEX2OCT Function in Excel:

In this article, you will learn how to use **HEX2OCT Function in Excel 365** using its basic syntax, explanation, and examples. Let’s see them below!! Get official version of **MS Excel** from the following link: [https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)

## Jump To:

- [**HEX2OCT- Function Description**](#1)
- [**Basic Syntax**](#2)
- [**Examples**](#3)
- [**A Brief Summary**](#4)

## **HEX2OCT- Function Description:**

- This Function will convert the hexadecimal number into an octal number.
- Sample hexadecimal values are A3, B5.

## **Basic Syntax:**

**=HEX2OCT(number, [places])**

### **Note:**

- If the input is not a valid hexadecimal number it returns **#NUM!** Error.
- If you give any negative value in places option, it returns **#NUM!** Error value.
- If “places” is non-numeric value, it will show **#VALUE!** Error.

## **Examples:**

See the below example images to understand this function.

### Example 1:

- The following screenshot has shown hexadecimal values in **Column B** , Places in **Column C**.
- Decimal values of column B have been listed in **Column A**.
- The converted octal values are placed in **Column D**.

![HEX2OCT Conversion](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/08/1-25.png)<figcaption id="caption-attachment-11639">HEX2OCT Conversion</figcaption>

### Example 2:

- If the input is not a valid hexadecimal number it returns **#NUM!** Error.
- If you give any negative value in places option, it returns **#NUM!** Error value.

![Example 2](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/08/2-21.png)<figcaption id="caption-attachment-11640">Example 2</figcaption>

### Example 3:

- If “places” is non-numeric value, it will show **#VALUE!** Error.

![Example 3](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/08/3-19.png)<figcaption id="caption-attachment-11642">Example 3</figcaption>

## **A Brief Summary:**

In this article, we guided you to learn the usage of **HEX2OCT Function in Excel 365** using its basic syntax, explanation, and examples. Leave your **feedback** in the comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!!

### Similar Functions:

- **HEX2DEC Function**
- **HEX2BIN Function**

### Keep Reading:

- [How to Use “BITLSHIFT” Function in Excel 365? – {With Examples}](https://geekexcel.com/how-to-use-bitlshift-function-in-excel-365-with-examples/)
- [Use ISTEXT Function in Microsoft Excel 365 In Easy Ways!!](https://geekexcel.com/use-istext-function-in-microsoft-excel-365-in-easy-ways/)
- [How to Use BIN2OCT Function in Microsoft Excel 365? – With Examples](https://geekexcel.com/how-to-use-bin2oct-function-in-microsoft-excel-365-with-examples/)
Sudo in Windows 10
Tags: tidbit
Published: 2020-08-14 05:31:25

`ssh max@localhost`

It's longer than `sudo`, but it's shorter than `Start-Process Powershell -Verb runAs` (and doesn't open a new window).

> But, Max, that's just an SSH login command!

That it is!  Windows 10 has built-in OpenSSH now, both server and client.  It just so happens that the Windows 10 SSH server gives administrative users an administrative context.  It's understandable why they would do it that way, given that Windows doesn't have a `sudo` equivalent, and that SSH is often used for remote _administration_.

So, whenever I need to bash out a Chocolatey command, or... is there anything else I ever need an administrative console for?  Anyways, whenever I need to do that, instead of opening a new Windows Terminal window, I just `ssh max@localhost` my way to super-user success!
Max Consecutive Ones (Javascript)
Tags: javascript, algorithms
Published: 2020-08-14 05:22:32

Algorithms have been a struggle for me to learn. I don't particularly enjoy them (until I solve them). I've been told they're an important part of being a developer, especially when searching for your first job. I practice on Leetcode and I'll start posting my accepted submissions here.

Here is my solution for [this Leetcode problem.](https://leetcode.com/problems/max-consecutive-ones/) 

>Given a binary array, find the maximum number of consecutive 1s in this array.
Note:
- The input array will only contain 0 and 1.
- The length of the input array is a positive integer and will not exceed 10,000

My job is to count the number of times the number 1 appears in a row and return the largest run of 1's. Just from reading the description using a `for` loop to touch each entry in the array is my plan. I'll use two variables. One to keep track of the current count and the second, the return value, to keep track of the largest number of 1's in a row.  I'll call those `currentCount` and `largestCount` respectively.

```javascript
var findMaxConsecutiveOnes = function(nums) {
    let largestCount = 0;
    let currentCount = 0;
    for (let i = 0; i<nums.length; i++) {
        if (nums[i] === 0) {
            currentCount = 0;
        } else {
            currentCount++;
        };
        if (currentCount > largestCount) largestCount = currentCount;
    };
    return largestCount;
};
```

Going through the array:
- First I check if the element (`nums[i]`) is 0.
 - If it is 0, I set `currentCount` to 0. Because that ends any run I have going.
- If the element is not 0, I add one to `currentCount`.
 - *This works because of the note supplied by Leetcode. The only elements in the array will only be 1 or 0.*
- Before ending the current iteration of the loop, I check and see if the `currentCount` is greater than the `largestCount`. If so, set that to `largestCount`.

After iterating through the entire array return the `largestCount`. 

___ 

Here is a refactor of this code using a ternary instead of an if/else statement.

```javascript
var findMaxConsecutiveOnes = function(nums) {
    let largest = 0;
    let current = 0;
    for (let i = 0; i<nums.length; i++) {
        nums[i] === 0 ? current = 0 : current++;
        if (current > largest) largest = current;
    };
    return largest;
};
```
Say hello to SubmitForm.app!
Tags: showdev, serverless, node, slack
Published: 2020-08-14 04:51:11

# What is it?
[SubmitForm.app](https://try.SubmitForm.app) is a Slack app that sends form submissions and file uploads to Slack. It’s great for collecting visitor **contact information**, **quote requests**, **surveys**, **file uploads**, and more.
Moonscript Iteration
Tags: recursion, moonscript, lua
Published: 2020-08-14 04:30:52

[collatz]: https://www.ams.org/journals/proc/1981-082-01/S0002-9939-1981-0603593-2/S0002-9939-1981-0603593-2.pdf
[fibonacci]: http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibnat.html
[moonscript]: https://moonscript.org/

[Moonscript][moonscript] is an interesting imperative weakly-typed programming language with some functional spice.

The Moonscript code compiles into Lua, much more verbose. This provides Moonscript with all Lua features, including coroutines and iterators.

We’re gonna look at three different approaches to implement iterations in Moonscript henceforth.

### Standard Lua iteration

The standard iterator consists of three parameters: a step function, the context (usually used as stop condition), and the initial state.

The step function, in turn, must take two parameters, the context (stop condition) and the previous state, returning the next state.

For instance, we’re using the [Collatz conjecture][collatz].

The Collatz conjecture’s step function might be:

```moonscript
_collatz = (stop, prev) ->
    return if prev == stop
    switch prev % 2
        when 0 -- even
            prev / 2
        when 1 -- odd
            prev * 3 + 1
```

When the sequence reaches the stop condition, it returns `nil` (nothing) – the `for` calls the step function until it receives `nil` back.

Now we can build the iterator function, that receives the step function, the stop condition, and the initial state (that we’re doubling up in order to preserve the parameter):

```moonscript
collatz = => _collatz, 1, @*2
```

We can use it:

```
mooni> print x for x in collatz 10
10
5
16
8
4
2
1
mooni>
```

### Closures

The Standard Lua iteration is quite cryptic. A clearer approach is using closures.

Using closures, the Collatz must return the final function, that returns each value by turn, so it needs to hold the context in a free mutable variable:

```moonscript
collatz = =>
    value = @*2 -- free variable
    ->
        return if value == 1
        switch value % 2
            when 0 -- even
                value /= 2
            when 1 -- odd
                value = value * 3 + 1
        value
```

it works just like before, keeping the `value` variable between executions as state.

### Coroutine

The most powerful approach Lua can offer is the coroutine. No free variables (closures), only a stateful coroutine yielding results.

There isn’t much fun in *coroutined* Collatz, so let’s try the [Fibonacci number][fibonacci], which has two state variables.

```moonscript
fib = (value using coroutine) ->
    import wrap, yield from coroutine
    wrap ->
        a, b = 0, 1
        for _ = 1, value
            a, b = b, a+b
            yield a
```

No magic structures, no free variables, neither (explicitly) side effects, only the good-ol’ fellow `for`.

```
mooni> print x for x in fib 10
1
1
2
3
5
8
13
21
34
55
```
Set Secret Action
Tags: actionshackathon, github, actions, opensource
Published: 2020-08-14 04:28:53

[Instructions]: # (To submit to the GitHub Actions x DEV Hackathon, please fill out all sections.)

Create or edit actions secrets in repository or organizations

### My Workflow
[actions-set-secret/action.yml](https://github.com/hmanzur/actions-set-secret/edit/master/action.yml)


### Submission Category: 

DIY Deployments


### Link to Code

{% github hmanzur/actions-set-secret %}


### Additional Resources / Info

#### References

##### References for repository

- [Get a repository public key](https://developer.github.com/v3/actions/secrets/#get-a-repository-public-key)
- [Create or update repository secret](https://developer.github.com/v3/actions/secrets/#create-or-update-a-repository-secret)

##### References for organization

- [Get an organization public key](https://developer.github.com/v3/actions/secrets/#get-an-organization-public-key)
- [Create or update an organization secret](https://developer.github.com/v3/actions/secrets/#create-or-update-an-organization-secret)