Category: Programming Languages

Calling APIs inside SquareSpace

Square space is a no code platform. You are constrained by what it provides. Let’s consider you are developing a website to display your favorite books. You want to dynamically query a URL and display the data in your website. There isn’t a straightforward way to do this now. In this tutorial I will explain

Continue Reading →

ipps90legacy.h not found error

Goto https://software.intel.com/en-us/articles/intel-ipp-legacy-libraries and download the links for your OS. Then follow the installation text file inside the zipped file. The password is specified in the installation file. Once downloaded extract the headers and libs into the proper folder. e.g. /opt/intel/include…

Continue Reading →

Create a timer using Web Workers/Javascript

If you don’t know about web workers learn them here: https://developer.mozilla.org/en-US/docs/Web/Guide/Performance/Using_web_workers Disclaimer: Might not follow strict coding standards, this is just a demo. This post basically shows how you can use webworkers to display a timer. For this I will be using the following files: a. index.php b. worker.js Inside your index.php, lets write some

Continue Reading →

MFC / Javascripts / CSS Integrations

Nowadays it feels like everywhere and everyone is using HTML. So why not use it for building a MFC based application by using lesser and lesser MFC dialogs. Lets start by creating a MFC application using visual studio any version is fine. Open up visual studio as below, and create a new MFC based application

Continue Reading →

Lua regex / string helpers

Match empty parenthesis pair, such as () or ( ), you use the pattern ‘%(%s*%)’ ‘[0-9]’ is simpler when written as ‘%d’, ‘[0-9a-fA-F]’ is the same as ‘%x’ .                    all characters %a                letters %c           

Continue Reading →

ARC – Disabling arc for specific files

Sometimes while including projects or files not developed by you, it would be necessary to go ahead and disable this option. To do this, goto your project settings, build phases, expand compile sources, click on a specific file and add this option to the compiler settings -fno-objc-arc That should do the trick. happy coding.

Continue Reading →

Heapsort implementation in C++

// // heapSort.cpp // learnCpp // // Copyright 2011 __MyCompanyName__. All rights reserved. // #include using namespace std; void display(int a[], int n) { cout<<” ————— “<<endl; for (int i=0;i<5; ++i) { cout<<a[i]<<endl; } } void heapify(int a[], int n) { int i,j,k,item; for(k=1; k0 && item > a[j]) { // if parent exists and

Continue Reading →

eclipse pydev error – not finding

I just compiled and installed mysqldb for python 2.7 on my mac os 10.7. import MySQLdb as mysql def main(): conn = mysql.connect( charset=”utf8″, use_unicode=True, host=”localhost”,user=”root”, passwd=””,db=”” ) if __name__ == ‘__main__'(): main() When executing it I get the following error message Traceback (most recent call last): File “/path/to/project/Python/src/cvdv/TestMySQLdb.py”, line 4, in import MySQLdb as

Continue Reading →

Resolve C2872 errors: ambiguous symbol

4>g:worktest.cpp(119): error C2872: ‘CRegKey’ : ambiguous symbol 4> could be ‘g:workwindowscregkey.h(33) : CRegKey’ 4> or ‘c:program files (x86)microsoft visual studio 10.0vcatlmfcincludeatlbase.h(5459) : ATL::CRegKey’ In case you have such issues, the easiest way to resolve them would be to use ::CRegKey in front of the keyword. This will call the local libraries first.

Continue Reading →

Iterate through all the tabs in Internet Explorer Windows

I found this code useful when you want to go through each tab and then look into their URLs and so on. You can also quit each tab individually. [sourcecode lang=”cpp”] // Implementation #include #include typedef BOOL (CALLBACK * IEENUMPROC)(HWND hwnd, LPVOID pif, LPARAM lParam); static BOOL CALLBACK EnumIEChildWindows(HWND hwnd, LPARAM lParam) { TCHAR szClassName[100];

Continue Reading →

IHTMLCollection iterating through HTML frames / GUI manipulation

