Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Sunday, August 5, 2012

MySQL drop all tables that follow a pattern

Playing around with drupal I had to drop all tables that were created by a module. To do so I used the following chain of commands :
mysql -u your_user -D your_database_name -e "show tables" -s | 
  egrep "^Whatever_" | 
  xargs -I "@@" echo mysql -u your_user -D your_database_name -e "DROP TABLE @@"

This will print out all the shell commands to drop the tables beginning with "Whatever_" (note the ^ regex notation). If you want it to actually execute those commands, remove the word "echo".

Thursday, December 15, 2011

strcasecmp: identifier not found when porting from linux to windows

Ever tried to port from linux to windows and got the :

error C3861: 'strcasecmp': identifier not found

The easiest workaround is to add a  conditional define (visual studio add the –D _WIN32 or _WIN64 depending your OS) and define the following mappings:

#if defined(_WIN32) || defined(_WIN64)
  #define snprintf _snprintf
  #define vsnprintf _vsnprintf
  #define strcasecmp _stricmp
  #define strncasecmp _strnicmp
#endif

Another common missing identifier is the Uint which can be solved adding:

#define uint=unsigned int