Posts

Showing posts from 2022

Managing Windows Services - Delete/Add

 First things first, lets delete cause that's super easy and before I delete anything I make sure to create backups. What I'm looking to do is expand a system like topshelf where it can just manage it remotely for me but using devops can be tricky. //delete command sc.exe delete <service name> or Ps way Remove-Service -Name "TestService" Note: curious about the registry but its better to use sc.exe. Now for adding sc create asperacentral binPath= "C:\Program Files\Aspera\Enterprise Server\bin\Debug\asperacentral.exe" DisplayName= "Aspera Central" start= auto

Ubuntu Server: Cmd line Network Shared folder for Windows

Image
 Got tired of using filezila to do everything so this morning I set things up with Samba to allow me to share. Just a few notes along with this video that I think might be helpful for other devs. commands sudo apt-get install -y samba sudo ufw allow 139 sudo ufw allow 445 sudo service smbd status sudo vi /etc/samba/smb.conf sudo chmod 777 shared_folder/ [guest] # This share allows anonymous (guest) access # without authentication! path = /shared_folder read only = no guest ok = yes guest only = yes I used the folder path at the root and probably will later add a user for security but for now I have what I need to get running. Doesnt seem as fast as filezilla but thats not a big deal. 

SQL Backup Database with Network folder

The time has come where I've been forced to work with SQL like a dba, and for once the pieces are falling in place.  https://stackoverflow.com/questions/3942207/how-can-i-backup-a-remote-sql-server-database-to-a-local-drive https://stackoverflow.com/questions/16491/restore-database-backup-over-the-network#:~:text=On%20the%20Server%20that%20you,bak%22 https://stackoverflow.com/questions/10204480/sql-server-the-backup-set-holds-a-backup-of-a-database-other-than-the-existing https://dba.stackexchange.com/questions/28082/restore-backup-fails-file-db-cannot-be-restored-to-mdf-use-with-mov Generating a script took too long and wasnt helpful for what I needed since I'd still need to move it onto the server. We're talking about 200gb and plus... and to make matters worse time is important. Since the backups are created nightly on the server and I just need to restore the backup on another server it seems kinda of a waste to not be able to use it. https://stackoverflow.com/questions...

Mono GTK on Windows

 I'd like to use visual studio but visual code with mono.exe on the side is what I'm currently doing. I'm able to get WinForms to work however I'm running into difficult trying to run GTK on windows.  Unhelp Q/A - https://stackoverflow.com/questions/51132090/mono-compliling-gtk-on-windows its unhelp because I already have the complier working and referencing the package properly. Its just windows doesnt pick up GTK inorder to run it. https://stackoverflow.com/questions/51132090/mono-compliling-gtk-on-windows Possible Solution https://stackoverflow.com/questions/16417342/mono-gtk-hello-world-deploy-to-windows GTK Notes https://www.mono-project.com/docs/gui/gtksharp/beginners-guide/ mcs -r:"C:\Program Files\Mono\lib\gtk-sharp-2.0\gtk-sharp.dll" -r:"C:\Program Files\Mono\lib\gtk-sharp-2.0\glib-sharp.dll" -r:"C:\Program Files\Mono\lib\gtk-sharp-2.0\atk-sharp.dll" hello.cs mono hello.exe Unhandled Exception: System.IO.FileNotFoundException: Coul...

Windows & Service Development

 As a consultant I've been able to start developing application and services at the lower levels of the operating system. Which is pretty interesting compared to what I use to do. I find myself doing the same thing with my web development. WPF -  https://en.wikipedia.org/wiki/Windows_Presentation_Foundation#:~:text=Windows%20Presentation%20Foundation%20(WPF)%20is,NET%20Framework%203.0%20in%202006. Understanding the .NET family https://en.wikipedia.org/wiki/.NET_Framework https://docs.microsoft.com/en-us/windows/apps/desktop/choose-your-platform https://en.wikipedia.org/wiki/Universal_Windows_Platform_apps

EFCore - Parallel Async

This is no longer needed but maybe can be used for real-time example projects. Currently dont have any use for it. https://stackoverflow.com/questions/44063832/what-is-the-best-practice-in-ef-core-for-using-parallel-async-calls-with-an-inje https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/ I've also been moving away from EF in favor for Dapper, still using tasks that might be unless until I write myself an example.

Handling Raw Html

