image
This file contains 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
string ToBitDoubleString(double num) | |
{ | |
return BitConverter.GetBytes(num) | |
.Reverse() // little endian -> big endian | |
.SelectMany(x => x.ToString("X2")) //to x16 char | |
.Select(x => Convert.ToString(Convert.ToInt32($"{x}", 16), 2).PadLeft(4, '0')) // to x2 | |
.Aggregate("", (x, y) => x + y); | |
} | |
double ToDouble(string str) |
This file contains 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; | |
using System.Collections.Generic; | |
namespace Test20160912 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var inputs = new[] { "((1 + 4) * (3 + 7) / 5)", "((1 - 7) / (7 - 5)) * 5", "", "1+2" }; |
This file contains 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
ls | ?{!$_.PSIsContainer} | Unblock-File |
This file contains 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
int GetGcd(int a, int b) | |
{ | |
if (a < b) return GetGcd(b, a); | |
int tmp = 0; | |
do | |
{ | |
tmp = a % b; | |
a = b; | |
b = tmp; | |
} while (tmp != 0); |
This file contains 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 ICSharpCode.AvalonEdit; | |
using System; | |
using System.Windows; | |
namespace AvalonEditSample | |
{ | |
public class BindableEditor : TextEditor | |
{ | |
public BindableEditor() | |
{ |
This file contains 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
<SyntaxDefinition name="SQL" extensions=".sql" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008"> | |
<Color name="Digits" foreground="#FF00008B" exampleText="3.1415f" /> | |
<Color name="Comment" foreground="#FF008000" exampleText="string text = "Hello, World!"" /> | |
<Color name="Punctuation" foreground="#FFFF0000" exampleText="string text = "Hello, World!"" /> | |
<Color name="String" foreground="#FF808000" exampleText="string text = "Hello, World!"" /> | |
<Color name="String2" foreground="#FF999933" exampleText="string text = "Hello, World!"" /> | |
<Color name="Keyword" foreground="#FF0000FF" fontWeight="bold" exampleText="SELECT" /> | |
<Color name="MethodCall" foreground="#FF191970" fontWeight="bold" /> | |
<Color name="ObjectReference" foreground="#FF008080" exampleText="Customer.Name" /> | |
<Color name="CommentMarkerSetTodo" foreground="#FFFF0000" fontWeight="bold" /> |
This file contains 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 string ToRadixString(int num, int radix) | |
{ | |
if (num == 0) return "0"; | |
var list = new List<string>(); | |
var tmp = num; | |
while (0 < tmp) | |
{ | |
var digit = tmp % radix; | |
tmp = tmp / radix; | |
list.Add(digit.ToString()); |
This file contains 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 bool IsNarcissistic(int num) | |
{ | |
var numStr = num.ToString(); | |
return num == (int)numStr.Select(c => int.Parse(c.ToString())).Sum(x => Math.Pow(x, numStr.Length)); | |
} |
This file contains 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 FirebirdSql.Data.FirebirdClient; | |
using System; | |
using System.IO; | |
namespace Fb3Test | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
NewerOlder