teleren/devto huggingface dataset:
Call a C library from C++
Tags: c, cpp, library, beginners
Published: 2020-04-22 06:03:42

---
published: true
title: "Call a C library from C++"
description: "How can you write a DLL in C and use it in C++."
tags: c, cpp, library, beginner
series:
canonical_url:
---

Yesterday I needed to write a small C DLL and use it in my C++ sample application. It took some time to figure out how I must do this on my Windows PC with Visual Studio installed. 
This is just a little reminder for me, so don't expect too much :-).

# C code
The C app contains just a little function:

```c
// ./code/c/lib.c

#include <stdio.h>

__declspec(dllexport) void f()
{
    printf("\n This is a C code\n");
}
```

The keyword `__declspec(dllexport)` is only valid within the Microsoft compiler world and exports that function.

# Compile C
Open the Visual Studio Developer Command Prompt and navigate to the folder, where the C project is. Then simply type: `cl /LD lib.c`. This will create two files. A `lib.lib` and a `lib.dll`.

# C++ Code
Also nothing special. First we need the header file:
```cpp
// ./code/cpp/Console/Console/Header.h

#pragma once

extern "C" {
  __declspec(dllimport) void f();
}

```
You find `declspec` again, but this time it is specified with `dllimport` which makes perfectly sense as we are importing our function :-)

Our app:
```cpp
// ./code/cpp/Console/Console/Console.cpp

#include <iostream>
#include "Header.h"
#pragma comment(lib, "../../../c/lib.lib")

int main()
{
  f();
}

```

Note the line `#pragma comment(lib, "../../../c/lib.lib")` which specifies the location of the `.lib` so the linker is able to reference the function `f()`.

# Execute
If you now execute `Console.exe` you will get an error because the `dll` can not be find. To fix this, just copy the `lib.dll` to the folder where `Console.exe` is.

----

# Found a typo?
As I am not a native English speaker, it is very likely that you will find an error. In this case, feel free to create a pull request here: https://github.com/gabbersepp/dev.to-posts . Also please open a PR for all other kind of errors.

Do not worry about merge conflicts. I will resolve them on my own.
TwilioHackathon - The late Start
Tags: twiliohackathon
Published: 2020-04-22 05:59:28

As a certain white rabbit once said to itself:
> "Oh dear! Oh dear! I shall be late!" - Lewis Carroll

I've also been saying this myself lately due to the covid19 pandemic throwing a possible metaphorical hammer in the works.
So when I came across this link  <https://dev.to/devteam/announcing-the-twilio-hackathon-on-dev-2lh8> I thought well I'm late but that's no excuse, I should be able to make something in less than a week right? 

Well if you're here reading this you're likely going to join me as I go down a rabbit hole known as I develop something :) as to what that is well I have a few ideas

* Centralise all my Phone numbers & Text Messages
* Phone App for seeing/replying to SMS
* Phone App for Receiving / Making Calls
* Web-Based phone calls?
* My business's CRM and using that to power the way calls are routed through my IVR
* Calendar Integration for Managing the IVR messages (maybe a covid19 warning?)


I'll be trying to live stream the whole development of this on my twitch channel
<https://www.twitch.tv/alicetheawoo>

As well I'll be posting updates on dev.to as I can

All the Code will be in the following Repo:
{% github StackTonic/Twilio-Hackathon-2020 %}

{% tag twiliohackathon %}
A different way to bookmark tabs and share them!
Tags: onetab, tabgroups, lpt
Published: 2020-04-22 05:56:43

OneTab is a very nifty chrome extension that can be used to group web pages together. The extension's purpose as is on its website is to reduce the memory hogged by your browser, but I use it slightly differently. It has not only helped me with keeping web pages on a related topic in a single place but also made sharing them easier. 

The steps are pretty simple
* Install the OneTab extension/add-on for your browser from [here](https://www.one-tab.com/)
* Once you have installed it, open up all the pages which you want to group/share in a new window.
* Click on the OneTab icon to collapse them into a list.
* Once you are on the extension's page, click on "More... -> Name this tab group" in the tab group and give it a name. Now it's easy to refer to this in the future.
* Additionally, if you want to share this with someone, click on "Share as web page", you'll get a link which you can then send across.

Obvious security caveats apply. Use this with discretion.

What I would like is for OneTab to offer a premium subscription plan which allows me to do periodic archives of my tab group for backup, and password-protected share of tab groups. Pretty please, OneTab? :)

