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
import logging | |
import pythonjsonlogger.jsonlogger | |
import datetime | |
def testJsonFormatter(): | |
supported_keys = [ | |
'asctime', | |
'created', | |
'filename', |
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
#include <windows.h> | |
#include <memory> | |
#pragma comment(lib, "version.lib") | |
#define ERR_INVALID_DLL_PATH 0x81000001 | |
#define ERR_INVALID_POINTER 0x81000002 | |
#define ERR_NAME_NOT_FOUND_OR_INVALID_RESOURCE 0x81000003 | |
#define ERR_NO_VALUE_AVAILABLE 0x81000004 | |
#define SUCCESS 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
std::wstring wstr = L"123"; | |
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> cv; | |
std::string str = cv.to_bytes(wip); |
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; | |
class BaseClass : IDisposable | |
{ | |
// Flag: Has Dispose already been called? | |
bool disposed = false; | |
// Public implementation of Dispose pattern callable by consumers. | |
public void Dispose() | |
{ |
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
#include <functional> | |
#include <iostream> | |
#include <stdio.h> | |
using namespace std; | |
extern function<int(int, function<int(int)>)> g; | |
auto f = [](int n, function<int(int)> h) | |
{ | |
if (n >= 5) return n; |
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
#include <windows.h> | |
HBITMAP WINAPI GetBits(HBITMAP h, LONG width, LONG height, WORD bitCount, BYTE **bytes, DWORD *bytesLen) | |
{ | |
// Sanity check omitted. | |
HDC hdcScreen; | |
hdcScreen = GetDC(NULL); | |
if (hdcScreen == NULL) | |
{ |
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
/** | |
* @file SampleDoxygenAnnotations.h | |
* @author My Self | |
* @date 9 Sep 2016 | |
* @brief File containing examples of doxygen usage for quick reference. | |
* | |
* Here typically goes a more extensive explanation of what the header | |
* defines. Doxygens tags are words preceeded by either a backslash @\ | |
* or by an at symbol @@. | |
* @see http://www.stack.nl/~dimitri/doxygen/docblocks.html |
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
<!-- Save this file to as SampleLog4netConfigfile.config and load it with the following code inside the AssemblyInfo.cs file | |
of the project: | |
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "SampleLog4netConfigfile.config", Watch = true)] | |
After this, log4net library can be used inside the project. For example, logger variables can be defined as private static | |
variables: | |
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
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
class SamplePrint | |
{ | |
public bool Print(string printer) | |
{ | |
if(string.IsNullOrEmpty(printer)) | |
return false; | |
bool ret = false; | |
try | |
{ |
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
static class SampleAESEncryptDecrypt | |
{ | |
static void Main() | |
{ | |
string original = "The data to encrypt."; | |
using (AesCryptoServiceProvider aes = new AesCryptoServiceProvider()) | |
{ | |
// Setting a key size disposes the previously-set key. | |
// Setting a key size is redundant if a key going to be set after this statement. |