Rtrim and Ltrim specific chars in VB.Net

Dim char_array_end = "<br />".ToCharArray Dim char_array_start = "I ".ToCharArray Dim my_string = "I love pizza, beer, sambuca<br />" Dim my_string_trimmed = my_string.TrimEnd(char_array_end) Console.WriteLine(my_string_trimmed) ‘I love pizza, beer, sambuca’ my_string_trimmed = my_string.TrimStart(char_array_start) Console.WriteLine(my_string_trimmed) ‘love pizza,…

Javascript | How to check sessionStorage support

var IS_SESSION_STORAGE_SUPPORTED; try { if (window.sessionStorage) { IS_SESSION_STORAGE_SUPPORTED = true; } else { IS_SESSION_STORAGE_SUPPORTED = false; } } catch (e) { IS_SESSION_STORAGE_SUPPORTED = false; } if (console) console.log(IS_SESSION_STORAGE_SUPPORTED);

ASP.NET Core | Making a request synchronously

using (var netClient = new System.Net.Http.HttpClient()) { var response = netClient.GetAsync(“https://example.com”).Result; if (response.IsSuccessStatusCode) { var responseContent = response.Content; string responseAsString = responseContent.ReadAsStringAsync().Result; Console.WriteLine(responseAsString); } }

PHP | List all folders in the mailbox

$mbox = imap_open(“{mail.example.com:143/novalidate-cert}”, “foo@example.com”, “password”) or die(“can’t connect: ” . imap_last_error()); $folders = imap_list($mbox, “{mail.example.com:143/novalidate-cert}”, “*”); if ($folders === false) { echo “Failed to list folders in mailbox”; } else { print_r($folders); } imap_close($mbox);

C# | Cast an int to enum

using System; public class Program { public static void Main() { var e0 = (Food)Enum.ToObject(typeof(Food), 0); Console.WriteLine(e0); // or simply var e2 = (Food)2; Console.WriteLine(e2); } public enum Food { Pizza, Pasta, Tofu } }