14/05/2021
11/04/2021
Mã hóa số thành chuỗi với Base62 c#
Đôi khi bạn cần mã hóa 1 số thành chuỗi, để đảm bảo chuỗi mã hóa không trùng, bạn cần 1 số long và kiểu mã hóa đủ rộng, ở đây có mô tả Base62
code sample như sau:
private string ToBase62(long number)
{
try
{
var alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var n = number;
long basis = 62;
var ret = "";
while (n > 0)
{
long temp = n % basis;
ret = alphabet[(int)temp] + ret;
n = (n / basis);
}
return ret;
}
catch(Exception ex)
{
//Helpers.Log.Error("ToBase62 error" + number.ToString(), ex); //hander exception error
return string.Empty;
}
}
10/03/2021
Kiểm tra 1 trang web có cho phép mở trong iframe hay không bằng c#
Khi cần nhúng 1 trang web (URL) khác vào website của bạn dưới dạng iframe
Nếu website đó không cho phép mở dưới dạng iframe, website bạn sẽ hiển thị lỗi :)
Bạn cần kiểm tra trước để hiển thị phù hợp, code c# có thể dùng như sau:
//using using System.Net;
//check frame support
string frame_support;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(iframeUrl);
using (WebResponse response = request.GetResponse())
{
//DENY, SAMEORIGIN, ALLOW-FROM
//null is open in iframe
frame_support = response.Headers["X-Frame-Options"];
}
25/02/2021
Dạo phố Việt Trì 25 Tết Tân Sửu
17/01/2021
Ultra Office miễn phí dùng cho word, excel, power point và pdf
tỷ năm mới cần dùng đến word, làm biếng crack MS Office, không muốn mua MS Office 365 cũng không muốn dùng GG drive hay SkyDrive
tìm linh tinh ra cái Ultra Office miễn phí này, đúng ngon bổ rẻ, dùng tốt cho yêu cầu soạn thảo văn bản đơn giản của mình (y)
link cài đặt cho windows 10:
https://www.microsoft.com/vi-vn/p/ultra-office-for-free-word-spreadsheet-slide-pdf-compatible/9n161bjrlc1d
14/01/2021
06/01/2021
Convert list object to DataTable
{
// creating a data table instance and typed it as our incoming model
// as I make it generic, if you want, you can make it the model typed you want.
DataTable dataTable = new DataTable(typeof(T).Name);
//Get all the properties of that model
PropertyInfo[] Props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
// Loop through all the properties
// Adding Column name to our datatable
foreach (PropertyInfo prop in Props)
{
//Setting column names as Property names
dataTable.Columns.Add(prop.Name);
}
// Adding Row and its value to our dataTable
foreach (T item in models)
{
var values = new object[Props.Length];
for (int i = 0; i < Props.Length; i++)
{
//inserting property values to datatable rows
values[i] = Props[i].GetValue(item, null);
}
// Finally add value to datatable
dataTable.Rows.Add(values);
}
return dataTable;
}
Đăng ký tên miền, hosting, máy chủ, thiết kế lập trình website theo yêu cầu
Chính thức trở thành đơn vị cung cấp dịch vụ đăng ký tên miền quốc tế, tên miền Việt Nam hosting, máy chủ, cloud hosting, cloud server, ema...