Originally posted [here](https://gist.github.com/rajki/c9fa459e9ce258460dc1119d33309e98).
Bring in Digital Transformation by Scaling DevOps and Agile Services!
Tags: devops, productivity, agile
Published: 2020-04-22 05:30:14

The Digital Success of your brand lies with how you manage to scale up the development and delivery process for products and services in your organization.


Many big businesses prefer to move towards Agile software development first and then consider moving towards DevOps services considering this to be the key to success in building a solid foundation for initiating their journey of bringing digital transformation. But many times, this move is often seen to be taken care of by small development teams, and as such, the resultant overall impact is limited. In fact, if you roll out this entire transition organization-wide, you can expect significant benefits by revamping the entire process on a larger scale. Definitely it is quite challenging though to do it this way.

 <h2>Agile Way</h2> – You can definitely aim to enhance the efficiency and quality of services and software development using Agile methodology for software development as it provides a collaborative environment for development among cross-functional, self-organizing teams as well as involves feedback from all the employees who are end-users.

<h2>DevOps Way</h2> – On the other hand, DevOps Services bring together IT operations and software development only to cut short the lifecycle of development by delivering high-quality applications continuously.

<h2>Some Useful Tips to Employ for DevOps & Agile Services Together</h2>
Combining both these approaches for software development together with DevOps solutions and Agile, both simultaneously, one can really expect to press the accelerate button to expedite the digital transformation journey that can leave a far greater impact on the development process itself.

 Particularly, this approach is more helpful particularly if it can involve more end-users and multiple projects at the same time. Here are some tips which you can find helpful while you are planning to employ both Agile and DevOps services together for expediting the deliverables.

Read complete article here <a href="https://addwebsolution.com/blog/bring-digital-transformation-scaling-devops-and-agile-services">Bring in Digital Transformation by Scaling DevOps and Agile Services!</a>
I rebuilt my personal portfolio using GatsbyJS, and I'm loving it!
Published: 2020-04-22 04:55:20

It's been about 4 years since I started my project, Resume on the Web, where I created a website that portrays who I am and my ever-changing personality. Every once in a while, I revamp the whole thing using new technologies so that I keep myself updated with the latest and greatest, and also gives me a creative outlet to experiment with new design ideas.

This year, I kicked it up a notch by revamping the design of the old boring two-column resume look, to something a lot more vibrant, responsive and effective. I'll keep my words to a minimum and let the website do the talking :)

**Introducing, the brand-new, Resume on the Web: 
https://amruthpillai.com/**

For those who want the technical deets, this version is built with GatsbyJS, a static-site React framework that I wanted to explore recently, as well as Tailwind CSS for the uber-cool utility classes.

As always, the source code for the project is available on GitHub here: https://github.com/AmruthPillai/ResumeOnTheWeb-Gatsby

Please do let me know if you liked it as much as I enjoyed making it! :)
Reading Snippets [54 => Ruby] 💎
Tags: ruby, beginners, codenewbie, rails
Published: 2020-04-22 04:52:14

Blocks in Ruby (like anonymous functions in JavaScript) do not require a name to operate. 

There are a few differences between blocks and methods in Ruby. While methods can run more than once, a block only runs once. 



<kbd><small><a href="https://www.codecademy.com/courses/learn-ruby/lessons/ruby-data-structures/exercises/iterating-over-multidimensional-arrays">Codecademy Ruby Course</a></small></kbd>
Valid Number
Tags: javascript
Published: 2020-04-22 04:27:54

The valid number problem currently has the lowest acceptance rate of Leetcode at just 14.9%. That must mean it's hard right?

This one reminded me of my Perl days because somehow it's 3 AM and I'm having fun with regular expressions :-)

