Skip to content

Instantly share code, notes, and snippets.

View musoftware's full-sized avatar
🌏
Working from home

Musoftware musoftware

🌏
Working from home
View GitHub Profile
internal static class DeviceFingerprintProvider
{
public static async Task<string> DeviceFingerprintAsync()
{
DeviceFingerprintProvider.DiskSpace diskSpace = await DeviceFingerprintProvider.GetDiskSpaceAsync();
List<string> appNames = new List<string>();
string fingerprintFormat = "{{\n dfid: {{\n \"tds\": {0},\n \"fds\": {1},\n \"boot_time\": {2},\n \"apps\": {{\n \"version\": 0,\n \"names\": [{3}]\n }}\n }}\n}}";
ulong tds = diskSpace.TotalSpace / 1024UL;
ulong fds = diskSpace.FreeSpace / 1024UL;
ulong bootTime = await DeviceFingerprintProvider.UnixBootTimeAsync();
@musoftware
musoftware / html5 template.html
Last active November 4, 2016 17:43
Support HTML5 in IE6/7/8 and old safari
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
@musoftware
musoftware / avoid_hang_UI.cs
Last active June 24, 2022 18:36
While you make invoke to control from many many threads , the UI will hang
internal class AvoidHang : IDisposable
{
private readonly SemaphoreSlim _semaphore = new System.Threading.SemaphoreSlim(1, 1);
public void Dispose()
{
_semaphore.Dispose();
}
public void ToAvoidHang(int fast = 1000, Action action = null)
@musoftware
musoftware / AsyncThread.cs
Last active November 6, 2016 19:40
Wait Seconds
private async WaitSeconds(int e)
{
await Task.Delay(e);
}
@musoftware
musoftware / is_rtl.html
Last active November 9, 2016 15:17
Fix combined RTL and LTR Words in HTML,PHP
<bdi>This is Egypt</bdi>
<bdi>هي Egypt</bdi>
<bdi>هي مصر</bdi>
@musoftware
musoftware / likeyoutubeID.php
Created November 10, 2016 09:41 — forked from rastislavcore/likeyoutubeID.php
PHP Convert Long Number to short string
<?php
/**
* Translates a number to a short alhanumeric version
*
* Translated any number up to 9007199254740992
* to a shorter version in letters e.g.:
* 9007199254740989 --> PpQXn7COf
*
* specifiying the second argument true, it will
* translate back e.g.:
class ShortId
{
public static readonly string Alphabet = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static decimal BcPow(double a, double b)
{
return Math.Floor((decimal)Math.Pow(a, b));
}
public static ulong Decode(string value, int pad = 0)
@musoftware
musoftware / msgbox.cpp
Last active November 21, 2016 21:02
learning CPP
MessageBox(_T("Help, Something went wrong."), _T("Error"), MB_ICONERROR | MB_OK);
@musoftware
musoftware / ColorAnimator.vb
Created November 14, 2016 09:21
Animate Color by Percentage
Imports System.Reflection
Imports System.Threading.Tasks
Public Class ColorAnimator
Public obj As New Object
Dim boolStop As New List(Of System.Threading.CancellationTokenSource)
Public Async Function Animate(ctrl As Control, prop As PropertyInfo, newColor As Color) As Threading.Tasks.Task
Dim oldColor As Color
Dim StopAni As New System.Threading.CancellationTokenSource
@musoftware
musoftware / i.vb
Created November 14, 2016 09:23
cut control by graphic Path
Dim graphics_path As New GraphicsPath
Dim m() As Point = {New Point(23, 62), New Point(31, 56), New Point(37, 53), New Point(38, 53), New Point(45, 51), New Point(53, 53), New Point(60, 55), New Point(65, 54), New Point(65, 49), New Point(62, 42), New Point(61, 35), New Point(65, 27), New Point(73, 23), New Point(81, 22), New Point(86, 25), New Point(86, 26), New Point(92, 23), New Point(93, 29), New Point(92, 41), New Point(90, 45), New Point(91, 49), New Point(91, 52), New Point(88, 54), New Point(88, 59), New Point(86, 61), New Point(84, 65), New Point(77, 68), New Point(83, 74), New Point(91, 77), New Point(96, 81), New Point(105, 86), New Point(103, 93), New Point(95, 95), New Point(88, 92), New Point(81, 90), New Point(76, 89), New Point(56, 102), New Point(52, 103), New Point(53, 100), New Point(48, 102), New Point(45, 110), New Point(38, 117), New Point(29, 120), New Point(23, 120), New Point(19, 119), New Point(14, 122), New Point(11, 121), New Point(11, 117), New Point(19, 112), New Point(28, 111),