USING A DLL IN C#

#21 USING A DLL IN C#

A very simple example of how a DLL can be used.

In this simple example I create a very simple DLL(Dynamic-link library) in C#. the library has to functions the first function is the Calculate method which allows us initiate a simple addition of the numbers in each numerical box.The second function is a logger to keep track of the addition problems we solve. The WriteLine method also shows us how we can write to and delete files in by calling methods from the dll_example_class_library.dll we compiled.

A simple method called Calculate just adds two numbers together using the dll_example_class_library.dll DLL’s help to keep code more organised and also allow us to change functionality of programs without recompiling the EXE .

After the DLL is compiled we can add it to our project by: right clicking Refrences, clicking add reference, clicking browse and selecting our DLL

In order for us to use the methods in our class it has to first be initiated. Once initiated we can start using the methods in our logic.

C# EVENT LOGGER

#20 C# EVENT LOGGER

Event Logger Example

A simple logger to write all the occurring events to a file in the root directory \ Logs folder of the application.

The logger class LoggerClass.cs processes the data and writes it to a .log file. the Class can also delete the current log file which is being written to.

 public static class Logger
        {
            private static string LogFile = Application.StartupPath + "\\Logs\\Event_Logger_" + DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss") + ".log";

            public static void WriteLine(string txt)
            {
                try
                {
                    File.AppendAllText(LogFile, "[" + DateTime.Now.ToString() + "] : " + txt + "\n");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Could Not Append Text To Log File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            public static void DeleteLog()
            {
                try
                {
                    File.Delete(LogFile);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Could Not Delete Log File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }

JAVASCRIPT ALERTS

#19 JAVASCRIPT ALERTS

jAlert example

JALERT is a useful library which can be used to replace the three boring system kinds of popup boxes: Alert box, Confirm box, and Prompt box.

The usual system JavaScript alert would be called like below:

alert("I am an alert box!");

Jalert can be used in the same way but with more functionality:

$("#confirm_button").click( function() {
    jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) {
        jAlert('Confirmed: ' + r, 'Confirmation Results');
    });
});
  • useful links

JS EVENT LOGGER

#18 JS EVENT LOGGER

Simple Loglevel event log save to text file examlpe.

Looking for a lightweight event logger for JavaScript? look no further then Loglevel.

Loglevel is a minimal lightweight simple logging library for JavaScript. Loglevel replaces console.log() with level-based logging and filtering, with none of console’s downsides.

It’s a bare bones reliable everyday logging library. It does not do fancy things, it does not let you reconfigure appenders or add complex log filtering rules or boil tea (more’s the pity), but it does have all the core functionality that you actually use…

In this example I have implemented Loglevel directly into my browser page:

<script src="loglevel.min.js"></script>
<script>
function Loginfo(){
    log.setLevel('info');//2
    log.info("log info");
}
</script>

WINDOWS BATCH FILES

#17 WINDOWS BATCH FILES

Custom batch file example

A batch file is a script file in DOSOS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file.

Batch scripts are used to automate redundant tasks such as creating 100 folders or updating 50 servers. Yes you could do this 1 at a time manually but this is inefficient and a waste of time and money + resources.

Example Batch script

A good well written batch file can get a lot done and makes our lives a hell of a lot easier. The Linux equivalent is called a shell script.

Typically batch scripts end with .bat and some with .cmd. Batch scripts are executed.

MARKDOWN FILES

#16 MARKDOWN FILES

Example of my style of MARKDOWN design document.

Many people are familiar with project collaboration apps such as Trello, Slack or KanbanFlow. These platforms are great for discussing projects and planing results + steps etc. However every application needs a design document. This is where markdown comes into play. Markdown is a lightweight and easy-to-use syntax for styling all forms of writing on the GitHub platform. Although you can use any other document format such as MS Words .docx or .xls etc. Markdown is my preferred documentation syntax.

A good README.md will have the following features:

https://www.markdownguide.org/basic-syntax/

MASM32 EXAMPLES

#15 MASM32 EXAMPLES

Examples

MASM32 also known as Microsoft Macro Assembler is an x86 assembler that is still maintained by Microsoft however it is no longer sold as a separate entity but is rather, included in various SDK’s and C compilers.

https://www.masm32.com/

I have included the Github repositories to a whole bunch of interesting keygen template examples.

https://github.com/Xyl2k/MASM32-graphical-effects

https://github.com/Xyl2k/Xylitol-MASM32-snippets

CIRCLE COLORS IN JAVASCRIPT

#14 CIRCLE COLORS IN JAVASCRIPT

Circle Color Example

Beautiful circles are formed while the mouse is moving inside your browser. This short bit of code uses the D3.js library also known as the Data Driven Documents JavaScript library.

D3 examples

D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG, and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization components and a data-driven approach to DOM manipulation.

D3 examples

D3 allows you to bind arbitrary data to a Document Object Model (DOM), and then apply data-driven transformations to the document. For example, you can use D3 to generate an HTML table from an array of numbers. Or, use the same data to create an interactive SVG bar chart with smooth transitions and interaction.

In this case D3 was used to display colorful circular animations behind the mouse while it moves over the browser window.

Take a look at the EXAMPLE GALLERY for more examples.

5 WEB BOOTSTRAP TEMPLATES

#13 5 WEB BOOTSTRAP TEMPLATES

Top 5 web templates IMO

These are the top 5 free web templates (May 8th 2020) in my opinion. There is millions if not billions of options out there however these are just a few that I have had experience with. They are generally easy to use and modify.

geo-bootstrap

Geo bootstrap.

bootstrap-social

Bootstrap social buttons.

global

Global template.

Bootstrap-Admin-Theme-3

Bootstrap 3 admin template.

Kapella-Free-Bootstrap-Admin-Template

Kapella admin template.

SIMPLE ANIMATIONS IN CSS

#12 SIMPLE ANIMATIONS IN CSS

CSS animations

The following is a few examples of web loading animations made entirely in HTML and CSS. jQuery is used to add and remove the CSS animations. For example once the document has loaded a jQuery click event can be triggered like so:

jQuery used to call animations
 jQuery(document).ready(function (${ $('#pulse').click(function({            $('.placeholder').removeClass('wave').addClass('pulse'); })                                                     });

index.php shows a variety of different shapes combined. The following 3 small scripts show their respective shapes. anim.css holds all the animations.

HTML: Hyper Text Markup Language

CSS: Cascading Style Sheets

jQuery: lightweight JavaScript library

Folder structure.

Passionate about technology!

Test