Skip to content

Instantly share code, notes, and snippets.

View felipeabajo's full-sized avatar

@felipeabajo felipeabajo

View GitHub Profile
@felipeabajo
felipeabajo / folders-in-csharp
Last active November 14, 2023 14:51
Snippets for working with folders in C#
/*OPERATIONS WITH FOLDERS*/
/*Check if folder exists*/
private Boolean ExistsFolder(string folderPath)
{
if (Directory.Exists(folderPath)) return true;
else return false;
}
/*Create folder*/
private void CreateFolder(string folderPath)
@felipeabajo
felipeabajo / documents-in-csharp
Last active November 14, 2023 17:00
Snippets for working with documents in C#
/*TEMPLATES FOR WORKING WITH DOCUMENTS*/
/*Word*/
private void TemplateUsageWordDocument(string filePath)
{ //Open app and document
Word.Application WordApp= new Word.Application();
Word.Document wordDoc = WordApp.Documents.Open(filePath, ReadOnly: true, Visible: false);
//Include operations here
//Close document and app
@felipeabajo
felipeabajo / typography-in-csharp
Created November 14, 2023 13:32
Snippets for working with typography in C#
/*FONT CUSTOMIZATION*/
/*Size*/
private Font SetFontSize(int fontSize)
{
Font newFont;
try
{
newFont = new Font(FontFamily.GenericSansSerif, fontSize);
}
catch (Exception ex)
@felipeabajo
felipeabajo / paths-in-csharp
Last active November 14, 2023 14:32
Snippets for working with paths in C#
/*PATHS*/
/*Special folders*/
string FolderPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments); //C:\Users\Public\Documents in Windows
/*GENERATION OF PATHS*/
/*Paths of documents*/
string FilePath = System.IO.Path.Combine(folderName, fileName);
string FilePath = System.IO.Path.Combine(destinationFolderPath, selectedWord + " - " + selectedTypeOfProject + ".pdf");
@felipeabajo
felipeabajo / files-in-csharp
Created November 14, 2023 15:30
Snippets for working with files in C#
/*OPERATIONS WITH FILES*/
/*Check if file exists*/
private Boolean ExistsFile(string filePath)
{
if (File.Exists(filePath)) return true;
else return false;
}
@felipeabajo
felipeabajo / exiting-winforms-applications
Created November 14, 2023 15:39
Snippets for exiting WinForms applications
this.Close(); //If called in the main form, it closes the app too.
Application.Exit();
System.Diagnostics.Process.GetCurrentProcess().Kill(); // Causes an abnormal process termination and should only used when necessary.
@felipeabajo
felipeabajo / navigation-blazor-syncfusion
Created November 16, 2023 12:39
Snippets for navigation in Blazor using SyncFusion
/*NAVIGATION BETWEEN PAGES*/
/*Navigation to Razor pages from SyncFussion buttons*/
@inject NavigationManager NavigationManager
<SfButton Content="To CsHtml page from Sf Button" OnClick="@(() = NavigateToRazorPage("/REPLACEWITHCSHTMLPAGE"))"></SfButton>
@code{
async Task NavigateToRazorPage(string page) {
NavigationManager.NavigateTo(page);
}
}
@felipeabajo
felipeabajo / snippets-for-github
Created December 20, 2023 08:58
Snippets for GitHub
Merge from branch not possible because branches do not share the same history:
git checkout [BRANCH]
git branch master [BRANCH] -f
git checkout master
git push origin master -f
@felipeabajo
felipeabajo / wordpress-sharing-buttons
Created February 9, 2024 22:38
Sharing buttons for WordPress
add_filter( 'the_content', function ( $content ) { if ( is_singular( 'post' ) ) {
/*********************
* choose icons
**********************/
$facebook = 1;
$twitter = 1;
$LinkedIn = 1;
$threads = 1;
$email = 1;
/*Versión con Emojis sin fotos*/
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="189" style="width:auto;border-top:none;border-bottom:none;border-left:none;border-right:1.5pt solid rgb(91,155,213);padding-right: 1rem; vertical-align: middle; min-width: 250px;">
<h3 style="margin:0cm 0cm 0.0001pt; font-family:Arial,sans-serif;color:black">Felipe
de Abajo Aragón</h3>
<p style="margin:0cm 0cm 0.0001pt;line-height:16.5pt; font-family:Arial,sans-serif;color:black">Informático y formador</p>
</td>
<td width="378" valign="top" style="auto;padding-left: 1rem; vertical-align: middle; min-width: 200px;">