This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static int SearchBinary(int[] array, int searchValue) | |
{ | |
int min = 0; | |
int max = array.Length - 1; | |
while (min <= max) | |
{ | |
int mid = (min + max) / 2; | |
if (searchValue == array[mid]) | |
{ | |
return mid; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Application x:Class="ExampleProject.App" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:local="clr-namespace:ExampleProject.ViewModel" | |
d1p1:Ignorable="d" | |
xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
StartupUri="View/MainWindow.xaml"> | |
<Application.Resources> | |
<ResourceDictionary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//using System.Net; | |
using var wb = new WebClient(); | |
var response = wb.DownloadString(url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NuGet package: EntityFramework from Microsoft | |
using System.ComponentModel.DataAnnotations; | |
public class JobEntry | |
{ | |
[Key] | |
public int Id { get; set; } | |
[StringLength(50)] | |
public string UniqueId { get; set; } | |
[StringLength(100)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<string> ReadAllTextAsync(string filePath) | |
{ | |
var stringBuilder = new StringBuilder(); | |
using (var fileStream = File.OpenRead(filePath)) | |
using (var streamReader = new StreamReader(fileStream)) | |
{ | |
string line = await streamReader.ReadLineAsync(); | |
while(line != null) | |
{ | |
stringBuilder.AppendLine(line); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel; | |
using System.Runtime.CompilerServices; | |
namespace ExampleProject | |
{ | |
public abstract class ViewModelBase : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected virtual void OnPropertyChanged([CallerMemberName]string propertyName = "") | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/tls" | |
"log" | |
) | |
func main() { | |
var cert tls.Certificate // from wherever | |
tlsConfig := &tls.Config{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Helper | |
{ | |
private static readonly Dictionary<string, string> Cache = new Dictionary<string, string>(); | |
public static string ReadUtf8EmbeddedRessource(string filename) | |
{ | |
string utf8EmbeddedRessource; | |
lock (Cache) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tlsConfig := &tls.Config{ | |
MinVersion: tls.VersionTLS12, | |
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256}, | |
PreferServerCipherSuites: true, | |
CipherSuites: []uint16{ | |
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, | |
tls.TLS_RSA_WITH_AES_256_GCM_SHA384, | |
}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func decodeUTF16ToUTF8(b []byte, bigEndian bool) ([]byte, error) { | |
if len(b) % 2 != 0 { | |
return nil, fmt.Errorf("must have even length byte slice") | |
} | |
var ( | |
u16s = make([]uint16, 1) | |
ret = &bytes.Buffer{} | |
b8buf = make([]byte, 4) | |
) |
OlderNewer