Showing posts with label C# Advanced. Show all posts
Showing posts with label C# Advanced. Show all posts

Friday, June 16, 2017

[Share] Tools Boot Traffic SSH

Tools Boot Traffic SSH



Chào các bạn SEOer, như các bạn đã biết sau khi xây dựng backlink cho website, việc tiếp theo là chúng ta phải submit backlink đó lên Google để các công cụ tìm kiếm index backlink đó càng nhanh càng tốt. Đồng thời chúng ta cũng phải chia sẻ backlink đó lên mạng xã hội để tăng lưu lượng truy cập đổ về website mà chúng ta cần SEO. Ngoài ra chúng ta có thể sử dụng một số phần mềm boot traffic để tự động click vào backlink đó. 

Tool Boot Traffic miễn phí


Hiện nay trên thị trường có khá nhiều Tool Boot Traffic, chẳng hạn như iView Premium hoặc iClick tuy nhiên các phần mềm này đều có phí. Hôm nay mình sẽ chia sẻ với các bạn Tool Traffic do mình tự code trên nền tảng .Net đây là 1 Tool Boot Traffic bằng SSH khá hiệu quả. Đặc biệt tool này có thể tự động click vào tọa độ trên website mà mình đã cài đặt, có thể fake Link Referral, các bạn xem báo cáo của Google Analytics bên dưới sẽ rõ.


boot-traffic-google-analytics

- Để tải phần mềm các bạn vui lòng để lại email mình sẽ gửi phần mềm vào hộp thư mail của các bạn ngay sau đó. Chi tiết liện hệ Facebook : Cường Nguyễn.

Friday, June 9, 2017

Public SMS Message Repository

Public SMS Message Repository

Introduction

This project enables an individual use a mobile phone to store a short message "in the cloud", that can be picked up by others using their mobile phone.
This project will demonstrate how to:
  • use the Twilio TwiML API to respond to SMS messages;
  • use XML as a data store;
  • have some political fun along the way.

Before we get started, see the application in action. Using your mobile phone, SMS (text) bush to +1 530 PROJECT (as in Code Project, or +15307765328).
Note: The demo does not allow addition/change/deletion of messages.

Background

My softball team had a problem. If a game was cancelled or rescheduled due to rain (or hail), it was difficult to relay the message to all the players quickly. They would drive to the ball park, only to learn about the cancellation.
This project, written in 2012, and rewritten for this article, is a solution. It works like this:
  1. The team captain sets a message by sending a message to the application:
    set rainout bingo July 5 @ 10:00 Today's games are cancelled.
  2. The application responds:
    rainout set: July 5 @ 10:00 Today's games are cancelled.
  3. Players can check the status by sending a machine to the application:
    rainout
  4. The application responds:
    July 5 @ 10:00 Today's games are cancelled.

How it Works

Twilio is a telephony gateway. It bridges data and voice between the internet, POTS, and 3GPP networks. By setting up an account with Twilio, calls and messages be be directed to and from an assigned number.
This project uses a simple API, called TwiML. It's use is very simple:
  1. A phone number is associated with a web application by specifying the URI of the application.
  2. When the number receives a message, an HTTP POST is made to the specified URI as application/x-www-form-urlencoded, containing data and metadata.
  3. The application responds to the request with an XML document (TwiML), containing instructions on how to respond.
  4. The response is relayed back to the requestor.

Inside the Code

https://www.codeproject.com/KB/Articles/996504/Sms.png
In this example I have used IIS/ASP.NET to act as the HTTP server and scripting interface. Incoming requests are handled by overriding the Render method of the Default Page class. If a form is POSTed with a Bodyparameter, the Controller is invoked.

Controller

Examples of valid request messages are:
  • bush
  • set greeting bingo Thanks for stopping by!
  • greeting
  • delete greeting bingo
ParseTwilioRequest uses a regular expression to split the message into its components.
// Parse the twilio request.
string command = string.Empty, message = null, password = null, key = null;
var matches = Regex.Match(request, "^(?<command>[^ ]+) (?<key>[^ ]+) (?<password>[^ ]+)(?: (?<message>.*))?$|^(?<command>[^ ]+)(?: (?<values>.*))?$");
The possible message components are:
command
A verb/instruction. This is the only required component. Valid commands are any stored key, hello, ping, set, delete, and bush.
password
If performing a set or delete command, a password is required. The password is specified by Repository.Password.
key
If performing a set or delete command, the key of a key/message pair. The key must match a pattern, specified by Repository.KeyPattern.
message
If performing a set or delete command, the message of a key/message pair.
If no components are present, or the command is invalid, a default message is returned.

