fabiochiu/medium-articles huggingface dataset:
Deploying an R Shiny app on Heroku free tier
By: Tim M. Schendzielorz
Tags: Web App Development, Heroku, Shiny, R, Continuous Deployment

This article will show you

What Heroku is and what you can get for free

How to containerize a Shiny app with Docker

How to set up GitHub to automatically deploy to Heroku

How to set up a custom domain name for your deployed app

Heroku free tier

Heroku (which I am not affiliated with) is a cloud platform service that offers an intuitive way to deploy and manage enterprise grade web apps. It enables easy auto scaling of your apps, however not on Free (and Hobby) tier we will use here. Apps can be managed via CLI or the Heroku dashboard.

Heroku has a plethora of addons, e.g. for logging or messaging. Additionally it provides services you can co-deploy with your apps like databases with just a few clicks or lines in the CLI or in a deploy instruction file, the `heroku.yml`.

With the new heroku.yml file it is possible to deploy multi container apps. Here however we will not use a heroku.yml as the deployment will be managed by GitHub Actions.

Heroku apps run in “dynos” which are containers running on AWS. With the free tier you can run apps in max 5 dynos (100 if you verify) with 512 MB memory each and get 550 (1000 if you verify) dyno hours. On free tier your apps go to “sleep mode” after 30 min and need to be woken up, which usually means your load time on the first request will be 10–30s longer. This behavior saves your free dyno hours. If you want to circumvent this, add a GET Request to your app so that the app will call itself in intervals < 30 min. We`ll see how long this will be possible.

What I like about the Heroku pricing model is that it is per app. That means you can upgrade a single app after testing it on free tier. On paid tiers you get various benefits, like auto scaling, unlimited dyno hours and SSL encryption with custom domains.
Using carrierwave and fog to store images on S3 before deploying to Heroku
By: Cecilia Benítez
Tags: Heroku, Carrierwave, S3 Bucket, Ruby on Rails

Sometimes we need to upload files to the server, whenever this happens we can use the “carrierwave” gem to help us make everything easier. I recommend choosing the s3 as our server, deploy the app to Heroku as I will show you below.

Ruby on Rails

Create an AWS account

Don’t forget you will need a credit card for this step.

aws account

Install “ImageMagick”

if you are on Mac or Linux, run the command:

$ brew install imagemagick

if you are on windows you can click this download link

The reason why we can’t install it by gem install command is that ImageMagick is written in C, not Ruby.

If you want to use ImageMagick, you should install it before installing carrier-wave and mini_magick to prevent some errors.

gem 'carrierwave'

gem 'mini_magick'

gem 'fog-aws'

The fog-aws gem will help us upload the file to s3.
Week 9 @ Encora Academy (Build Something From Scratch)
By: Uriel Martinez
Tags: Encora, Heroku, Nodejs, Internships

In the ninth week at Encora Academy we delivered the final product of this phase in which we were working for the last month.

This week I learned a lot from the beginning. On Monday, I was dealing with a dependencies issue that I installed locally, and when I tried to upload the changes into Github, my teammates couldn’t run my changes, so I deleted my project locally, and when I tried to run it, again, it threw me an error that I couldn’t identify, so I went to the internet, and copy the first thing that I found because I was desperate to solve the issue, and the result was a tragedy. I deleted all my files on my computer with the rm command I don’t know how…

At first, I wanted to cry because I lost a lot of work that I’ve been doing for the past months, and also the code that I had written in my IDE. Then I realized that I couldn’t recover anything, so I just moved on. I just started at zero and try to recover as soon as possible.

The following days, it was just about finishing everything on the project, making sure that everything worked well before deployment. I finished the notification system, which we managed sending emails for appointments, for registers, for appointment cancelations, and so on.

By Wednesday, we started deploying our project. We chose Heroku, which was a whole new thing for me. I learned the deploying process and the problems that come with it.

The next day, we faced with compatibility issues, the web app doesn’t work well with iOS devices because they manage calendars in a different format, as well as some other visual details.

By Friday, we had our last demo, where everything went well, although we did it locally.

Then we discovered some other details, that if you enter the app through the HTTP protocol instead of HTTPS, you couldn’t log in for some reason. And lastly, the thing that we found was that we have to keep in mind that servers have to default UTC, so we have to code keeping this in mind.

Conclusion

This week was tough. I learned by the bad way that I have to be careful of what commands I put in my computer and to read well before I do anything. I learned a lot about technical issues from Nodejs and its promises to deployment tools, but where I learned most was from my teammates. Everybody was always in their best disposition to help each other. I learned a lot about git and Github thanks to them and how to be for each other. This phase was very special to me, and I’m really looking forward to see what comes in the next phases.
Discovery, a space game story act 1
By: Antoine P.
Tags: Servers, Game Development, Heroku, Optimization

Select a provider to host the game

Since I’ve discovered Heroku I’ve used it intensively, checked the possibilities of their services, checked how much it cost to run a qualitative service with backups and many other cool tools like CI etc...

So, why have I picked a service which cost a lot of money compared to many other services or self hosted solutions?

Heroku, in fact, don’t cost that much. Actually, we don’t have DevOPS and wont spend much resources into those tasks, then i can manage our 10 apps painlessly. And you know, pain is time, time is money :) Heroku offers a real environment which cannot be recreated with our actual fees. In fact we spend around 150$/month which allow us to perform many things, more than anything we’ll be able to do for this price without spending too much time on it.

Those two reasons can be easily dropped away, but I’ve a main interest in using Heroku instead of a self hosted solution: The Dyno restrictions

If you never used Heroku before, you have to know that Heroku consume your cash on a usage basis. They split resources into Dyno which are basically 1 thread + 512MB RAM.

And it’s incredibly low to run a game server with a lot of players on it. It forced us to enhance all our components to avoid high RAM usage and load average.

Our first ever game server version, using most popular libraries, consumed around 20MB RAM for each online player. This were completely insane. At this time I’ve understood the real cost of our server.

On a dedicated server with 64GB of RAM and 16 threads this version will be able to manage around 3k players, which is clearly not enough. This kind of server at OVH costs around 130€ excluding taxes.

Our first benchmarks (for each online player):

16MB to 20MB ram usage

CPU load average + 0.45%

Our new benchmark (still for each online player):

0.02MB ram usage

CPU load average never change significantly

The next article will expose which was the first component to leave our stack away, which dropped our RAM usage significantly.
Minimum system architecture for new product launch
By: Hau Vo Phuoc
Tags: Startup, Software Architecture, Ghost Blog, Heroku, Amazon Web Services

Which is needing for your product system architecture in the very early stage.

Photo by Fotis Fotopoulos on Unsplash

As a technical founder or a technical architecture for your startup, you usually struggle to find what is needing for your product system architecture in the very early stage.

Based on my experience, we should choose as much simple as we can because, in a very early stage, we would like to test the product idea so we shouldn’t take much time to choose the perfect stack. Actually, in startup growing life, our system architecture will be rebuilt many times.

So the simple stack will be

Hosting and database should be on cloud (Amazon web services, Microsoft Azure, Google Cloud, etc). Because they can be scaled with just one click and support monitoring as well.

A monolithic backend. We can manage it easier than a micro-service backend.

A mobile app with React Native or Flutter if your product requires the mobile app in both iOS & Android platforms.

A single page application with VueJS/ReactJS/AngularJS if your product requires.

A landing page using a web design tool such as Unbounce, Webflow, etc

A blog site by using Ghost Basic that will cost only $29/month. Or you can use Medium.

With this stack, you can grow your MAU from 0 to 300,000 without any problems. After that when you get funding, you can scale the system or rebuild.
Heroku, Godaddy, SSL certificate, not secure, https, help… I have your fix!
Tags: Godaddy, Ssl, Heroku, Bootstrapping, Https

In comes cloudflare! It is free.

It isn’t perfect but it works.

How the f*ck is something new meant to help?

This was my reaction first.

Well GoDaddy demands you have an A record that is an IP.

Cloudflare doesn’t.

It allows you to set up specific CNAME rules easily. Also Cloudflare easily routes all requests to HTTPS. And it has a good amount of onboarding and community panels.

I would fully, fully recommend.

Think of GoDaddy is the shop you get the domain from, and Cloudflare is the trophy cabinet.

What to do?

Sign up and go through the welcome screens.
Implement LINE login with Angular project
By: Porkaew Jarusdamrongwat
Tags: Heroku, Liff, Line, Github, Angular

Create new app in Heroku

go to https://dashboard.heroku.com/apps

create new app

we will connect Heroku with GitHub search repository name then click connect

Automatic deploys is when you push code into selected branch so heroku will deploy your application automatically click on Enable Automatic Deploys

Manual deploy is you must click Deploy Branch button then Heroku with deploy your application
ROSDING #3
Tags: Rosling, Mern, Heroku, React

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
MongoDB: Migrating from mLab to Atlas
By: Edward Krueger
Tags: Heroku, Database, Towards Data Science, Mongodb, Editors Pick

In a previous article, we discussed how to detach a mLab database from a Heroku deployment. We did this to buy us some time to develop a more permanent solution for our MongoDB app. Check out that work below! Hopefully, you've detached by now. If you missed the deadline, mongo says you can still do a password reset. However, we have had no luck with this as the link is broken.

MongoDB bought mLab in 2018 and has decided to end the service on Nov 10th, 2020. This is an effort to get users to migrate databases to MongoDB Atlas, which we will cover here.

Mongo provided a guide in the email they sent us; however, we will not follow it in this article. Our methods here will give you more options for migration down the line.

We are going to use Google Cloud shell to migrate a database from mLab to Atlas. To get started in this guide, we will need a free GCP account. Using cloud shell will be easier than doing the process locally but is not necessary.

Migration Guide

Before we begin, we will need access to MongoDB Altas.

Make an account on Mongo.com to use their free service.

After you create an account, name your project and select language preference.

Getting Started with the Free cluster

We are going to use the free plan for this article.

Altas Cluster Tiers

Select the cloud provider and region you use. Regardless of selection, this will not show up in your projects. You should pick your cloud and region for low latency. These selections determine where your Atlas DB will be spun up.

Cloud provider selection

Lastly, deploy the cluster!

Now we have an AtlasDB instance ready to go.

2. Install Mongo tools

Now we will use Google Cloud shell to set up a mongo client and some mongo tools we will need for our migration. You may need to set up a free account with them if you haven't already.

We have written a shell script to get the tools for you! Note that these are versioned for Debian 10. This shell script will be nice to reuse when we need to use mongo shell as it adds the files to a location that does not persist.

This will work on Debian 9 and 10. If you are running another version of Linux, you can find more info in Mongo’s installation instructions.

Cloud Shell Terminal

Once you have the terminal open, clone the repo with the following command.

git clone https://github.com/edkrueger/download-mongo-shell-tools.git

Install the MongoDB tools by running the shell script.
Ultimate 2020 Django on Heroku deploy guide
By: Matej Meglic
Tags: Coding, Prototyping, Heroku, Hacking, Django

Photo by Anna Shvets from Pexels

A step-by-step guide on how to quickly prototype and showcase your Django apps with a free-tier Heroku package

Prologue:

I don’t really consider myself a developer, but a mere enthusiast. I found Django earlier in 2020 and used it in a couple of prototype projects that never saw the light of day. I saw the potential of a front-end/back-end combo I loved the possibility of moving past vanillaJS/React+Netlify pages that I was creating. I lacked backend, database and more versatility and Django provided.

I found it very non-trivial to deploy to Heroku and I didn’t find any good step-by-step beginners tutorials and spent multiple hours debugging errors and trying to make up my mind on Stack overflow.

As I was struggling with these twice, following a great youtube tutorial, I decided to “hack” my way into making publicly-available notes on the matter or how to quickly set up projects so that it can be exhibited for initial feedback with no upfront maintenance costs.

Disclaimer: this was written and works as described in November 2020. Some likely mistakes or steps can or should be optimized — I concatenated some of the code and didn’t split it into obvious functionality steps as this is meant to be hacky prototyping, not explaining what every action, bit, and piece of code does.

The final project as deployed is available at GitHub, but it will take more than c/p to make it run on Heroku.

Assumptions:

GitHub account GitHub CLI installed GitHub CLI login process completed Heroku account Heroku CLI installed Heroku CLI login process completed Node.js/npm installed Code editor installed (in my case VS Code) Python installed Django installed pipenv installed

Pre-process (make this proper):

Your environment is all set, now you need to create a Django app. I extended the app past the point of initial index.html to include a model so that I was able to simulate a database migration and admin panel as well.

1. create a new git repository on GitHub

2. django-admin startproject djangoheroku ← that is my project name

3. cd ./REPONAME ← jump in the folder

4. pipenv shell ← installs pipenv virtual environment in your project

5. pipenv install Django

6. python manage.py startapp polls ←that is my app name

7. git init

8. git add --all

9. git commit -m “Initial commit”

10. git remote add origin GITHUB CLONE LINK

11. git push -u origin master

12. python manage.py runserver ← initiate localhost

13. Check http://127.0.0.1:8000/
Deploy Laravel Project On Heroku width Database
Tags: Laravel, Heroku, Laravel Framework, Laravel Development, Herokuapp

In this small tutorial, I will guide you on how to deploy Laravel application to the Heroku. Heroku Cloud Application Platform is a Platform as a Service (PaaS) that enables developers to run, build, and operate applications entirely in a cloud.

Heroku is a public PaaS (Platform as a Service) provider that makes it easy to deploy applications written using several technology stacks at no cost.

Steps to Deploy Laravel Project On Heroku:
ELI5: Heroku
By: Madison Stankevich
Tags: Software Development, Heroku, Eli5, Paas

Let’s dig a little further by dissecting the product definition found on Heroku’s website.

“Heroku is a cloud platform that lets companies build, deliver, monitor and scale apps” -heroku.com

Strip that sentence down to the bare minimum and you get: “Heroku is a platform”

So, what does this mean? In this case, a platform is a single place where a developer can perform multiple actions related to keeping their website up and running, while not having to worry about the underlying infrastructure.

Common actions might include:

Uploading/updating code (build/deliver)

Confirming code is not broken (build/test)

Determining how many machines should be dedicated to the website (scale)

Identifying errors that are happening live on the site (monitor)

Part of this service is simplifying the process a developer needs to follow in order to get their code from their local development environment to a live site.

Let’s revisit our pared down definition and build upon it… “Heroku is a cloud platform”

If you are unfamiliar with the concept of the cloud, it is essentially the idea that software companies do not have to own their own physical machines in order to run software. The idea of renting a physical machine (or a portion of a physical machine) is the concept behind cloud services. To tie the cloud into the physical world… If you are using a cloud-based service your code is likely being run on a server farm. You receive access to this space either by directly renting it from the physical machine owners or via a third party that rents space from the company that owns the physical machine.*

*In the background, Heroku is actually renting space from AWS (owner of the physical machines). [source]

Lets circle back to our original definition: “Heroku is a cloud platform that lets companies build, deliver, monitor and scale apps”

A few paragraphs earlier we covered a list of common actions that are available on the Heroku platform (see the bulleted list), which almost covers the entire second half of the definition. The final word that needs recognition is “apps”. An app is one of those ubiquitous software terms that can have several different meanings depending on the context. For our purposes we are just going to keep it generic. An app is a set of instructions (written in code) that perform some function. This can range from a single webpage with text to an enterprise website that provides complex tooling and various features.

So there you have it. We have examined the definition of Heroku word by word.

In summation, Heroku is a service that removes all of the complexity of getting your c̶o̶f̶f̶e̶e̶ code to your friends by abstracting away the nitty gritty bits, so that all you have to worry about is writing top notch code.
Reflection provides objects that describe assemblies, modules, and types. We can dynamically create an instance of a type and bind that type to current object. Let suppose we have a business…
By: Arvind Kumar
Tags: Dotnet Core, Software Development, C Sharp Programming

What is Reflection and uses of Reflection

Reflection provides objects that describe assemblies, modules, and types. We can dynamically create an instance of a type and bind that type to current object.

Let suppose we have a business class(ArticleLogic) and we have to return News, Expert Review, videos and images of a Car.

Current State of the Code

Now we want to add Road test logic also. so we will add one more else if condition. This code is not extensible, and does not follow the DRY principle because we are repeating similar lines of code.

With Reflection
C# how to handle exceptions to illustrate try-catch action with Exceptions
Tags: Coding, Program, Assignment Help, Computer Science, C Sharp Programming

C# how to handle exceptions to illustrate try-catch action with Exceptions codeboks ·Dec 26, 2020

Object: Write a C sharp program to illustrate try-catch action with the following Exceptions. C# Projects with Source Code

i. IndexOutOfRangeException

ii. ArgumentOutOfRangeException

iii. ArrayTypeMismatchException

Code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace exc

{

class exp1…..continue code for click here….
.Net Core 3.1/.Net 5 CORS
By: Matt Perley
Tags: Net Core, API, Web Development, Cors, C Sharp Programming

Have you run into an xmlhttp error? Do you think it could be due to your .Net backend? It very well could be.

I was having some issues recently when trying to connect a web application to my backend, it kept giving me cors errors. So naturally I started looking around for a fix and it honestly seemed kind of pointless, no errors displayed in my .Net Core app and it only said xmlhttperror in my dart front end. I worked around this by using windows servers and setting up headers manually. This got annoying however, so I started playing and eventually found this bit of magic.

In your ConfigureServices function, simply add servces.AddCors();

Thats it.

Then…

We want to run the Cors builder inside the configure function. This will actually set up the headers and will work properly when making requests via dart/javascript/etc. Normally I work on desktop and mobile applications and this does not really seem to be much of an issue there. However in the world of the web, things are not always so simple I find.

I hope this was useful to someone out there. It was for me! Until next time, take care.
C# — Back to basics. I’ve been telling myself that I would…
By: Ed Atreides
Tags: C Sharp Programming, Leanring Journeys

I’ve been telling myself that I would get deeper into C# for the last 2 years — the time has come.

I learned C# in the 2D Unity Engine, but it didn’t give me the deeper understanding I was hoping for. I made a cool space shooter, but it just lacked… something. Didn’t really feel practical.

Missed out on Web Applications, RESTful web services, and modern development methodologies.

So — 2021 is the year of C# for me. I have a few projects in mind, but more on that later.

First step — buy a book. So, after searching around the internet for far too long I found a book by Dr. Andrew Lock titled ASP.NET Core in Action from Manning Publishing.

ASP.NET Core in Action

Got a digital version; planning on sitting down with it over the holiday and getting through the first couple of chapters .

If you want to follow along, you can buy a copy here.

Stay tuned — more to come soon.
Export CSV file using C# MVC
By: Suresh Kamrushi
Tags: Aspnet, C Sharp Programming

Export CSV file using C# MVC

Sharing here how you can export CSV file on runtime using C# MVC 4.5. In below code I am executing query to get data and then exporting it as CSV files.

public ActionResult exportData(FormCollection exportForm)

{

var exportReport = exportForm["exportList"];

if (exportReport != "")

{

var BL = new businesslogic();

string sqlQuery = "SELECT * FROM " + exportReport;

DataSet tableDataSet = BL.GetResultsDS(cs, sqlQuery); string data = ""; //will store file data

bool flag = true;

string headings = ""; //to store column headings

foreach (DataTable table in tableDataSet.Tables)

{

foreach (DataRow row in table.Rows)

{

data += "

"; // New line for each column

foreach (DataColumn column in table.Columns)

{

if(flag)

headings += column + ",";

data +=row[column]+",";

}

flag = false; //once we get heading setting to false;

}

}

data = headings+data;

Response.Clear();

Response.ContentType = "application/CSV";

Response.AddHeader("content-disposition", "attachment; filename=\"" + exportReport + ".csv\"");

Response.Write(data);

Response.End();

return new EmptyResult();

}

else

{

//redirecting to different page if no form data found.

return RedirectToAction("index", "ExportImport");

}

}

Hope this will help someone!!!

Generating and Formatting Excelsheet Using EPPLUS
[Mal Series #14] Debug C# In-Memory Loaded Module
Tags: Cybersecurity, Debugging, Malware Analysis, Reverse Engineering, C Sharp Programming

Most of the C# malware will load the decrypted loader module in memory to avoid signature based detection. The In-Memory file loader can be done by using [System.Reflection] Assembly Class which will load the file (.dll etc.) bytes into it and invoke/call any function that found inside the loaded file.

Some good reading on C# .Net Assembly.

Overview for C# Assembly Loader in action of a certain malware

Using LateBinding.LateGet to execute the In-Memory function

smethod_6 is a wrapper to the LateBinding.LateGet function which will invoke the function call (Means execution the function right away).

smethod_5 is wrapper to the GetObjectValue function to performs a shallow copy of the fields of the specified value type into the new object.
Hangfire Background Recurring Jobs — Console Application
By: Ghanshyam Shukla
Tags: Processing, Jobs, Console Application, Hangfire, C Sharp Programming

Hangfire is an open-source framework that helps you to create, process and manage your background jobs, i.e. operations you don’t want to put in your request processing pipeline:

https://www.hangfire.io/ Hangfire supports all kind of background tasks — short-running and long-running, CPU intensive and I/O intensive, one shot and recurrent. You don’t need to reinvent the wheel — it is ready to use.

Hangfire supports different types of background jobs:

Fire-and-forget, Background Process, Delayed, Recurring, Continuations, Batches, Batch Continuations

In this article, I am going to explain how to configure Hangfire for processing Background Recurring Jobs in Console Application.

Install the Hangfire package using NuGet

PM> Install-Package Hangfire

In the App.config, add the connecting string to get Hangfire Job Storage as:

<add name=”HangfireConnection” connectionString=”Data Source=GHANSHYAMS\SQLEXPRESS;Initial Catalog=Hangfire_Demo;Integrated Security=True;” providerName=”System.Data.SqlClient”/>

Now, install Topshelf package from NuGet and also some more packages like Microsoft.Owin.Host.HttpListener, Microsoft.Owin.Host.SystemWeb & Microsoft.Owin.Hosting

Add the Startup.cs class and configure the Hangfire dashboard.

Recurring Job

The Recurring job structure consists of JobId, Method, Queue, Type, Cron expression

By default Hangfire processes Default queue, but you can also specify your own queue like:

Queue("alpha")]

public void SomeMethod() { }

To begin processing queues, you need to update your BackgroundJobServer configuration.

var options = new BackgroundJobServerOptions

{

Queues = new[] { "alpha", "beta", "default" }

};



app.UseHangfireServer(options);

Methods to Trigger by Hangfire

After all configurations are done, start the console application and open the below URL in browser as:

You will hangfire dashboard accessed with “/hangfire”.

The hangfire dashboard shows various information about your Recurring Jobs, Servers, Retries, Jobs status — succeeded, failed, processing, deleted, awaiting, scheduled, enqueued

Hangfire References

https://www.hangfire.io/

https://www.hangfire.io/overview.html

My GitHub Project Reference

Happy Learning
Download Image And Replace in Html Page
By: Hasan Can Güler
Tags: Algorithms, Download Images, HTML, C Sharp Programming

You may want to use an image on some another HTML page. Of course, you can add on your page an image that is hosting on the internet, but sometimes, the server which is hosting an image may doesn’t permit using image directly.

In this case, one of the solutions is downloading the image and using from the local path it. The following methods execute this process. This code has coded with C#, if you use another language, you can convert easily or you can communicate with me.

For Github code, please click the following link
Generating output JSON log with log4net
By: Victor Souza Da Silva
Tags: Legacy Software, Software Development, Log4net, C Sharp Programming

Recently, my team was in charge of a legacy software written in .NET Framework. One of the biggest problems with this legacy is that we had no visibility of what was going on in.

One way to solve this problem was to send the software logs to Kibana (data visualization plugin for ElasticSearch). And it was the option we chose.

The output logs in “standard” format (to send to Kibana), make it difficult to create more complex graphs in Grafana (web application with interactive visualization of tables, graphs and alerts). Hence the need to generate logs in JSON format.

To generate logs in JSON format, we need to create a new layout and format the output in the desired format.

Our class will be named JsonLayout and must extend LayoutSkeleton (from the log4net.Layout namespace). The LayoutSkeleton class implements two interfaces (ILayout and IOptionHandler), so we must implement the methods: ActivateOptions and Format.

We already have our class created, we need to implement our custom formatting in the Format method.

In this example, we will print the fields in the log:

messageObject (which we pass as a parameter when logging)

requestId

pid

timestamp

level

logger

location

thread

exceptionObject (exception that we pass as a parameter when logging an error)

exceptionObjectString

This is how our class looks:

Now we just need to reference our JsonLayout class in the log4net.config file:

<configuration>

<log4net>

<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">

...

<layout type="MyNamespace.JsonLayout">

</layout>

</appender>

...

</log4net>

</configuration>

We write a log in our application:

And voilà:

{

"messageObject": {

"message": "new log message",

"field": "some data"

},

"requestId": "9e20b1b3-9064-4ebf-9d84-6662c7673324",

"pid": 25829,

"timestamp": "2020-12-17T00:16:15.0696380Z",

"level": "INFO",

"logger": "Log4netOutputJson.Program",

"location": "Log4netOutputJson.Program",

"thread": "1",

"exceptionObject": null,

"exceptionObjectString": null

}

The sample project is hosted on GitHub: https://github.com/victorlss/log4net-output-json
C# ile Karşılaştırmalı Python Rehberi Bölüm 1
By: Barış Can Kurt
Tags: Python, Rehber, Yazılımcı, Programming, C Sharp Programming

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
C# Development | 如何快速建立 TCP/IP 連線並傳送資料
By: Garnett.C 嘎內
Tags: Tcp Ip, Onestepatatime, Internet Transmission, Visual Studio, C Sharp Programming

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
C#: What is a Data Access Layer (DAL) and How To Create It
By: Hello Katie Kodes
Tags: Database, Data Access, C Programming, Visual Studio Code, C Sharp Programming

As a web developer, we deal with mountainous quantities of data.

To handle this, databases are created to store the data, retrieve and modify it. Web pages are built in conjunction to collect and summarise it.

This is done by creating what we call a Data Access Layer (DAL).

How do we create a Data Access Layer?

1. Create a website or application

2. Set up database

3. As the application or web site is created, add a reference to the database in Visual Studio’s Server Explorer.

4. Go to the Server Explorer in Visual Studio, right-click on the Data Connections node, and choose Add Connection.

5. The presentation layer of code should make a ‘call’ into the DAL for all data requests.

6. Such methods when called for will connect to the database, issue the query and then return the results.

7. The methods simply return a DataSet or DataReader that will be populated by the database.

Examples:

In your DAL, some methods can be:

GetProducts(), returning all product information from the database

GetProductsByCategoryID(categoryID), which returns all products that are associated with a category ID.

8. Developers can create their own custom objects or use Typed DataSets. E.g. Object A (of data) is implemented by the developer as a class. Object A has properties reflecting the columns of the underlying database that Object A contains.

The rule of thumb is that all code specific to the underlying data source should be located on the DAL.

Further information on creating a DAL in C# on Visual Studio visit:
#筆記:C# Boxing 與 UnBoxing
Tags: C Sharp Programming

Boxing 和 Unboxing - C# 程式設計指南

Boxing 是將Boxing is the process of converting a 當 common language runtime （CLR）方塊為實值型別時，它會將值包裝在實例內， When the common…
Deep Comparing Objects in C#
By: Shivam Singh
Tags: Aspnetcore, Aspnet, Compare, Programming, C Sharp Programming

Deep comparing two objects has always been a convoluted process.

Often we are presented with a situation where we may have to compare two objects in our program. It can be either to create an audit log or to avoid users to enter duplicate data.

This process of object comparison in C#/.NET is being simplified by the Nuget package Compare-Net-Objects offered by the Kellerman Software group. Compare-Net-Objects uses reflection to perform the comparisons.

Let’s jump into our implementation example implementation for more details.

Step 1:

Make sure you’ve downloaded the correct Nuget Package.

Step 2:

Creating two Person Objects for comparison.

Step 3:

By default Compare-Net Objects only distinguishes the first difference. Hence to capture all the differences of our object, we have to set the MaxDifferences property of our ComparisonConfig class to the total number of attributes. ComparisonConfig is part of the CompareLogic class.

Step 4:

Now that we’ve setup our CompareLogic, we can call the Compare method and pass our two objects(person1, person2) created in the step 1.

This returns a list of differences.

Performing Quick Watch on differences variable.

As we can see we have caught two differences on our objects(person1, person 2). Also you can note, the values of attributes are stored as string in Object1Value and Object2Value irrespective of their original type.

Step 5:

We can loop through these differences and either save or display it. I’ll print the values for example.

Compare-Net-Objects also provides the functionality of comparing lists, dictionaries. In conclusion we can safely say that, Compare-Net-Objects is a very powerful tool which has considerably eased down the process of performing deep comparisons and has made the life of .NET developers considerably easy!
Learning Something New
By: Ben Grange
Tags: UX, UX Design, C Sharp Programming, Product Design

Microblog #12

I learned C# in November.

I designed and developed a video game in December.

It’s amazing how closely designing a product is to how it’s developed. How intricate the relationship is between the architecture and the engineering. There are a hundred ways to code a solution to a problem. Naturally, working with an engineer to determine the best solution is a valuable skill.

The way a product is engineered determines how someone will use it, after all.
Simple Object Movement in Unity
By: Troy Lyndon
Tags: Unity Game Development, C Sharp Programming, Gamedevhq

The last task to complete GameDevHQ’s 2D Game Design course requires that we create a large boss with all the bells and whistles at the end of a Space Shooter level.

As with many things in Unity, doing simple movement is not intuitive. For example, I sought to create a direction vector based upon the current position of an object that would direct the object to a specific target position.

For example, I wanted to move the object vertically 5 units and horizontally by 3 units. But this doesn’t work. The issue is that you cannot modify each individual axis in a vector. So, joining them together into a Vector3, I wrote this:

But this didn’t work, either. To solve this, I A) created a simple offset (-2 and 2 for this new example) and B) added it to come up with the target position. But then, C) I also had to .normalize the result for the direction to always work as you can see in this code here:

Then, when it came time to move the object toward the target position, I could include this single line of code in Update().

transform.Translate(direction * speed * Time.deltaTime);

It’s truly amazing how much power 4 lines of code can produce. But coming up with the right 4 lines is not always so easy.

To see the practical use of this code, this image shows how the enemy objects move out of the way when the player shoots at them.

Thanks to Jonathan and Al at GameDevHQ, our superhero team lead Dan and Economic Development Alliance of Hawaii for making this program available for those of us impacted by Covid-19.
Day 14: Galactic Heatwave
By: Brittany Lumanlan Martin
Tags: Codependency, Game Development, Gamedevhq, Unity, C Sharp Programming

Today I created my absolute favorite game feature yet — a secondary fire powerup for my player. The “Heatwave” is a beast of an attack in which the player can emit a ray that explodes every active enemy onscreen for up to five seconds straight. The catch: this powerup will rarely spawn — just about every 60 to 90 seconds — and that can seem like a lifetime in a video game. In my opinion, the scarcity creates more excitement. See the Heatwave in action below.

I added three enemies into the game for demonstration purposes.

Programming the Heatwave took a bit of planning and researching. Originally, I planned to create a multi-directional shot, but opted to go for something really dramatic that would temporarily even out the playing field for the player. If the player must fight a seemingly endless wave of enemies, it only seems fair!

To my surprise, what I originally thought would be complicated wasn’t too much of a task. The Heatwave moves and functions similarly to the Laser. The key was to use a tag for the Heatwave to seek out and destroy. In the code below, you’ll see this applies to all objects onscreen tagged “Enemy”.

The last two items on the Phase I checklist include a bar to visualize the charge of the player’s thrusters with a cool down system, and a camera shake effect that occurs every time the player takes damage. I’m nearly through with programming the camera shake, and need to circle back to create the thruster charge bar. An exciting day lies ahead!
To script or not to script.
By: Kristin Treder
Tags: Unity Game Development, Space, Learning To Code, Unity, C Sharp Programming

Today I continued to work on the homing missile. I found a cute rainbow Mario star .png file and I converted it to a powerup by adding a 2D rigid body and a 2D circle collider.

Then I started working on the spawning. The instructions state that this powerup needs to spawn rarely. I also looked ahead into Phase II (which I’ll be tackling next) and saw that an assignment in there requests that our current random spawning be converted to “smart spawning” (my words) so that very powerful powerups like health and this homing missile spawn rarely and more needed items like ammo spawn regularly.

My first instinct was to create a new spawning script with a longer spawning interval. I created the new script and did not feel comfortable with it as it was identical to my current Powerup script with only the interval of time different. This can’t be efficient (I thought) and so I decided to just change the time intervals on the original spawn manager for the rare powerups. So I deleted the new script and started modifying my original spawn powerup script. Low and behold, after adding much more code that I had anticipated, I saw just how clunky my code was and realized that a second script for the rare powerups would, after all, be much more straight forward end efficient. So I’m at the point now of having to revert my code to it’s original form and go ahead and add and integrate a new script for the rare powerups.

New homing missile power up.

Here is what I have so far with the homing missile powerups spawning randomly like all the others.
Objects to Shooting. Objects to Shooting
By: Karissa Huynh
Tags: Game Development, C Sharp Programming

Day 4 : December 7, 2020

In a world of prefabs and instantiations, I have learned to create Capsule game object into mini laser beams. How? We create a laser object in Project view under the prefab folder and passed that in to the inspector-Player(script)- laserPrefab (which we created is our script). This way our script has a reference + holder for that object… so now it can be instantiated. My player was able to spawn multiple little pellets when ever I hit the space bar.

But its called laser for a reason, so what did we do? We shoot! How? Well we used the same concepts when creating our player (such as: transform.Translate) and repositioning the laser object to move up. Some details we included was the rate to which the laser moved, the boundaries (when the laser moved off screen it will destroy itself.

I was also fascinated with the many efficient ways to code in C#. For example, if you look below we can we my code. It did what it had to do but it was harder to understand & longer (yuck). While the 2nd example is easier to understand and overall more pleasant.

My version when setting laser position offset

The efficient way

It was a productive day. Ready for the next!

Karissa.
Day 13: Replenish
By: Brittany Lumanlan Martin
Tags: Unity Game Development, Game Development, Gamedevhq, Unity, C Sharp Programming

After two days of slow progress, today I made a fair dent in my Phase I checklist. The tasks I completed are listed in the following image:

Two of the requirements from Phase I.

I began by creating simple sprites on Canva for my player to collect. Canva is a great resource with a massive archive of free shapes, backgrounds, texts, etc. for tasks such as these — you can think of it as something similar to Adobe Creative Cloud.

The images below are essentially just .png files that I dropped into Unity, and by adding a Box Collider 2D and Rigidbody 2D, the images transform into game objects that can interact with the player and be programmed to perform specific functions. In this instance, these were turned into powerups and are attached to the same script as the triple shot, speed boost, and shield powerups. The missile sprite is for my next task, which I’ll be tackling and blogging about tomorrow.
Day 14 I am my own worst Enemy!
By: Mark Bohuslav
Tags: Unity, Game Development, C Sharp Programming

Today I decided to spend some time tweaking my Elite Unit that I had created earlier. I was not happy with his sound and or how his laser fired. Now that I learned RayCasting and saw its applications for detecting other objects I decided to give my Elite Unit RayCasting abilities. First I fixed his laser so that it would fire when the player was in its field of view. I put a small delay of 0.2 seconds before firing so the player has a chance to dodge if he is paying attention and times his moves right. This was more fun than just getting zapped right away. I also added a better sound effect when he fires. Basically used the original laser shot, stretched it a bit and added a few levels of Chorus in a Wav editor to make the sound a bit more rich. Additionally I completed one more Core 2 feature; I gave the Elite unit the ability to also dodge my lasers. Since this unit moves side to side I also added animated thrusters on each side depending on the direction the unit is going. Also have one in the back that only activates when the unit first comes into play. The thruster flame also get bigger whenever the unit dodges my lasers to enhance the speed boost the unit gets when he dodges. Since the unit has 5 hit points, it takes a bit of work to finish him off. The video below is a quick demonstration of the unit in action….he is HARD. lol!

I also spent some time implementing my Player’s secondary weapon. I got some of the coding done and created an animation for the weapon. It is pretty bad ass and I can’t wait to demonstrate it, most likely tomorrow. I am still looking for the perfect sound effect to go with it but I have decided to active the weapon by pressing the ALT key. It will have very limited uses as it is mostly an “ Oh Sh!t “ ability to get the player out of trouble, but the visuals are pretty awesome!

Over the next couple days I basically will finish the player weapon and then work on the Boss and then some balancing before starting to cleanup my Spaghetti code before submitting the project!

Mahalo!
Containerizing ASP.NET CORE 3.1 Web API with DOCKER
By: Joever Monceda
Tags: C Sharp Programming, Aspnetcore, Container Orchestration, Docker

What is Docker by the way?

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly.

With Docker, you can manage your infrastructure in the same ways you manage your applications. — Docker

Written in: Go

Initial release date: March 20, 2013

Developer: Docker, Inc.

Project setup:

1. Generate new project by using the command:

— dotnet new webapi -o AspNetCoreDockerTest

— cd AspNetCoreDockerTest

2. Open the project by using the command:

— code .

Note:

1. If your project not generated .vscode please enter the command:

(Ctrl+Shift+P) and Select .NET: Generate Assets for Building and Debug

2. Please select Yes if you get notified like this:

3. Please install Docker extension .

Let’s get started with Docker:

1. You need to install docker desktop in this url: Docker and make sure that docker is running.

2. In your project in vscode enter (Ctrl+Shift+P) and search for the following

> Docker: Add Docker Files to Workspace..

> ASP.NET Core

> Windows

> 80

It will generate: Dockerfile (if you can’t generate the file, add Dockerfile manually).

Per line explanation (by my own understanding).

AS base

1. We are using the mcr.microsoft.com/dotnet/core/aspnet:3.1 repository and Creating asp.net 3.1 app and tagging as layer base.

2. Your /app as working directory

3. And exposing to the port 80

AS build

5. We are using the mcr.microsoft.com/dotnet/core/sdk:3.1 repository and Creating as src/source of the project as build.

6. Your /src working directory

7. Copy the project file AspNetCoreDockerTest.csproj into the root of the project directory “./”

8. Restore all dependecies of the project.

9. Copy all the files into same location

10. Build the project as a release version into /app directory

As publish

13. use the same line and same configuration of line number 10 to create a release on /app directory

As final

15. Switching to /app directory

16. Copy the files from publish directory to /app directory.

18. After all the process the entry point will be [“dotnet”, “AspNetCoreDockerTest.dll”]

Running image commands:

1. docker build -t asp-net-core-docker-test:v1 .

— it will download images for aspnet 3.1 and sdk 3.1 (wait until the download done).

2. to verify the image, enter command: docker images

3. to run the image, enter the command: docker run -t --rm -p:9090:80 asp-net-core-docker-test:v1

Github Repository:

https://github.com/Ethan0007/DockerizeAspNetCore