Monday, January 25, 2010

VirtualBox - Start up Virtual Machine without gui

So you can ssh into it or whatever

VBoxManage startvm "windows xp" --type headless
VBoxManage controlvm "windows xp" poweroff

Tuesday, January 19, 2010

virtualbox - convert img file to vdi


VBoxManage convertfromraw -format VDI [filename].img [filename].vdi

source(s): http://mdm-adph.blogspot.com/2009/05/using-img-files-with-virtualbox-to-test.html

Monday, January 18, 2010

mysql - get rid of pipe delimiter, and auto escaping

mysql --silent
> select '\\';
\\

When using IO redirection, mysql commandline automatically enters --silent or --batch mode, and auto escapes the output. -r (--raw) is the fix.

mysql -r --silent
> select '\\';
\


mysql -r -D digicert_com < somequery.txt > Desktop/r-queries.txt

source(s): http://bugs.mysql.com/bug.php?id=35122

Tuesday, January 12, 2010

VirtualBox copy harddrive to new uuid

This should work fine with vdi and vmdk files.
VBoxManage clonevdi myhardrive.vdi


source(s): http://www.brianjester.us/blog/index.php?entry=entry080720-165143

Saturday, November 28, 2009

wxWidgets ubuntu linux compile unicode


sudo apt-get install wx-headers libwxbase2.8-0 libwxbase2.8-dev
g++ main.cpp `wx-config --libs` `wx-config --cxxflags`

Friday, November 27, 2009

wxWidgets Sample vcproj file | Unicode