For sometime now I've been at a point in my research to find the proper way to handle raw html. Sometimes you need your api to push raw html with syntax that can't be edited once its submitted.  Handling all html in a 2D array where the first in just the html tag and the second is a child's value which can also be a html tag. { ["p"]["test"]  This may also be another case to start my project with a headless orchard core project. Using fluid syntax might be the better way to allow an api to take information and using a custom javascript library to convert html to the api? 

Image Enhancement Research

For some of the projects I have in mind this would be a great way to handle poor quality images, for example schematics that have low pixels. From there I would have an easier time convert to svg files but that is a project later down the road. For now this is something I need to keep in mind of. msmsajjadi/EnhanceNet-Code: EnhanceNet: Single Image Super-Resolution Through Automated Texture Synthesis (official repository)

Linux: Managing Security & System Logs

Not a linux novice by any means, so this last year (2019) I had been tracking logs on my server. I'll come back to this article and clean it up but incase I dont these definitely helped me track things until I start using a third party tool. sudo ip6tables -I INPUT -m geoip --src-cc IT,FI,GB,CA,MX,CN,DE,TR,ID,RU,IN,IL,BR -j DROP http://blog.jeshurun.ca/technology/block-countries-ubuntu-iptables-xtables-geoip https://unix.stackexchange.com/questions/92560/list-all-connected-ssh-sessions  cat /var/log/auth.log | grep 'Connection closed' |  tail -n 40 sudo iptables -L  iptables -A INPUT -m state --state INVALID -j DROP Notes http://ipset.netfilter.org/iptables.man.html https://unix.stackexchange.com/questions/345114/how-to-protect-against-port-scanners https://unix.stackexchange.com/questions/318859/how-to-use-watch-command-with-a-piped-chain-of-commands-programs https://daenney.github.io/2017/01/07/geoip-filtering-iptables http://xmodulo.com/block-network-traff...

ReUsed Flexcode ADOC Connection

Back in 2019 I was working for a consulting firm which this came in handle, I dont think I will ever need to go back to an ERP system and specially dont think I will need to work with flexcode again. Still this was something that I found and might help someone else. Public Sub Database_Connection()  Do      If cn1.State = 1 Then Exit Sub      On Error Resume Next      Set cn1 = macForm.ConnInfo.OpenADOConn      On Error GoTo 0  Loop  End Sub

Aspnet Dotnet Notes: Custom Authorization & App_Data

Trying to handle a secure folder  where the files are not pushed to the server at deploy. Like all files in wwwroot they are in source control, these will not. The files I'm storing are so big that moving them is a separate process do outside of my application. https://stackoverflow.com/questions/36775942/how-do-i-serve-static-files-only-to-authorized-users https://github.com/ClintBailiff/MiddlewareDemo/blob/master/Startup.cs get current user   inside an MVC controller: From the  Controller  base class, you can get the  IClaimsPrincipal  from the  User  property System . Security . Claims . ClaimsPrincipal currentUser = this . User ; You can check the claims directly (without a round trip to the database): bool IsAdmin = currentUser . IsInRole ( "Admin" ); var id = _userManager . GetUserId ( User ); // Get user id: Other fields can be fetched from the database's User entity: Get the user manager using dependen...

Dynamically sitemap.xml in Aspnet Core

Someday I'd like to complete this project but for now I have very little time so I'll just hold onto these notes. The goal or idea would be for me to create a SEO friendly site but with all my experience with cms or spa applications I'd create it more based on a headless cms. If I get the chance I'd want to work with orchard core on this. Notes https://stackoverflow.com/questions/50311264/how-to-create-dynamically-sitemap-xml-in-net-core-2 https://rehansaeed.com/dynamically-generating-sitemap-xml-for-asp-net-mvc/ https://github.com/uhaciogullari/SimpleMvcSitemap#google-sitemap-extensions

Still a use case for slow-cheetah

With .net 6 out I'm still finding myself maintaining application dependent on .net framework 4.7.2 which isnt too difficult to move them over just time consuming. So as a real quick reminder for myself there's a way to handle debug/local environments. Since most employer's dont know about this cool library or dont see the advantage, over using #DEBUG  in code. Which I really hate handling so instead I install slow-cheetah and using the foling.  xdt:Locator="Match(name)" add this to your App.{env}.config and call it a day with handling your environment! Notes https://www.c-sharpcorner.com/article/transform-config-using-slow-cheetah/ https://marketplace.visualstudio.com/items?itemName=vscps.SlowCheetah-XMLTransforms