Repository

The application uses and XML file as a data repository, abstracted by the Repository class. It subclasses XDocument, and provides properties and methods to manipulate its data.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<repository password="bingo" pattern="[a-zA-Z0-9]{3,10}">
  <default>Reply with [hello|bush|{0}]. +1530PROJECT brought to you by Red Cell Innovation Inc.</default>
  <message key="foo">bar</message>
  <message key="rainout">July 5 @ 1000 Today's games are cancelled.</message>
</repository>

Bushisms

Just for some fun, a bush request invokes Bushisms.GetRandom() for a random Dubya quote.

Deployment

  1. Copy the provided files to your web server.
  2. Open a Twilio account (you'll receive some free credit).
  3. Order a telephone number.
  4. In the telephone number configuration, assign the URI of your application the to the SMS callback.
  5. Test, and use Twilio's alerts panel to debug.
Once your credit expires, this project will cost:
  • about USD 1.00 per month for a telephone number;
  • about USD 0.0075 (¾¢) per message sent or received.

Security Considerations

For my use, security was not a major concern. Keep in mind:
  • The password, used to set and delete messages is stored in plain text in the repository.xml file, so are the messages.
  • To secure the application, it should be configured on a server that uses SSL/TLS (HTTPS) to encrypt the transport of messages between Twilio and the web server.
  • By design, messages can be retrieved from the store using only a keyword.

Contribute

How could you use this application? What other use cases can you imagine? Add your response below.

Conclusion

This project demonstrates how to build a simple SMS application without the use any external libraries or dependencies.
I am not affiliated with Twilio. This article is not an endorsement for Twilio. Twilio is one telephony gateway, and there are many others. Each may offer different services, at different costs.
Note: Offering a working demo for this article has real costs. The cost of this demonstration is sponsored by Red Cell Innovation Inc. If you require development of a telephony or mobile application, please consider us.

History

  • May 31, 2015 – First publication

Download Source Code


Google Translate Desktop Application in C#.NET

Google Translate Desktop Application in C#.NET


Introduction

This tip demonstrates how to implement Google translate in your C# application without purchasing its API.
Points of Interest are:
  • We are using Google translate service so an internet connection is required.
  • We are sending HTTP requests like a browser does.
  • We are parsing the output and displaying result.
Features of Application are:
  • Grabs input string from clipboard as soon as application starts or its window is actived.
  • Language change option is available in context menu on each textbox.
  • Translate while typing.
  • Shows single or all meanings of given word.
  • Shows meaning with corresponding sentence surrounded with [ ].

Snapshots

Using the Code

I am using http://translate.google.com/translate_a url.

Points of Interest

This code is edited by me and more features are added to make a handy translator. I hope this will help readers.

History

  • Version 1.0 - GoogleTranslateDesk

Download Source Code

Saturday, July 9, 2016

Facebook Auto Beta Tools - Bản Beta CuongVizut Dev

Facebook Auto Beta Tools - Bản Beta CuongVizut Dev

Facebook Auto Beta Tools - Bản Beta CuongVizut Dev
Facebook Auto Beta Tools - Bản Beta CuongVizut Dev

     Đây là bản beta với các chức năng như :


  1. GET thông tin tài khoản
  2. GET ID Friends
  3. GET Accesstoken tài khoản
  4. Mời bạn bè like page
  5. Mời bạn bè tham gia nhóm
  6. Auto kết bạn tăng friends list.
  7. Xóa bạn hàng loạt
  8. Xóa theo dõi hàng loạt


      Chức năng Auto comment do chưa có thời gian nên chưa thể publish cho các bạn được nên tạm thời các chức năng kia mình dùng rất OK.
Facebook Auto Beta Tools
Facebook Auto Beta Tools

Hiện tại chương trình còn một số lỗi mình chưa tìm ra do đây là bản beta thử nghiệm, sang phiên bản tới vào cuối tuần sau mình sẽ update fix lỗi các bạn. Để tải chương trình về dùng thử bạn vui lòng ấn like page https://www.facebook.com/laptrinh24h/ và mời tất cả mọi người like page sau đó chụp ảnh gửi qua message fb mình sẽ gửi link cho các bạn tải. Xin lỗi vì sự bất tiện này nhưng đây coi như là 1 phần công sức để mình suy nghĩ và tạo phần mềm hi vọng các bạn vui lòng hợp tác. Chúc các bạn 1 ngày làm việc tốt lành.

Tuesday, June 28, 2016

Tài liệu tham khảo C#

Tài liệu tham khảo C#
Tài liệu tham khảo C#
Các nguồn sau chứa thông tin bổ sung về C#. Mong bạn tham khảo chúng để hiểu sâu hơn các chủ đề đã được trình bày trong loạt bài này.

Link hữu ích về C#

  • Tutorialspoint − Loạt bài hướng dẫn của chúng tôi xây dựng dựa trên nguồn này.
  • C# Programming Guide − Cung cấp thông tin chi tiết về các đặc điểm cốt lõi của ngôn ngữ C#.
  • Visual Studio − Tải phiên bản mới nhất của Visual Studio mà làm việc như là C# IDE.
  • Go Mono − Mono là một nền tảng được thiết kế để cho phép các lập trình viên dễ dàng tạo các Cross Platform Application (ứng dụng đa nền tảng).
  • C Sharp (programming language) − Wikipedia về C#.

Sách hữu ích về C#

  • Head First C#
  • C# 5.0 in a Nutshell
  • 
Pro C# 5.0 and the .NET 4.5 Framework
  • C# in Depth, Second Edition
  • C# 2010 All-in-One For Dummies
  • Beginning C# Object-Oriented Programming













Loạt bài hướng dẫn học C# cơ bản và nâng cao của chúng tôi dựa trên nguồn tài liệu của:Tutorialspoint
Follow https://www.facebook.com/giaithuatlaptrinhTN/để tiếp tục theo dõi các loạt bài mới nhất về Java,C,C++,Javascript,HTML,Python,Database,Mobile.... mới nhất của chúng tôi.

Đa luồng (Multithread) trong C#

Đa luồng (Multithread) trong C#
Đa luồng (Multithread) trong C#

[Thread trong c#] Một thread được định nghĩa như là một đường thực thi (execution path) của một chương trình. Mỗi Thread định nghĩa một dòng điều khiển duy nhất. Nếu application của bạn gồm các hoạt động phức tạp và tốn thời gian, thì nó thường là rất hữu ích khi thiết lập các execution path hoặc Thread, với mỗi Thread thực hiện một công việc cụ thể.
Các Thread là các tiến trình nhẹ. Một ví dụ phổ biến của sự sử dụng Thread là sự triển khai lập trình tương tranh (concurrent programming) bởi các hệ điều hành hiện đại. Sử dụng các Thread tiếp kiệm sự hao phí của CPU cycle và tăng hiệu quả của một application.
Tới chương này, chúng ta đã viết các chương trình mà một Thread đơn chạy như là một tiến trình đơn, đó là trình chạy thể hiện của application. Tuy nhiên, theo cách này, application có thể thực hiện một công việc tại một thời điểm. Để làm nó thực thi nhiều hơn một tác vụ tại một thời điểm, nó có thể được phân chia thành các Thread nhỏ hơn.

Vòng đời của Thread trong C#

Vòng đời của một Thread bắt đầu khi một đối tượng của lớp System.Threading.Thread được tạo và kết thúc khi Thread đó được kết thúc hoặc hoàn thành việc thực thi.
Dưới đây là các trạng thái đa dạng trong vòng đời của một Thread trong C#:
  • Unstarted State: Nó là tình huống khi instance của Thread được tạo, nhưng phương thức Start chưa được gọi.
  • Ready State: Nó là tình huống khi Thread đó sẵn sàng để chạy và đợi CPU cycle.
  • Not Runnable State: Một Thread là không thể thực thi (not executable), khi:
    • Phương thức Sleep đã được gọi.
    • Phương thức Wait đã được gọi.
    • Bị ngăn chặn bởi hoạt động I/O.
  • Dead State: Nó là tình huống khi Thread hoàn thành sự thực thi hoặc bị hủy bỏ.

Main Thread trong C#

Trong C#, lớp System.Threading.Thread được sử dụng để làm việc với các Thread. Nó cho phép tạo và truy cập các Thread riêng biệt trong một Multithreaded Application. Thread đầu tiên để được thực thi trong một tiến trình được gọi là Main Thread trong C#.
Khi một chương trình C# bắt đầu thực thi, Main Thread được tự động tạo ra. Các Thread, được tạo bởi sử dụng lớp Thread, được gọi các Thread con của Main Thread. Bạn có thể truy cập một Thread bởi sử dụng thuộc tính CurrentThread của lớp Thread.
Dưới đây là chương trình ví dụ minh họa cho sự thực thi Main Thread trong C#:
using System;
using System.Threading;

namespace MultithreadingApplication
{
   class MainThreadProgram
   {
      static void Main(string[] args)
      {
         Thread th = Thread.CurrentThread;
         th.Name = "MainThread";
         Console.WriteLine("This is {0}", th.Name);
         Console.ReadKey();
      }
   }
}
Khi code trên được biên dịch và thực thi, nó sẽ cho kết quả:
This is MainThread

Thuộc tính và Phương thức của lớp Thread trong C#

Bảng dưới liệt kê một số thuộc tính được sử dụng phổ biến nhất của lớp Thread trong C#:
Thuộc tínhMiêu tả
CurrentContextLấy ngữ cảnh (context) hiện tại mà trong đó Thread đang thực thi
CurrentCultureLấy hoặc thiết lập culture gồm language, date, time, currency, … cho Thread hiện tại
CurrentPrincipleLấy hoặc thiết lập nguyên lý hiện tại của Thread
CurrentThreadLấy Thread đang chạy hiện tại
CurrentUICultureLấy hoặc thiết lập culture hiện tại được sử dụng bởi Resource Manager để tìm kiếm cho Resource cụ thể tại runtime
ExecutionContextLấy một đối tượng ExecutionContext mà chứa thông tin về các context đa dạng của Thread hiện tại
IsAliveLấy một giá trị chỉ trạng thái thực thi của Thread hiện tại
IsBackgroundLấy hoặc thiết lập một giá trị chỉ rằng có hay không một Thread là Background Thread
IsThreadPoolThreadLấy một giá trị chỉ rằng có hay không một Thread là của Managed Thread Pool
ManagedThreadIdLấy một định danh duy nhất cho Managed Thread hiện tại
NameLấy hoặc thiết lập tên của Thread
PriorityLấy hoặc thiết lập một giá trị chỉ quyền ưu tiên của một Thread
ThreadStateLấy một giá trị chứa các trạng thái của Thread hiện tại
Bảng này liệt kê các phương thức được sử dụng phổ biến nhất của lớp Thread trong C#:
STTPhương thức
1public void Abort()
Tạo một ThreadAbortException trong Thread mà trên đó nó được triệu hồi, để bắt đầu tiến trình kết thúc Thread đó. Gọi phương thức này thường kết thúc Thread
2public static LocalDataStoreSlot AllocateDataSlot()
Cấp phát một Unnamed Data Slot cho tất cả Thread. Để tăng hiệu suất, sử dụng các Field mà được đánh dấu với attribute là ThreadStaticAttribute để thay thế
3public static LocalDataStoreSlot AllocateNamedDataSlot(string name)
Cấp phát một Named Data Slot cho tất cả Thread. Để tăng hiệu suất, sử dụng các Field mà được đánh dấu với attribute là ThreadStaticAttribute để thay thế
4public static void BeginCriticalRegion()
Thông báo cho một host rằng sự thực thi là chuẩn bị đi vào một khu vực code, mà trong đó các ảnh hưởng của việc hủy bỏ một Thread hoặc các Exception không được xử lý có thể gây nguy hại tới các tác vụ khác trong miền ứng dụng
5public static void BeginThreadAffinity()
Thông báo cho một Host rằng Managed code là chuẩn bị thực thi các chỉ lệnh mà phụ thuộc vào tính đồng nhất của Physical operating system thread hiện tại
6public static void EndCriticalRegion()
Thông báo cho một host rằng sự thực thi là chuẩn bị đi vào một khu vực code, mà trong đó các ảnh hưởng của hủy bỏ một Thread hoặc các Exception không được xử lý bị hạn chế tới tác vụ hiện tại
7public static void EndThreadAffinity()
Thông báo cho một Host rằng Managed code đã kết thúc việc thực thi các chỉ lệnh mà phụ thuộc vào tính đồng nhất của Physical Operating System Thread hiện tại
8public static void FreeNamedDataSlot(string name)
Loại bỏ sự liên kết giữa một name và một slot, cho tất cả Thread trong tiến trình. Để tăng hiệu suất, sử dụng các Field mà được đánh dấu với attribute là ThreadStaticAttribute để thay thế
9public static Object GetData(LocalDataStoreSlot slot)
Thu hồi giá trị từ slot đã xác định trên Thread hiện tại, bên trong miền hiện tại của Thread hiện tại. Để tăng hiệu suất, sử dụng các Field mà được đánh dấu với attribute là ThreadStaticAttribute để thay thế
10public static AppDomain GetDomain()
Trả về miền hiện tại trong đó Thread đang chạy
11public static AppDomain GetDomain()
Trả về một định danh miền ứng dụng duy nhất
12public static LocalDataStoreSlot GetNamedDataSlot(string name)
Tìm kiếm một Named Data Slot. Để tăng hiệu suất, sử dụng các Field mà được đánh dấu với attribute là ThreadStaticAttribute để thay thế
13public void Interrupt()
Interrupt (ngắt) một Thread mà trong trạng thái WaitSleepJoin
14public void Join()
Chặn Thread đang gọi tới khi một Thread kết thúc, trong khi tiếp tục thực hiện COM và SendMessage Pumping. Phương thức này có các mẫu được nạp chồng khác nhau
15public static void MemoryBarrier()
Đồng bộ truy cập bộ nhớ như sau: Prosessor đang thực thi Thread hiện tại không thể sắp xếp lại các chỉ lệnh theo một cách để mà quyền truy cập bộ nhớ tới lời gọi đến MemoryBarrier thực thi sau khi các truy cập bộ nhớ mà theo sau lời gọi đó đến MemoryBarrier
16public static void ResetAbort()
Hủy một Abort được yêu cầu cho Thread hiện tại
17public static void SetData(LocalDataStoreSlot slot, Object data)
Thiết lập dữ liệu trong slot đã cho trên Thread đang chạy hiện tại, cho miền hiện tại của Thread đó. Để tăng hiệu suất, sử dụng các Field mà được đánh dấu với attribute là ThreadStaticAttribute để thay thế
18public void Start()
Bắt đầu một Thread
19public static void Sleep(int millisecondsTimeout)
Làm Thread dừng trong một khoảng thời gian
20public static void SpinWait(int iterations)
Làm một Thread đợi một khoảng thời gian đã được xác định trong tham số iterations
21
public static byte VolatileRead(ref byte address)
public static double VolatileRead(ref double address)
public static int VolatileRead(ref int address)
public static Object VolatileRead(ref Object address)
Đọc giá trị của một Field. Giá trị này là được viết mới nhất bởi bất kỳ Prosessor nào trong một máy tính, không quan tâm đến số lượng Prosessor hoặc trạng thái của Prosessor Cache. Phương thức này có các mẫu được nạp chồng khác nhau. Đó là các form ở trên
22
public static void VolatileWrite(ref byte address,byte value)
public static void VolatileWrite(ref double address, double value)
public static void VolatileWrite(ref int address, int value)
public static void VolatileWrite(ref Object address, Object value)
Ghi một giá trị tới một Field ngay lập tức, để mà giá trị này là nhìn thấy cho tất cả Processor trong máy tính. Phương thức này có các mẫu được nạp chồng khác nhau. Đó là các form ở trên
23public static bool Yield()
Làm Thread đang gọi chuyển sự thực thi cho Thread khác mà đã sẵn sàng để chạy trên Processor hiện tại. Hệ điều hành chọn Thread để chuyển tới

Tạo Thread trong C#

Trong C#, các Thread được tạo bằng việc kế thừa lớp Thread. Sau đó, Lớp Thread được kế thừa gọi phương thức Start() để bắt đầu sự thực thi của Thread con.
Sau đây là ví dụ minh họa việc tạo Thread trong C#:
using System;
using System.Threading;

namespace MultithreadingApplication
{
   class ThreadCreationProgram
   {
      public static void CallToChildThread()
      {
         Console.WriteLine("Child thread starts");
      }
      
      static void Main(string[] args)
      {
         ThreadStart childref = new ThreadStart(CallToChildThread);
         Console.WriteLine("In Main: Creating the Child thread");
         Thread childThread = new Thread(childref);
         childThread.Start();
         Console.ReadKey();
      }
   }
}
Khi code trên được biên dịch và thực thi, nó sẽ cho kết quả:
In Main: Creating the Child thread
Child thread starts

Quản lý Thread trong C#

Lớp Thread trong C# cung cấp các phương thức đa dạng để quản lý các Thread.
Ví dụ sau minh họa cách sử dụng phương thức sleep() để làm một Thread dừng trong một khoảng thời gian cụ thể.
using System;
using System.Threading;

namespace MultithreadingApplication
{
   class ThreadCreationProgram
   {
      public static void CallToChildThread()
      {
         Console.WriteLine("Child thread starts");
         
         // the thread is paused for 5000 milliseconds
         int sleepfor = 5000; 
         
         Console.WriteLine("Child Thread Paused for {0} seconds", sleepfor / 1000);
         Thread.Sleep(sleepfor);
         Console.WriteLine("Child thread resumes");
      }
      
      static void Main(string[] args)
      {
         ThreadStart childref = new ThreadStart(CallToChildThread);
         Console.WriteLine("In Main: Creating the Child thread");
         Thread childThread = new Thread(childref);
         childThread.Start();
         Console.ReadKey();
      }
   }
}
Khi code trên được biên dịch và thực thi, nó sẽ cho kết quả:
In Main: Creating the Child thread
Child thread starts
Child Thread Paused for 5 seconds
Child thread resumes

Hủy Thread trong C#

Phương thức Abort() được sử dụng để hủy các Thread trong C#.
Trong thời gian runtime, chương trình hủy bỏ Thread bằng việc ném mộtThreadAbortException. Exception này không thể được bắt, điều khiển được gửi tới khốifinally, nếu là không.
Dưới đây là chương trình minh họa việc sử dụng phương thức Abort() để hủy bỏ các Thread trong C#:
using System;
using System.Threading;

namespace MultithreadingApplication
{
   class ThreadCreationProgram
   {
      public static void CallToChildThread()
      {
         try
         {
            Console.WriteLine("Child thread starts");
            
            // do some work, like counting to 10
            for (int counter = 0; counter <= 10; counter++)
            {
               Thread.Sleep(500);
               Console.WriteLine(counter);
            }
            
            Console.WriteLine("Child Thread Completed");
         }
         
         catch (ThreadAbortException e)
         {
            Console.WriteLine("Thread Abort Exception");
         }
         finally
         {
            Console.WriteLine("Couldn't catch the Thread Exception");
         }
      }
      
      static void Main(string[] args)
      {
         ThreadStart childref = new ThreadStart(CallToChildThread);
         Console.WriteLine("In Main: Creating the Child thread");
         Thread childThread = new Thread(childref);
         childThread.Start();
         
         //stop the main thread for some time
         Thread.Sleep(2000);
         
         //now abort the child
         Console.WriteLine("In Main: Aborting the Child thread");
         
         childThread.Abort();
         Console.ReadKey();
      }
   }
}
Khi code trên được biên dịch và thực thi, nó sẽ cho kết quả:
In Main: Creating the Child thread
Child thread starts
0
1
2
In Main: Aborting the Child thread
Thread Abort Exception
Couldn't catch the Thread Exception 
Loạt bài hướng dẫn học C# cơ bản và nâng cao của chúng tôi dựa trên nguồn tài liệu của:Tutorialspoint
Follow https://www.facebook.com/giaithuatlaptrinhTN/để tiếp tục theo dõi các loạt bài mới nhất về Java,C,C++,Javascript,HTML,Python,Database,Mobile.... mới nhất của chúng tôi.