```js
/**
 * @param {string} s
 * @return {boolean}
 */
var isNumber = function(s) {

  const trimRegex = /(^\s+|\s+$)/g;
  const trimedS = s.replace(trimRegex, '')
  if (trimedS.length == 0) return false;
    
  const validCharsRegex = /[0-9e+-.]/;
  if (![...trimedS].every(e => e.match(validCharsRegex))) return false;
  
  const invalidPatternsRegex = /(^\.e|^\.$|^e.*?|e.+?\.+?|\..+?\.|.+?e$|\d+?[+-]\d.?|[+-]+?\.$|.+?[+-]$|.+?e+?.*?e+?|\+[e+-]+?|\-[e+-]+?|\.[.+-]+?|e\.+?)/gi;
  if (trimedS.match(invalidPatternsRegex)) return false;

  return true;
};
```

Short, and hopefully correct description of the scary regex:
```
const invalidPatternsRegex = /
    (^\.e               -> . at the beginning of string followed by e
    |^\.$               -> only 1 .
    |^e.*?              -> e at the beginning of string followed by any zero or more times
    |e.+?\.+?           -> e 1 or more times followed by . 1 or more times
    |\..+?\.            -> . followed by any 1 or more times followed by .
    |.+?e$              -> any 1 or more times followed by e at the end of string
    |\d+?[+-]\d.?       -> [0-9] 1 or more times followed by either + or - followed by [0-9] 1 or more times
    |[+-]+?\.$          -> either + or - 1 or more times followed by . at the end of string
    |.+?[+-]$           -> any 1 or more times followed by either + or - at the end of string
    |.+?e+?.*?e+?       -> any 1 or more times followed by e 1 or more times followed by any zero or more times followed by e 1 or more times
    |\+[e+-]+?          -> + followed by either e or + or - 1 or more times
    |\-[e+-]+?          -> - followed by either e or + or - 1 or more times
    |\.[.+-]+?          -> . followed by either . or + or - 1 or more times
    |e\.+?              -> e followed by any 1 or more times
    )
    /gi;                -> flags: global and case insensitive
```
// Runtime: 76 ms, faster than 92.92% of JavaScript online submissions for Valid Number.
// Memory Usage: 37.5 MB, less than 12.50% of JavaScript online submissions for Valid Number.
Debug Angular 9 in Chrome console
Tags: angular, webdev
Published: 2020-04-23 01:14:28

---
title: Debug Angular 9 in Chrome console
published: true
date: 2020-04-22 04:00:00 UTC
tags: angular, webdev
canonical_url: https://ajonp.com/blog/debug-angular-9-in-chrome-console
cover_image: https://cdn.sanity.io/images/hfh83o0w/production/abe894ac2fad4b33a2913bcf3d93deee1f0c6b14-1920x1080.png?w=1000&h=420&fit=scale
---

# Debug Angular 9 in Chrome Console

{%youtube H8GrzgQS-6c%}

> These functions are exposed via the global `ng` "namespace" variable automatically when you import from `@angular/core` and run your application in development mode. These functions are not exposed when the application runs in a production mode.

## Chrome Console Utilities

