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 <fcntl.h> | |
#include <io.h> | |
// | |
class EnableConsole | |
{ | |
FILE * fp; | |
public: | |
~EnableConsole() | |
{ |
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
# coding = utf-8 | |
from django.utils.module_loading import import_string | |
from django.utils.functional import cached_property | |
from django.template.engine import _dirs_undefined | |
from django.template.backends.base import BaseEngine | |
from django.template.backends.utils import csrf_input_lazy, csrf_token_lazy | |
from django.template.context import _builtin_context_processors | |
from mako.lookup import TemplateLookup |
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
from django.forms.models import model_to_dict | |
authors = [] | |
for author in Author.objects.prefetch_related("books"): | |
books = [model_to_dict(book, ["name", "price"]) for book in author.books.all()] | |
author = model_to_dict(author, ["name", "age"]) | |
author["books"] = books | |
authors.append(author) | |
# json.dumps(authors) |
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
// .h | |
void __fastcall AcceptFiles (TMessage& Msg); | |
BEGIN_MESSAGE_MAP | |
MESSAGE_HANDLER(WM_DROPFILES, TMessage, AcceptFiles) | |
END_MESSAGE_MAP(TForm) | |
// .cpp | |
__fastcall TFormMain::TFormMain(TComponent* Owner) | |
: TForm(Owner) |
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
// | |
AnsiString GetFileVersion(AnsiString Path) | |
{ | |
AnsiString asReturn; | |
DWORD dwHandle,InfoSize; | |
InfoSize = GetFileVersionInfoSize(Path.c_str(),&dwHandle); | |
if(InfoSize == 0) return ""; | |
//将版本信息资源读入缓冲区 | |
char *InfoBuf = new char[InfoSize]; |
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
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); | |
if (mBluetoothAdapter == null) { | |
// Device does not support Bluetooth | |
} else { | |
if (!mBluetoothAdapter.isEnabled()) { | |
// Bluetooth is not enable :) | |
} | |
} |
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
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
getMenuInflater().inflate(R.menu.action_menu, menu); | |
return true; | |
} |
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
TSearchRec SearchRec; | |
int Attr = faAnyFile; | |
int Ret = FindFirst(FolderPath + "\\*.*", Attr, SearchRec); | |
while(Ret == 0) | |
{ | |
if(AnsiString(SearchRec.Name) == "." || AnsiString(SearchRec.Name) == "..") | |
{ | |
} |
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
HANDLE mMutexOneInstance; | |
UINT mMsgLaunched; | |
mMsgLaunched = RegisterWindowMessage(_T("SOMETHING")); | |
mMutexOneInstance = ::CreateMutex(NULL, FALSE, _T("MY_APP_ONE_INSTANCE")); | |
if((mMutexOneInstance != NULL) && (GetLastError() != ERROR_ALREADY_EXISTS)) | |
{ | |
CMyDlg dlg; | |
dlg.DoModal(); |
OlderNewer