teleren/devto huggingface dataset:
Passing serialized C# object in JSON to Razor Page
Tags: csharp, dotnet, json, razor
Published: 2018-08-24 16:18:50

---
title: Passing serialized C# object in JSON to Razor Page
published: true
description: 
tags: csharp, dotnet, json, razor
---

I was working in a way to convey a dataset coming from the database to Google Chart JavaScript framework, using C# and .NET Core MVC framework under the Razor Page.


The first step was easy, a trivial query to the database in order to get the data, but Google Chart has their special way to handle a dataset and to realize a simple conversion from POCO was not sufficient, then I wrote a converter:

```csharp
private IEnumerable<Array> poco2GoogleChartDataset(IEnumerable<MyData> dataset)
{
    List<Array> googleDataset = new List<Array>();
    foreach (MyData data in dataset) {
        Array arr = new object[] { data.Label, data.Value };
        googleDataset.Add(arr);
    }
    return googleDataset.ToList();
}
```

The result of this conversion was serialized to JSON using the `Newtonsoft.Json` assembly:

```csharp
// Top of the class
using Newtonsoft.Json;

// Hidden for brevity
ReportJson = JsonConvert.SerializeObject(poco2GoogleChartDataset(myDataset));
```

On the other hand, in Razor Page, I need to pass this JSON object to a JavaScript variable. If you just pass the model value using a simple Razor syntax, it will not work because in the Razor Render process will pass the value through an HTML encoding. Like this:

```csharp
// Razor Page
...
@section Scripts {
    function drawChart() {
        var jsonDataset = @Model.ReportJson;
        ...
    }
...
}
```
```cmd
jsonDataset result:
[[\&#x22;Label\&#x22;, value]]
```

To bypass the HTML encoding wrap the model variable into the HtmlHelper directive with their `Raw` method. This way:

```csharp
// Razor Page
...
@section Scripts {
    function drawChart() {
        var jsonDataset = @Html.Raw(Model.ReportJson);
        ...
    }
...
}

```

Now the value result will be a JSON object, ready to be used in Google Chart framework.

I suffered hours to achieve this comprehension, in part because I do not master Razor syntax, nor ASP.NET Core MVC, neither the C# 😂

That's it!
SQL Server’s [N]VARCHAR(MAX) and How to Wield It
Tags: sqlserver, datatypes, sql
Published: 2018-08-30 14:25:32

---
title: SQL Server’s [N]VARCHAR(MAX) and How to Wield It
published: true
tags: SQL Server,Data Types,SQL
canonical_url: 
---

[N]VARCHAR(MAX) is a data type that was created to replace [N]TEXT.  Depending on how many characters you store in this data type, it will react differently to its surroundings. It might be just what you needed or it might be your worst nightmare, so choose wisely. Here’s a run down on this data type. What … [Continue reading SQL Server’s [N]VARCHAR(MAX) and How to Wield It](https://randallsims.wordpress.com/2018/08/24/sql-servers-nvarcharmax-and-how-to-wield-it/)
Dev.to made my day :)
Tags: devto, offline, beginners, serviceworker
Published: 2018-08-24 14:42:05

---
title: Dev.to made my day :)
published: true
description: Dev.to's cool offline page
tags: devto, offline, beginners, serviceworker
---

So I just decided to start writing technical articles to help me get a deeper understanding of programming concepts, and also help fellow beginners like myself in the process. And where better to do that than Dev.to 😁. 

As I was searching around the site for some inspiration though, I lost my connection, and I have to say, the offline page is really cool. 