<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
 ProjectType="Visual C++"
 Version="9.00"
 Name="utf8_basic"
 ProjectGUID="{2FA27B9E-AB18-4225-BF22-3D6042C2D6B6}"
 RootNamespace="utf8_basic"
 Keyword="Win32Proj"
 TargetFrameworkVersion="196613"
 >
 <Platforms>
  <Platform
   Name="Win32"
  />
 </Platforms>
 <ToolFiles>
 </ToolFiles>
 <Configurations>
  <Configuration
   Name="Debug|Win32"
   OutputDirectory="$(SolutionDir)$(ConfigurationName)"
   IntermediateDirectory="$(ConfigurationName)"
   ConfigurationType="1"
   CharacterSet="1"
   >
   <Tool
    Name="VCPreBuildEventTool"
   />
   <Tool
    Name="VCCustomBuildTool"
   />
   <Tool
    Name="VCXMLDataGeneratorTool"
   />
   <Tool
    Name="VCWebServiceProxyGeneratorTool"
   />
   <Tool
    Name="VCMIDLTool"
   />
   <Tool
    Name="VCCLCompilerTool"
    Optimization="0"
    AdditionalIncludeDirectories="&quot;C:\Server\wxWidgets-2.8.10\include\msvc&quot;;&quot;C:\Server\wxWidgets-2.8.10\include&quot;"
    PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WINVER=0x0400;__WXMSW__ ;_WINDOWS"
    MinimalRebuild="true"
    BasicRuntimeChecks="3"
    RuntimeLibrary="3"
    UsePrecompiledHeader="0"
    WarningLevel="3"
    DebugInformationFormat="4"
   />
   <Tool
    Name="VCManagedResourceCompilerTool"
   />
   <Tool
    Name="VCResourceCompilerTool"
   />
   <Tool
    Name="VCPreLinkEventTool"
   />
   <Tool
    Name="VCLinkerTool"
    AdditionalDependencies="comctl32.lib rpcrt4.lib winmm.lib advapi32.lib wsock32.lib wxbase28ud.lib wxmsw28ud_core.lib"
    LinkIncremental="2"
    AdditionalLibraryDirectories="&quot;C:\Server\wxWidgets-2.8.10\lib\vc_lib&quot;"
    GenerateDebugInformation="true"
    SubSystem="2"
    TargetMachine="1"
   />
   <Tool
    Name="VCALinkTool"
   />
   <Tool
    Name="VCManifestTool"
   />
   <Tool
    Name="VCXDCMakeTool"
   />
   <Tool
    Name="VCBscMakeTool"
   />
   <Tool
    Name="VCFxCopTool"
   />
   <Tool
    Name="VCAppVerifierTool"
   />
   <Tool
    Name="VCPostBuildEventTool"
   />
  </Configuration>
  <Configuration
   Name="Release|Win32"
   OutputDirectory="$(SolutionDir)$(ConfigurationName)"
   IntermediateDirectory="$(ConfigurationName)"
   ConfigurationType="1"
   CharacterSet="1"
   WholeProgramOptimization="1"
   >
   <Tool
    Name="VCPreBuildEventTool"
   />
   <Tool
    Name="VCCustomBuildTool"
   />
   <Tool
    Name="VCXMLDataGeneratorTool"
   />
   <Tool
    Name="VCWebServiceProxyGeneratorTool"
   />
   <Tool
    Name="VCMIDLTool"
   />
   <Tool
    Name="VCCLCompilerTool"
    Optimization="2"
    EnableIntrinsicFunctions="true"
    AdditionalIncludeDirectories="&quot;C:\Server\wxWidgets-2.8.10\include\msvc&quot;;&quot;C:\Server\wxWidgets-2.8.10\include&quot;"
    PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WINVER=0x0400;__WXMSW__ ;_WINDOWS"
    RuntimeLibrary="2"
    EnableFunctionLevelLinking="true"
    UsePrecompiledHeader="0"
    WarningLevel="3"
    DebugInformationFormat="3"
   />
   <Tool
    Name="VCManagedResourceCompilerTool"
   />
   <Tool
    Name="VCResourceCompilerTool"
   />
   <Tool
    Name="VCPreLinkEventTool"
   />
   <Tool
    Name="VCLinkerTool"
    AdditionalDependencies="comctl32.lib rpcrt4.lib winmm.lib advapi32.lib wsock32.lib wxbase28u.lib  wxmsw28u_core.lib"
    LinkIncremental="1"
    AdditionalLibraryDirectories="&quot;C:\Server\wxWidgets-2.8.10\lib\vc_lib&quot;"
    GenerateDebugInformation="true"
    SubSystem="2"
    OptimizeReferences="2"
    EnableCOMDATFolding="2"
    TargetMachine="1"
   />
   <Tool
    Name="VCALinkTool"
   />
   <Tool
    Name="VCManifestTool"
   />
   <Tool
    Name="VCXDCMakeTool"
   />
   <Tool
    Name="VCBscMakeTool"
   />
   <Tool
    Name="VCFxCopTool"
   />
   <Tool
    Name="VCAppVerifierTool"
   />
   <Tool
    Name="VCPostBuildEventTool"
   />
  </Configuration>
 </Configurations>
 <References>
 </References>
 <Files>
  <Filter
   Name="Source Files"
   Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
   UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
   >
   <File
    RelativePath=".\main.cpp"
    >
   </File>
  </Filter>
  <Filter
   Name="Header Files"
   Filter="h;hpp;hxx;hm;inl;inc;xsd"
   UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
   >
  </Filter>
  <Filter
   Name="Resource Files"
   Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
   UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
   >
  </Filter>
 </Files>
 <Globals>
 </Globals>
</VisualStudioProject>

wxWidgets | Hello World | Unicode | Visual Studio Express 2008

//Project Properties:
//http://wiki.wxwidgets.org/Microsoft_Visual_CPP_Guide
//General>Charset: Use Unicode Character Set (or ansi:not set)
//Include: "C:\Server\wxWidgets-2.8.10\include\msvc";"C:\Server\wxWidgets-2.8.10\include"
//Library: "C:\Server\wxWidgets-2.8.10\lib\vc_lib"
//[preprocessor defines:] WINVER=0x0400;__WXMSW__ ;_WINDOWS
//[linker system subsystem:] Windows (/SUBSYSTEM:WINDOWS)
//[linker libraries (all    ):] comctl32.lib rpcrt4.lib winmm.lib advapi32.lib wsock32.lib 
//[linker libraries (debug  ):] wxbase28ud.lib  wxmsw28ud_core.lib
//[linker libraries (release):] wxbase28u.lib  wxmsw28u_core.lib
//File > Advanced Save Options > UTF8 with signature, CRLF


#include <wx/wx.h>
class MyApp public wxApp
{
  public:
    virtual bool OnInit();
};

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{

    wxFrame *simple new wxFrame(NULLwxID_ANYwxT("你好"), wxDefaultPositionwxSize(250150));
    simple->Centre();
    simple->Show(true);

    return true;

}


wxWidgets 2.8 for windows lib files