The great part about using the Chrome console is that it gives you access any DOM element that you have selected. For the last item you can get the reference by typing `$0` in the console. Below you will see that you can use the selection tool to easily find the element. Once this is selected you can then use `$0` as it will be the latest in your selection history. You can read further about this in [Console Utilities API Reference](https://developers.google.com/web/tools/chrome-devtools/console/utilities).

 ![Chrome Selection](https://res.cloudinary.com/ajonp/image/upload/v1587580781/ajonp-ajonp-com/blog/debugAngular9/chromeSelection.png)
## Getting the Angular Component reference

Now that we know how to get a DOM reference we can use the Angular `@angular/core/global` utilities, you can find more details here: [https://angular.io/api/core/global#entry-point-exports](https://angular.io/api/core/global#entry-point-exports).

Using `ng.getContext($0)` we can access the angular component instance.

```
// Get this component
let dialogComponent = ng.getContext($0)

// Get parent component
let dialogParentComponent = ng.getOwningComponent($0)
```

## Changing values in the Component

Now that you have a reference to the component using `let dialogComponent = ng.getContext($0)` we can now update the properties within the component. For this example we will change the qty in our recipeIngredient object.

```
dialogComponent.data.recipeIngredient.qty = 5
```

You should also note that you can display the entire component as well incase you are unaware of the structure.

 ![](https://res.cloudinary.com/ajonp/image/upload/v1587581740/ajonp-ajonp-com/blog/debugAngular9/Screen_Shot_2020-04-22_at_2.55.22_PM.png)
## Making Component Update

In order to get the value change to show within the component you must trigger change detection.

```
// Apply change detection
ng.applyChanges(dialogComponent)
```
Host images for FREE on GitHub
Tags: github, hosting, free, hack
Published: 2020-04-22 03:44:36

![](https://cdn-images-1.medium.com/max/2000/1*o7A9ywIcLEByTYdpL16Tlg.png)

Hosting images have always been a tricky part for me. Recently I got the opportunity to write a lot of documentations (ReadMe on GitHub). One thing which was constant with the README.md files — screenshots.
>  A picture is worth 1000 words!

I prefer to add screenshots wherever necessary to be more precise about the steps to be followed. But taking a screenshot and then hosting it on a third party website was too much of a hassle. There were times when I wanted to host images on a free service and use it in apps I was developing. I decided to scratch my own itch and come to a definitive solution once and for all!

## STEP 1: Take a screenshot

Now, this will work with any image. Screenshots are something I am taking as an example. There are two ways you can take a screenshot:

 1. Use the native Print Screen method for your OS

 2. If you are on a browser (Chrome/Firefox) you can use an extension called [LightShot](https://chrome.google.com/webstore/detail/lightshot-screenshot-tool/mbniclmhobmnbdlbpiphghaielnnpgdp?hl=en). With this tool, you can take and save parts of the screenshot i.e. crop the screenshot and save the important part!

---

## STEP 2: Open a GitHub issue

Yes, you read it just right!

If you don’t have a GitHub account, then sign-up for a new account and create a simple repo. I’ll use my [scalable-angular-folder-structure](https://github.com/adityatyagi/scalable-angular-folder-structure) repo from [my GitHub account](https://github.com/adityatyagi).

![*Click on **Issues***](https://cdn-images-1.medium.com/max/2010/1*1QwnsjfFhjqP3HxFVkFDuA.png)

Click on “**Issues**”.

After that, click on “**New Issue**”.

![*Click on New Issue*](https://cdn-images-1.medium.com/max/2004/1*6P8kEPr9mKeoeHxY6Id6dg.png)  

---

## STEP 3: Host it!

Now if you are observant enough (or a observant freak like me), you’ll notice GitHub is giving an open invitation to host images for free!

![](https://cdn-images-1.medium.com/max/2030/1*DUypPhpGZiWhMSw9elOd7Q.png)

The only thing you have to do is Drag and Drop any image/screenshot you want to host! Once you do that, GitHub will be kind enough to host the image/screenshot on its server and provide you with a link!

![*Something like this…*](https://cdn-images-1.medium.com/max/2042/1*gk5W6HtNAb9LDvEndV_2vw.png)

GitHub will give back something like:
```
![sample image](https://user-images.githubusercontent.com/
18363595/79008316-c20bc800-7b7a-11ea-8daa-bf09ec558611.jpg)
```

The link is between the “(“ and “)”.

I just hosted this image on GitHub and I can use the link anywhere! Check it out [here](https://user-images.githubusercontent.com/18363595/79008316-c20bc800-7b7a-11ea-8daa-bf09ec558611.jpg).  

---

## STEP 4: Enjoy and forward this little hack!

So, that’s it. Host all your images for free. If you do like this, do share it with your colleagues in office and all your dev-friends!

***

> Originally posted on my blog: [adityatyagi.com](http://adityatyagi.com/)
TwilioHackathon - Crowdsourcing Emotional Support Helpline
Tags: twiliohackathon, node, voice, firebase
Published: 2020-04-22 03:40:10

[Comment]: # (All of this is placeholder text. Use this format or any other format of your choosing to best describe your project.)

[Reminder]: # (Make sure you've submitted the Twilio CodeExchange agreement: https://ahoy.twilio.com/code-exchange-community)

[Important]: # (By making a submission, you agree to the competition's terms: https://www.twilio.com/legal/twilio-dev-hackathon-terms)

## Idea
Amid the current pandemic outbreak, peoples are forced to stay home to break the chain of transmission. But there are some unfortunate people who don't have anyone at their home to rely for help or emotional support. And also there are some who have limited or no access to the internet at their home like in New Zealand.

## What we built
Think a call center system, but outsourced to and answered by anyone that registered online. Anyone who need someone to talk to will ring a hotline number, the person will be put on queue and wait. The system will ring everyone who are registered and set their status as available online. The first person who pick up will automatically connect to the caller.

## Demo
Give a call to +18557725566 to chat with someone,

OR become that someone who will be ready to receive a call by registering your number at https://chinwag.xyz

> Currently only New Zealand, Malaysia & USA phone number are supported for this demo.

## Link to Code

https://github.com/natsu90/chinwag-twilio

## How we built it
* NodeJS as the backend
* Firebase Cloud Firestore as the database
* Firebase Authentication, at the beginning we're using Twilio SMS API, but we realised it cost you money, in addition of the Voice API.
* Twilio Voice API


## Additional Resources/Info
If you're just started using Twilio, they have this setting called Geographic Permissions to protect from abuse. You have to toggle on the setting yourself for any country you think your user will come from. But this setting is not obviously displayed, so I had been pulling my hair for a few hours. But I'm partly to blame because I don't put a catch block in the code.😬

#### just one of our Hacking & Hustling sessions
![Online Meeting](https://dev-to-uploads.s3.amazonaws.com/i/narpuq7azgyomwabl5dx.png)
Matrix Simulation Using JAVASCRIPT
Tags: javascript, showdev
Published: 2020-04-22 03:36:48

Made a Matrix Simulation using P5.js inspired by great Youtuber "THE CODING TRAIN(Danial Shiffman)".

Link to the code is: https://github.com/Shubham2503/Matrix-Simulation
Link to Live  page: https://shubham2503.github.io/Matrix-Simulation/

![alt text](http://drive.google.com/uc?export=view&id=1NwBHGiQ-O6jKxQvbJb96pIjO5VrASgWc)
Python Microservices, Part 2: Build and Test REST endpoints with Tornado
Tags: tutorial, python, microservices, tornado
Published: 2020-04-22 03:09:55

*Learn to implement Tornado HTTP endpoints as a layer on business logic. Tune it to assist debugging, and write unit and integration tests.*

---

This blog post covers some of the best practices we learned while building microservices powering Slang Lab's platform; how to:

- Design REST endpoints as a separate layer over business logic,
- Implement Tornado HTTP server and service endpoint handlers,
- Use Tornado hooks to control behavior and assist debugging, and
- Write unit and integration tests using Tornado testing infra.

(Based on a PyCon India 2019 tutorial.) 

[Continue reading »](https://www.ml4devs.com/articles/python-microservices-tornado-02-rest-unit-integration-tests/)
#WebDev on web.dev - Author Page should have more information about the author #2274
Tags: webdev, javascript, opensource, frontend
Published: 2020-04-22 02:53:50

{% youtube DZlsb9EDhAc %}

Hey y'all, my name is Michael and I'm one of the engineers who works on Google's [web.dev](https://web.dev/) site.

On April 22 at 12 PM PST I'll be doing some coding of the site live on YouTube and would love for you to join in.

We'll look into a [GitHub issue on web.dev](https://github.com/GoogleChrome/web.dev/issues/2274) where we're asked to add more details to individual author pages, such as [https://web.dev/authors/philipwalton/](https://web.dev/authors/philipwalton/), in order to display more data about the author. Like links to their configured meta data (like Github, Twitter etc).

[(Join the chat here)](https://youtu.be/DZlsb9EDhAc)

###### (There are audio issues until the 16:00 mark, sorry!)
Where do you put your stickers?
Tags: watercooler, discuss
Published: 2020-04-22 02:08:26

Hello !

I have a lot of stickers but I don't use them because I don't want to stick them on my laptop to keep it nice and clean looking.

It might be interesting to share where you put your stickers so we can all get inspired, also don't hesitate to post pictures !

So i'm curious, Where do you put your stickers ?