![offline-page](https://thepracticaldev.s3.amazonaws.com/i/ez266x2sh37654m1k68s.png)

Having just recently learnt about service workers, I can really appreciate how useful it was. Instead of feeling frustrated over suddenly going offline, (mind you, my WiFi bar was full -- or, LieFi, I should say), the unexpected witty message made me feel better than if I had continued my search 😅.

This just goes to show that no connection shouldn't equal to no content, or boring content. I feel like as coders, we don't get to experience the other side as much so we might not appreciate what that extra effort to turn a seemingly bad situation into an uplifting one means.

Whoever did the offline page, it was a good idea. I'm glad I came across it. It gave me an idea for my first Dev.to post so... Hello World! 🎉

Here's to many more 🥂. I'll go play outside now.
Latency vs Throughput
Tags: latency, throughput, networking, internet
Published: 2018-08-24 13:28:10

---
title: Latency vs Throughput
published: true
description: Latency vs Throughput
tags: Latency, Throughput, Networking, Internet
---


![From CMU Parallel Computer Architecture and Programming Course](https://thepracticaldev.s3.amazonaws.com/i/qt7fwxo5kvboxuhzjmlb.jpeg)


Latency: Elapsed time of an event.

eg. Walking from point A to B takes one minute, the latency is one minute.

Throughput: The number of events that can be executed per unit of time.

eg. Bandwidth is a measure of throughput.

We can increase bandwidth to improve throughput but it wont improve latency.

Take the RPC case — There are two components to latency of message communication in a distributed system, the first component is the hardware overhead and the second component is the software overhead.

The hardware overhead is dependent on how the network is interfaced with the computer, this is managed mostly by the network controller.

How do we reduce the software overhead? That’s a question every product owner needs to ask themselves to improve their product.

If you liked this, you'll like my other posts!
Original post here: https://medium.com/@nbosco/latency-vs-throughput-d7a4459b5cdb
Wanna play with GraphQL on an existing database
Tags: help, graphql, postgres, vue
Published: 2018-08-24 11:07:40

---
title: Wanna play with GraphQL on an existing database
published: true
tags: help, graphql, postgresql, vue
---

I spend some time earlier this year building a REST-API for a personal app project (Vue in the frontend, Python + Flask + Postgres for the backend API). It is pretty complex and works fine. My PostgreSQL database if full of data now and all tables are working well together.

But lately, I've been having the itch to try out **GraphQL**... just for fun. What would you guys recommend? My app is using Vue.

[PostGraphile](https://www.graphile.org/postgraphile/)? seems easy to start with, but will it be sustainable in the long run? [Apollo](https://akryum.github.io/vue-apollo/)? seems like the "standard" pair to Vue?

Anyone ever did this, converting a REST API to a GraphQL API?

Will it really be fun? 🤔

Thanks!
best,
Daniel
Script your Yakuake with default tabs
Tags: kde, linux
Published: 2018-08-28 11:22:45

---
title: Script your Yakuake with default tabs
published: true
tags: KDE, linux
canonical_url: https://daniele.tech/2018/08/script-your-yakuake-with-default-tabs/
---

For people like me, the terminal is the most important tool. The problem is that I usually open different tabs and always to the same path, so after year became

The post [Script your Yakuake with default tabs](https://daniele.tech/2018/08/script-your-yakuake-with-default-tabs/) appeared first on [Daniele Mte90 Scasciafratte](https://daniele.tech/eng).
React-Rails app - How to validate uniqueness?
Tags: react, rails, validation, help
Published: 2018-08-24 09:40:43

---
title: React-Rails app - How to validate uniqueness?
published: true
description: 
tags: React, Rails, validation, help
---

Hi there, 
This is my first post. Please let m know if I'm doing something wrong. I am Ruby on Rails deveoloper which start to useing React form Model View and Ract-Native. 

I am building app to mangaing warehouse. It is already done and in production (created with Rails, Turbolinks and jQery). Now I would like to change this app to React single page app with react-native mobile version.

I knew basics about, React, Redux, React-Native now and I started changing process. 

I have simple react-rails app created. I created a form in react and db in rails and I would like to crate record only if his name is unique. 

I connect with rails through axios and when I try to create record with not unique name, axios send back to react action validation error.

// ACTION
export const startAddingLocation = ( name ) => {  
  
  return(dispatch) => {    
    const location = { name }    
    return axios.post( '/api/locations', { location }) 
      .then(response => {
        if(response.data['status'] === 'SUCCESS'){
          const id = response.data.data.id;     
          const created_at = response.data.data.created_at;   
          dispatch(addLocation({id, ...location, created_at}));                    
        }
        else{
          dispatch(nameChangedError(name, response.data['message']));
        } 
      }).catch(error => {
        dispatch(nameChangedError(name, error+"Cannot save in DB"))
      });
  }
}

I need to find a way to not redirect from from when have a validation error. What is the best route to do this? I tried to redirect when action nameChangedError fill up error in redux but this is asynch action and when when I am checking error in component it still empty. Sould I redirect somehow from action?

//COMPONENT ON SUBMIT
  onButtonPress() {  
    const { name, error } = this.props;    
    if(name && name.length < 30){      
      this.props.startAddingLocation(name);      
       if(!error){
          this.props.history.push('/locations');
       }
    }else{
      this.props.nameChangedError(name, "Incorrect value")
    }


Thanks!
Diary - 2018.08.24
Tags: career, productivity, learning, journey
Published: 2018-08-24 09:05:44

---
title: Diary - 2018.08.24
published: true
tags: career, productivity, learning, journey
series: Diary
---

I know the Basics of Regex, today I learnt something new:

When copying code, I always had the urge to change from this:

`.then(function(response) {`

to this:

`.then((response) => {`

So today, I just built a solution.


To get this result, using Visual Studio Code,
hit `CMD + H`, then `Alt + R`,
to open the Replace Window and include Regex.

First Box: `function\((.*)\)\s*{`
Second Box: `($1) => {`

Explanation:
```
function => the word "function"
\( => escaped (
( => open capturing group
.* => zero or more times any single character => captured group
) => close capturing group
\) => escaped )
\s* => zero or more times whitespace
{ => {
```

```
($1) => use the the captured group
=> { => => {
```
Friday Blast #50
Tags: fridayblast, links, post
Published: 2019-01-20 15:26:34

---
title: Friday Blast #50
published: true
tags: friday_blast,links,post
canonical_url: https://horia141.com/friday-blast-50.html
series: "Friday Blast"
---

[Distributions of zeros of the Riemann zeta (2018)](https://www.johndcook.com/blog/2018/08/23/riemann-zeta-zeros/) - mostly for the nice view from Quanta of the various places where a certain distribution appears - zeros of Riemann’s zeta function, spaces between eigenvalues of random matrices, distances between cells in chicken cells in chicken’s eyes etc.

[An illustrated proof of the CAP theorem (2014)](https://mwhittaker.github.io/blog/an_illustrated_proof_of_the_cap_theorem/) - the CAP classification is a (somewhat misused) workhorse of describing distributed systems. But it’s also a theorem in it’s own right, with some very precise specifications. This article delves a bit into that, and gives an intuition for the proof.

[Lamport’s logical clocks (2015)](https://mwhittaker.github.io/blog/lamports_logical_clocks/) - a brief overview of Lamport’s famous “Time, Clocks, and the Ordering of Events in a Distributed System” paper (how famous? 11k citations worth). Now the paper itself is easy to follow, and the article is almost as big as it. Still, the graphics are neat and the explanation a bit bigger. The notion of limited ordering in distributed systems is very important. Vector clocks are very often encountered in the design of _bigger systems_ (most famously Dynamo), and they’re improvements to Lamport clocks.

[Visualizing linearlizability (2015)](https://mwhittaker.github.io/blog/visualizing_linearizability/) - I’m not _that_ familiar with the various consistency models, but linearlizability is one of the important ones, so any intuition about it is good. Indeed the paper seems _terse_, but the visualisations _do_ help - especially wrt the “equivalence” relation on histories.

[Cybernetics - a cyborg-free introduction (2018)](http://blog.grio.com/2018/04/cybernetics-a-cyborg-free-introduction.html) - cybernetics is a strange discipline - big for about 30 years from the _40s_ to the _70s_, it is quite obscure now. The _good stuff_ has moved to other disciplines more or less. This article is a very quick overview of the history and objectives of the folks working in the field. I searched a bit to find a more definitive answer to “what happened to cybernetics?”. I think [Asa Sherill on Quora](https://www.quora.com/Is-cybernetics-an-active-field-of-research-What-are-some-recent-developments) offered a good take - the _name changed_. Cybernetics is just a _futurist_ name for things like control theory, AI, robotics etc.
Developer whimsy: Llamas in Pajamas
Tags: discuss
Published: 2018-08-24 06:34:46

---
title: Developer whimsy: Llamas in Pajamas
published: true
description: Have you ever left something silly or fun in some code. I want to hear what your llamas in pajamas are.
tags: discuss
---

I love how developers sometimes slip fun, amusing or whimsical easter eggs into software. I was just taken by how the Ruby application server Puma's current version has a codename of "Llamas in Pajamas".


![When starting a Rails app, Puma prints out its current version's codename: "Llamas in Pajamas"](https://thepracticaldev.s3.amazonaws.com/i/zbbsut03givp29cvm6n7.png)

What are your favourite whimsical bonuses you've found in code? Have you slipped something fun into a project that left you giggling while you waited for someone else to find it? What are your favourite llamas in pajamas?
Where do Software Architects, CTOs, and other Senior+ developers hang out?
Tags: question, discuss
Published: 2018-08-24 05:38:01

---
title: Where do Software Architects, CTOs, and other Senior+ developers hang out?
published: true
description: 
tags: question, discuss
---

If you are a senior developer or above senior level what blogs do you read, what communities are you a part of, how do you get to know new people? Do you chat online anywhere?

Disclaimer: This would contribute and help me a lot with my market research
From Angular to React
Tags: discuss, typescript, react, angular
Published: 2018-08-24 02:54:43

---
title: From Angular to React
published: true
description: Discussing some pitfalls of coding react apps in TypeScript
tags: discuss, typescript, react, angular
---

I've spent the past three years growing up with Angular and TypeScript. I've never worked with a language that saw so many changes in a year, from adding additional types to changing the way we think about type inference. As difficult as it was to keep up at times, we eventually became one.

Now that my career is on the move, I've been exploring React. I jumped right in with a few projects built on create-react-app, and I noticed two thigs right away. 

First, I have a decent handle on ES6/7, and I can thank TypeScript for that. In fact, the last time I used JavaScript for any length of time was … before jQuery hit the scene, so I've never even used lodash or underscore.js. Let's just keep that bit between us!

Second, types are awesome. That is all. React's PropTypes can fill that gap, and I'm sure there is a tool for my favorite editor that will help straighten things out if I start mismatching types.

I've been having a blast with React. Excuse my terrible analogy, but the more time I spend with it, the Angular feels like piloting a 747 (_don't they land themselves these days?_), and React feels like taking a motorcycle on a windy back road. They're both capable vehicles, but connection between man and machine feels a lot stronger without the huge framework in the way.

What was your experience if you traveled in this direction? What are some pitfalls to developing React apps with TypeScript?
Recovering Rockstar Dev, ask me anything
Tags: ama, softskills, team
Published: 2018-08-24 02:23:32

---
title: Recovering Rockstar Dev, ask me anything
published: true
description: I'm a recovering rockstar developer, and I really would like you to ask me anything! Yes, I will be taking some blame for that one issue you had with rockstar devs
tags: #ama, #softskills, #team
---

https://insights.dice.com/2018/08/23/5-reasons-avoid-hiring-rockstar-developers/

Check out this article if you want some perspective on what a rockstar dev is. Then ask me anything!

I'm a recovering rockstar developer, and I really would like you to ask me anything! Yes, I will be taking some blame for that one issue you had with rockstar devs that one time, I've probably done that before, sorry!
How to Build a REST API using Node, Express, and Mongo
Tags: node, express, mongodb, video
Published: 2018-08-24 00:11:12

---
title: How to Build a REST API using Node, Express, and Mongo
published: true
description: A REST API is an integral component of a web application. You don't need to be an expert backend developer to make your own. In this workshop, we will walk through the basic building blocks of creating your own REST API using Node.js, Express, and MongoDB.
tags: node,express,mongo,video
---

A REST API is an integral component of a web application. You don't need to be an expert backend developer to make your own. In this workshop, we will walk through the basic building blocks of creating your own REST API using Node.js, Express, and MongoDB.

**Pre-requisites** 
If you would like to follow along, please download and install the following:

- [Node.js (LTS 8.x)](https://nodejs.org/en/)
- [Robo3T](https://robomongo.org/download) (Lightweight GUI for MongoDB)
- Create a free MongoDB instance on [mLab](https://mlab.com/)
- [Insomnia REST Client](https://insomnia.rest/)
- IDE Suggestions: [Visual Studio Code](https://code.visualstudio.com/), [Atom](https://atom.io/), [WebStorm](https://www.jetbrains.com/webstorm/) (Trial/Paid)

**Links**
- [Youtube Video](https://youtu.be/egeHq-lYyxo)
- [Github Repo](https://github.com/theoutlander/rest-api-workshop)
- [Slide Deck](https://docs.google.com/presentation/d/1VSlo9JEsoVjNNH4DqOJtSWInKIis5p39lmHvAcLifSw/)
- [Workshop link on dev.to](https://dev.to/events/7-workshop-build-a-rest-api-with-node-express--mongo-03-22-2018)

#### If this video was helpful, ❤️ it and [subscribe to my YouTube channel](https://www.youtube.com/channel/UClCm-WAOgN6XLwCpefSVezg?sub_confirmation=1).

---

{% link https://dev.to/theoutlander/introduction-to-mongoose-for-mongodb--3c30 %}

---
How To Change a Git Repo's Authentication Protocol
Tags: git
Published: 2020-09-24 03:46:36

---
title: How To Change a Git Repo's Authentication Protocol
published: true
date: 2018-08-24 00:00:00 UTC
tags: git
canonical_url: https://nickymarino.com/2018/08/24/change-git-repo-auth-protocol/
---

*This post was originally published on [my website](https://nickymarino.com). Check it out for more awesome content!*

## HTTPS to SSH Key

Often I need to change a git repository to use an SSH key instead of my username and password to authenticate with the remote server. In order to do so, type the following in the repository’s folder on your machine:

```
$ git config remote.origin.url git@github.com:username/repository_name.git

```

(Make sure to include the `.git` at the end of the repository name.)

## SSH Key to HTTPS

In order to change it to do the reverse, type:

```
$ git config remote.origin.url https://github.com/username/repository

```
Crazy Developer Stories/Bugs
Tags: discuss
Published: 2018-08-21 03:23:28

---
title: Crazy Developer Stories/Bugs
published: true
description: 
tags: #discussion
---

Hello all, I'd like to see some of the game developers of this community tell some of their craziest stories/bug fixes.

I'll start the list off, I was creating a GameState management structure within my project and wanted to see if I could create nested GameState managers(not the best idea in the world). The application would launch into the `MainMenu`, go to `SinglePlayer`, which would then go into the `PlayingScreen`. Now, `PlayingScreen` had another GameState manager inside of it and worked exactly like the main application's manager. On entry it would show the `Loading` screen which had an `ImGui` progress bar that was updated like this:

```cpp
static float fraction = 0.0f;

ImGui::ProgressBar(fraction, ImVec2(100, 20));

fraction += 0.001f;

if(fraction > 1.0f )
{
    // This sets Playing as the current state
    g_Client->getPlayingScreen()->setState("playing")
}
```

Some of you might already see the problem that I would have in changing the state of the `PlayingScreen` in this fashion. `Playing` had a button that told `g_Client` to go exit `PlayingScreen` and go directly back to `SinglePlayer`. When I did this and went back into `PlayingScreen` something was wrong...The `Loading` didn't show!

I thought that the `std::vector` that held the states wasn't clearing and was messing with the re-entry of `PlayingScreen`. That proved to be a long day of frustration and disappointment as I poured over `std::vector` docs online trying to get it to clear properly.

Finally, I was screen-sharing with one of my friends using Discord and he noticed a stutter going from `SinglePlayer` to the `Playing` state inside of `PlayingScreen`. So I investigated a little further and realized to my relief and now apparent idiocy that **I never reset** `fraction` when switching to `Playing`!!!

Here was the final code that fixed the entire problem in less than 30 seconds:

```cpp
static float fraction = 0.0f;

ImGui::ProgressBar(fraction, ImVec2(100, 20));

fraction += 0.001f;

if(fraction > 1.0f )
{
    // This sets Playing as the current state
    g_Client->getPlayingScreen()->setState("playing")
    fraction = 0.0f; // <-- Note this part
}
```

I hope you have a similar story, and if not, please comment on someone else's. Have a great day/night, everyone!
The best way to structure React Native git project? 
Tags: discuss, reactnative, git, help
Published: 2018-08-23 22:39:24

---
title: The best way to structure React Native git project? 
published: true
tags: discuss,react native,git,help
---

Hi devs, for the last couple weeks, I was working on a react native project and at this point, I think I need to think seriously about the best ways to structure my git repo especially after implementing a circleCi for releasing App.

As you know we choose the react native to build a cross-platform app ( android and ios ) so we have multiple build types  

* Beta version for android ( deployed on fabric.io)
* Beta and Prod  version for IOS ( using testflight) 
* Prod version for android ( google play)

CircleCI can run builds only based on the branch.

I am searching for the best ways to structure my git repo ( branches ) and git workflows.
Git merge specific file from another branch
Tags: git, gitmerge, gitbranch
Published: 2018-08-23 21:04:12

---
title: Git merge specific file from another branch
published: true
description: 
tags: git, git merge, git branch
---

There are two teams working on the same project and they realize a common problem that was already resolved by one side, but the status of work in each branch is `in progress` and to make a merge can be unsafe.

> How to solve this problem?

There is a safe solution: *merge a specific file from another branch.* And there is the steps:

```cmd
$ git checkout <another-branch> <path-to-file> [<one-more-file> ...]
$ git status
$ git commit -m "'Merge' specific file from '<another-branch>'"
```

That's it!

[Here is a more detailed approach.](http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/)