Azure functions appsettings.json instead of local.settings.json

 Currently one of the services I manage needs to properly set configurations similar to appsetting.json so that the parent name of the config doesnt need to change. This is because of service that calls for the config is looking specifically at the parent name. However since its a azure function using this I ran into an issue of using a different name rather than "Values" where db connections or other properties need to be in order to be read. I tried using the following example... { "CustomParent": {      "test":"true"      }    "Values": {          "test": "true"       } } For my custom name I can grab the test value, just what's in values parent. https://adamstorr.azurewebsites.net/blog/why-wont-you-load-my-configuration-azure-functions https://stackoverflow.com/questions/51781298/read-custom-settings-from-local-settings-json-in-azure-functions https://github.com/Azure/Azure-Functions/issue...

Hybrid Connection for On Premise connections

This week I got to setup a on premise connection with one of our database, which to my surprise worked out great. The project was creating a Azure function connect to one azure database and on remote machine located in the office. The issues I faced included access to the machine itself to questions about the firewall or service. Originally mixed up the machine which send me down the path for most of the links. However the final solution was to just restart the service after it was all send and done. I probably would had ran into firewall issues or maybe just proxy network issues like I found for a few articles if it had not already be setup for me by the IT team. Still work noting incase, the other major issue was just testing/prototyping. So for that I create a store proc on both databases to test a connection was made, another way to prove it was via an email get results from both databases. Still dont quite get the Testing console in Azure so for triggering it I just set a timer ev...

Task Scheduling With AgendaJs and MongoDB

This was a project I wanted to start for my consulting project however my team was using TopShelf to create windows service and handled timers in the main loop. Which is fine but if you wanted to look up execution logs, like last run or if it was currently running you had to be on the machine. Checking the service status, and system logs. Later we used the database with nlog to help us but I think hangfire would have been a improvement. Side not for my calendar project this would have been the route I would have taken for the backend service or at least started looking at. https://thecodebarbarian.com/node.js-task-scheduling-with-agenda-and-mongodb https://medium.com/hacktive-devs/nodejs-scheduling-tasks-agenda-js-4b6824f9457e https://dev.to/andre347/how-to-create-a-task-scheduler-in-nodejs-4lo2 https://github.com/agenda/agenda https://nosqlbooster.com/home https://github.com/timgit/pg-boss/blob/master/docs/usage.md

Angular 9: Loading App

A lot of my articles this month are going to be useless to some people because they arent organized in any way. This is because there were quick notes collected when I was consulting and using angular 9. Which was working for me at that time to complete my work. Until I have another professional angular project, angular 12 is looking like a pain to upgrade from 9 so much so it has slowed my personal projects down. So all research and work I do is on my personal time.  https://medium.com/@tomastrajan/how-to-style-angular-application-loading-with-angular-cli-like-a-boss-cdd4f5358554 https://loading.io/# https://napster2210.github.io/ngx-spinner/

WebApi: Notes & Richardson Maturity Model

I forget how I came across this but certainly need to research more on the subject. For now I'll just leave this article here for myself to remind myself later.  HATEOAS - https://en.wikipedia.org/wiki/HATEOAS idempotent - https://en.wikipedia.org/wiki/Idempotence upserts - https://stackoverflow.com/questions/20861870/web-api-and-upserts/20862830 https://martinfowler.com/articles/richardsonMaturityModel.html What is the   Richardson Maturity Model ? The   Richardson Maturity Model   is a way to grade your API according to the constraints of REST. ... The   Richardson Maturity Model   knows 4   levels   (0-3), where level 3 designates a truly RESTful API.

Configuration Pains with Postfix

In the start of 2018 around February I finally got everything in place to send and receive emails. For now my server just sends emails not receive. I want to investigate more into the authorization system for postfix and currently at the moment I caught up on ways to create listeners which I need for another project. I want to create an aspnet core version of squirrel mail but for now things are where I need them. https://linux-audit.com/postfix-hardening-guide-for-security-and-privacy/#test-the-existing-postfix-configuration https://linux-audit.com/postfix-hardening-guide-for-security-and-privacy/#test-the-existing-postfix-configuration https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-14-04 http://postfix.state-of-mind.de/patrick.koetter/smtpauth/smtp_auth_mailclients.html https://serverfault.com/questions/712903/503-5-5-1-error-authentication-not-enabled-when-trying-to-connect-to-my-postf https://github.com/nl...

Popular posts from this blog

Aspetcore: NLog with Postgresql

Mongodb Cheatsheet

Installing Windows on Acer chromebook 15 cb3-532