LRESULT lResult; UINT nMsg = ::RegisterWindowMessage( _T(“WM_HTML_GETOBJECT”) ); ::SendMessageTimeout( handleToInternetExplorerWindow, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lResult); LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)::GetProcAddress( hInst, “ObjectFromLresult” ); HRESULT hr; CComPtr htmlDoc2; hr = (*pfObjectFromLresult)( lRes, IID_IHTMLDocument2, 0, (void**)&htmlDoc2); if ( SUCCEEDED(hr) ) { IHTMLFramesCollection2 *p; htmlDoc2->get_frames(&p); long lLen; p->get_length(&lLen); for (long i = 0; i < lLen; i++) {

Continue Reading →

_SECURE_SCL issues

Be careful when using _SECURE_SCL option when integrating your DLLs with DLLs you received from someone else. If you have compiled your dlls with this option but the dlls you use havent, you are most likely going to get a runtime application compatibility error. To fix this just remove this option. When secure SCL is

Continue Reading →

Getting the parent id of a process

Below is the code to return the parent id of a process, given a process id. This can be helpful in circumstances when we have to scan all the running processes to find out the spawned processes from another process. [code language=”cpp”] // change this method signature according to your requirements BOOL GetParentPID( DWORD dwParentId,

Continue Reading →

Using Virtual Box COM APIs to list the Virtual machine snapshots

int Helper_ReturnVms(IVirtualBox *virtualBox) { HRESULT rc; bool bFound=false; /* * First we have to get a list of all registered VMs */ SAFEARRAY *machinesArray = NULL; rc = virtualBox->get_Machines(&machinesArray); if(FAILED(rc)) { SafeArrayDestroy (machinesArray); return -1; } IMachine **machines; rc = SafeArrayAccessData (machinesArray, (void **) &machines); if(FAILED(rc)) { SafeArrayUnaccessData (machinesArray); SafeArrayDestroy (machinesArray); return -1; } for

Continue Reading →

Static analysis of C/C++ code using cppcheck

Download cppcheck from here: http://cppcheck.sourceforge.net/ some of the things you can find out by running cppcheck on your code is: 1) Summary: Possible inefficient checking for ‘idList’ emptiness. Message: Checking for ‘idList’ emptiness might be inefficient. Using idList.empty() instead of idList.size() can be faster. idList.size() can take linear time but idList.empty() is guaranteed to take

Continue Reading →

difference between lua find and c++ find

Lua: string.find(“testthis”, 5,5,7) this is going to give you “th”. Meaning it will start from the 5th letter and give the next letters between 5 and 7. C++ / C string str=”testthis” str.find(5,5); this will start from the fifth element and give you the next 5 letters. Basically in lua, it gives the letters between

Continue Reading →

Qt how to add torch / flash in your phone

Are you getting QCameraExposure is not found??? Then goto your project file and add the following: CONFIG += mobility MOBILITY += contacts messaging multimedia systeminfo # Self-signing capabilities symbian:TARGET.CAPABILITY += NetworkServices ReadUserData WriteUserData LocalServices UserEnvironment // in header file QCamera *qcam; QCameraFlashControl *qcamflash; QCameraExposure *qcamexp; // in cpp file qcam = new QCamera(); qcamexp =

Continue Reading →

loading C++ libs in linux with Qt

1) Create ur qt project. 2) include all the header files in your project. 3) Use appropriate namespaces 4) Important part: linking against your libraries In your .pro file, use : LIBS += -L”/home/test/Desktop/test-build-desktop/” -lLibrary1 -lLibrary2 Here library1 and 2 are the names of the libraries i link against. 5) Now from the command prompt

Continue Reading →

reading messages from message table

Sometimes data is also stored as message instead of resources. the easiest way to read this is as below: ofstream myfile; myfile.open (“example.txt”); HMODULE handle = LoadLibrary(“AgentRes.dll”); // dll for reading the file DWORD err=::GetLastError(); for(int i=0;i<10000;i++) { LPTSTR    lpMsgBuffer=NULL; DWORD dwRet=FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE, handle, i, // number of the corresponding message // you

Continue Reading →

Windows debugging using windbg

Sometimes or most times when you get a crash dump from your customer, its always good to know how to reproduce the crash and point out where the actual crash happens. Today I was debugging some bug with my lead, I found this very useful: Here are the steps: First of all open the windows

Continue Reading →

Hacking into DLLs [ COM ]

This is especially useful when you want to use someone else’s dlls. 1) Open the dll in windows dependency viewer: You should see the following, if its a COM dll. This basically is related to COM. If you go through COM tutorials you will know about this. 1)  next open the dll you need in

Continue Reading →

Replace switch statement by function pointers

//———————————————————————————— // 1.2 Introductory Example or How to Replace a Switch-Statement // Task: Perform one of the four basic arithmetic operations specified by the // characters ‘+’, ‘-‘, ‘*’ or ‘/’. // The four arithmetic operations … one of these functions is selected // at runtime with a switch or a function pointer float Plus

Continue Reading →

Using DebugBreak()

I learnt this from my manager. DebugBreak is powerful tool you can use when debugging applications. I had this scenario where I need to use a java app which was internally calling C++ methods, basically JNI functions. The error in question was in the C++ side, so not really an option to use debugger. Therefore

Continue Reading →