lib files
[ansi]
wxexpatd.lib            wxexpat.lib       
wxjpegd.lib             wxjpeg.lib        
wxpngd.lib              wxpng.lib         
wxtiffd.lib             wxtiff.lib        
wxzlibd.lib             wxzlib.lib        

wxregexd.lib            wxregex.lib            
wxbase28d.lib           wxbase28.lib           
wxbase28d_odbc.lib      wxbase28_odbc.lib      
wxbase28d_net.lib       wxbase28_net.lib       
wxbase28d_xml.lib       wxbase28_xml.lib       
wxmsw28d_adv.lib        wxmsw28_adv.lib        
wxmsw28d_aui.lib        wxmsw28_aui.lib        
wxmsw28d_core.lib       wxmsw28_core.lib       
wxmsw28d_dbgrid.lib     wxmsw28_dbgrid.lib     
wxmsw28d_gl.lib         wxmsw28_gl.lib         
wxmsw28d_html.lib       wxmsw28_html.lib       
wxmsw28d_media.lib      wxmsw28_media.lib      
wxmsw28d_qa.lib         wxmsw28_qa.lib         
wxmsw28d_richtext.lib   wxmsw28_richtext.lib   
wxmsw28d_xrc.lib        wxmsw28_xrc.lib        

[unicode]
wxregexud.lib           wxregexu.lib           
wxbase28ud.lib          wxbase28u.lib          
wxbase28ud_odbc.lib     wxbase28u_odbc.lib     
wxbase28ud_net.lib      wxbase28u_net.lib      
wxbase28ud_xml.lib      wxbase28u_xml.lib      
wxmsw28ud_adv.lib       wxmsw28u_adv.lib       
wxmsw28ud_aui.lib       wxmsw28u_aui.lib       
wxmsw28ud_core.lib      wxmsw28u_core.lib      
wxmsw28ud_dbgrid.lib    wxmsw28u_dbgrid.lib    
wxmsw28ud_gl.lib        wxmsw28u_gl.lib        
wxmsw28ud_html.lib      wxmsw28u_html.lib      
wxmsw28ud_media.lib     wxmsw28u_media.lib     
wxmsw28ud_qa.lib        wxmsw28u_qa.lib        
wxmsw28ud_richtext.lib  wxmsw28u_richtext.lib  
wxmsw28ud_xrc.lib       wxmsw28u_xrc.lib       

Wednesday, November 18, 2009

golang setup

put the following in your .bashrc

export GOROOT=$HOME/go
export GOARCH=386
export GOOS=linux
export GOBIN=~/bin/
export PATH=$PATH:~/bin/

then follow
http://golang.org/doc/install.html

Wednesday, October 28, 2009

ubuntu firewall


sudo apt-get denyhosts
sudo apt-get install ufw
sudo apt-get install gufw
sudo ufw status
sudo ufw enable
sudo ufw limit ssh/tcp
sudo ufw allow proto tcp from 192.168.1.0/24 to any port 22

Tuesday, October 13, 2009

wxwidgets screenshot


wxWidgets wxMemoryDC

wxScreenDC dcScreen;
wxCoord screenWidth, screenHeight;
dcScreen.GetSize(&screenWidth, &screenHeight);
wxBitmap screenshot(screenWidth, screenHeight,-1);
wxMemoryDC memDC;
memDC.SelectObject(screenshot);
memDC.Blit( 0, 0, screenWidth, screenHeight, &dcScreen, 0, 0);
memDC.SelectObject(wxNullBitmap);

http://trac.wxwidgets.org/ticket/11007






source(s): http://www.source.com

vaccum a firefox sqlite database

in the firefox-error console type the following:
Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsPIPlacesDatabase).DBConnection.executeSimpleSQL("VACUUM");


in the firefox profiles folder. look for: *.sqlite

Friday, September 11, 2009

rsync -C or --cvs-exclude

rsync -C option excludes .exe files by default so if you want to rsync .exe files add in
--include=*.exe

Which filetypes does cvs ignore? Then.. which filetypes does rsync ignore ontop of the cvs ignores. From man pages (man rsync):


-C, --cvs-exclude
This is a useful shorthand for excluding a broad range of files that you often don’t want to transfer between systems. It uses a similar algorithm to CVS to determine if a file should be ignored.


The exclude list is initialized to exclude the following items (these initial items are marked as perishable — see the FILTER RULES section):


RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS .make.state .nse_depinfo *~ #* .#* ,* _$* *$ *.old *.bak *.BAK *.orig *.rej .del-* *.a *.olb *.o *.obj *.so *.exe *.Z *.elc *.ln core .svn/ .git/ .bzr


then, files listed in a $HOME/.cvsignore are added to the list and any files listed in the CVSIGNORE environment variable (all cvsignore names are delimited by whitespace).


Finally, any file is ignored if it is in the same directory as a .cvsignore file and matches one of the patterns listed therein. Unlike rsync’s filter/exclude files, these patterns are split on whitespace. See the cvs(1) manual for more information.


If you’re combining -C with your own --filter rules, you should note that these CVS excludes are appended at the end of your own rules, regardless of where the -C was placed on the command-line. This makes them a lower priority than any rules you specified explicitly. If you want to control where these CVS excludes get inserted into your filter rules, you should omit the -C as a command-line option and use a combination of --filter=:C and --filter=-C (either on your command-line or by putting the “:C” and “-C” rules into a filter file with your other rules). The first option turns on the per-directory scanning for the .cvsignore file. The second option does a one-time import of the CVS excludes mentioned above.

Thursday, September 03, 2009

modification to zetcode tutorial

wxwidgets tutorial at
http://zetcode.com/tutorials/wxwidgetstutorial/menustoolbars/

has the line
wxBitmap exit(wxT("exit.png"));


I get the error in a windows compiler
"failed in wxToolbar::Realize(): invalid tool button bitmap"

the fix:
replace that line with
wxImage exitimage(wxT("exit.png"), wxBITMAP_TYPE_PNG);
wxBitmap exit(exitimage);



note:
don't forget to include #include
and call wxInitAllImageHandlers(); in your app init

wx widgets icon for your app

in windows build a file call main.rc with the following contents:


aaaaaaaaaaaaaaaa ICON "application_icon.ico"
application_icon ICON "application_icon.ico"
#define wxUSE_NO_MANIFEST 1
// set this to 1 if you don't want to
// use manifest resource (manifest resource
// is needed to enable visual styles on
// Windows XP - see docs/msw/winxp.txt
// for more information)
#include <wx/msw/wx.rc>


the windows compiler sets the first icon to be the .exe icon... and the 2nd is referenced in the code:


Then in your Frame constructor

#if !defined(__WXMSW__) && !defined(__WXPM__)
#include "application_icon.xpm"
#endif
SimpleMenu::SimpleMenu(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(280, 180))
{

SetIcon( wxICON( application_icon ) );
...


you can use gimp to build your xpm and and ico files. If you rename your xpm file at all... edit it with a text editor and make sure the c string in it reads:
application_icon_xpm if the filename is application_icon.xpm

wxWidgets - rc file "wx/msw/wx.rc" not found

using visual studio express 2008
with an .rc file that has:
#include "wx/msw/wx.rc"

Error: "wx/msw/wx.rc" not found

the fix:
Even though you have already set the include path for your whole project to include wxwidgets... you need to set the include path again for the .rc file. Select main.rc... go up to project properties and you will see a smaller menu, and a place to put the Include path again.

wxWidgets - No Image Handler Defined

wxWidgets

Error: No Image Handler Defined

the fix:
wxInitAllImageHandlers();

Friday, August 21, 2009

use array_map to select 1 column out of rowset of php rows

Given a series of rows of data (perhaps rows in a database, copied into memory), we want to extract only 1 field of data and put it into a comma delimited list. (or array to loop through).


$arr = array();
$arr[] = array('first'=>'jack','last'=>'smith');
$arr[] = array('first'=>'john','last'=>'williams');
$arr[] = array('first'=>'mark','last'=>'jesperson');
$arr[] = array('first'=>'vlad','last'=>'shuttleworth');

$f = array_map(create_function('$a', 'return $a["first"];') , $arr);
echo implode(",", $f);
//outputs:
//jack,john,mark,vlad

Friday, July 31, 2009

numbers from 001 to 999

the numbers from 001 to 999

echo "<?php for(\$i=1; \$i<=999; \$i++){ echo sprintf('%03d',\$i).chr(10);} ?>"|php


The \ has to go before the $ character because $i can refer to the command line environment variable $i, so we escape it with \$i in order to pass it straight through to the php parser.