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.

Thursday, July 30, 2009

output formatting like command line sql

--usage1----------

$sql = '';
$sql.="SELECT fieldtype, count(1) as count ";
$sql.="FROM mytable ";
$sql.="GROUP BY fieldtype ";
$sql.="ORDER BY fieldtype ";
echo report_append("summary of data", $sql);

--output1---------
|fieldtype|count|
|0 |9 |
|1 |397 |
|2 |965 |
|3 |554 |
|4 |683 |
|5 |1352 |
|6 |1390 |
|7 |237 |
|8 |1372 |


--usage2----------
$q='';
$q.="SELECT
(case
when fieldtype=1 then 'Apple'
when fieldtype=2 then 'Banana'
when fieldtype=3 then 'Blackberry'
when fieldtype=4 then 'Cherry'
when fieldtype=5 then 'Grape'
when fieldtype=6 then 'Orange'
when fieldtype=7 then 'Peach'
when fieldtype=8 then 'Pear'
else '' end) as typename, fieldtype, count(1) as count
FROM mytable d GROUP BY fieldtype ORDER by fieldtyped;
";
report_append("summary of data", $q);

--output2---------
|typename  |fieldtype|count|
| |0 |9 |
|Apple |1 |397 |
|Banana |2 |965 |
|Blackberry|3 |554 |
|Cherry |4 |683 |
|Grape |5 |1352 |
|Orange |6 |1390 |
|Peach |7 |237 |
|Pear |8 |1372 |

--code------------

function select_all($sql)

{
$rows = array();
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
$rows[] = $row;
return $rows;
}
function report_append($title,$sql)
{

$rows = select_all($sql);

$headersize=array();
$header=array();
foreach($rows[0] as $colname=>$col)
$header[]=$colname;
foreach($rows[0] as $colname=>$col)
$headersize[] = strlen($colname);
foreach($rows as $row)
foreach($headersize as $colnum=>$col)
$headersize[$colnum] = max( $headersize[$colnum] , strlen($row[$header[$colnum]]) );

$h='';
foreach($header as $colnum=>$colname)
$h.="|".sprintf("%-".$headersize[$colnum]."s", $colname);
$h.= "|\n";
foreach($rows as $row)
{
foreach($headersize as $colnum=>$col)
$h.="|".sprintf("%-".$col."s", $row[$header[$colnum]]);
$h.= "|\n";
}

$return='';
$return.="---------------------------------------------------------\n";
$return.="$title\n";
$return.="---------------------------------------------------------\n";
$return.=$h;
return $return;
}

Monday, July 20, 2009

Crontab daily gui app launcher, and taskkill

10 17 * * 1-5 killall pidgin
8 10 * * 1-5 if ! ps -C pidgin > /dev/null; then export DISPLAY=:0 && pidgin; fi

Friday, July 10, 2009

common pitfalls when going from html to xhtml

common pitfalls when going from html to xhtml
-------------------------------------------------
<img /><br /><input /> #good, bad: <img><br><input>
<i><b>hi</b></i> #good, bad: <b><i>hi</b></i>
<a href=""></a> #good, bad: <a href=''></a>
<a href="a=b&amp;c=d"></a> #good, bad: <a href="a=b&c=d"></a>
&#160; #good, bad: &nbsp;

Friday, June 12, 2009

Monday, June 08, 2009

smbfs smbmount are deprecated, use cifs

mount -t cifs -o username=guest \\\\192.168.0.97\\share /home/share-buff/

Friday, June 05, 2009

postgres age function

select dob,extract(year from AGE(dob                  )) from dob_table limit 1;
select dob,extract(year from AGE(now(), dob )) from dob_table limit 1;
select dob,extract(year from AGE(current_timestamp,dob)) from dob_table limit 1;
select dob,extract(year from AGE('2009-09-10', dob )) from dob_table limit 1;
select dob,to_char(AGE(dob),'YYYY')::integer from dob_table limit 1;
select dob,substr(AGE(dob)::text,1,3) from dob_table limit 1;

Tuesday, June 02, 2009

Cross Browser Compatible Javascript DOMelement function

In the past... you had to do
//------------
var a = document.createElement('div');
a.setAttribute('class','myclass');
a.setAttribute('id','id_mydiv');
document.getElementById('otherdiv').appendChild(a);

//------------
to create a dom element... and it only worked in firefox. to get one that works in internet explorer you have to do:
//------------
var a;
try {
  a = document.createElement('<div class=myclass id=id_mydiv>');
}
catch(e) {
  a = document.createElement('div');
  a.setAttribute('class','myclass');
  a.setAttribute('id','id_mydiv');
}
document.getElementById('otherdiv').appendChild(a);

//------------
include the function below, and it will work in both browsers:
//------------
var a = DOMelement('div','class':'myclass','id':'id_mydiv');
document.getElementById('otherdiv').appendChild(a);

//------------

function DOMelement(elementname,attributes)
{
  var htmlspecial = function(tmp_str){
    var histogram = {"&":"&amp;","'":"&#39;", "\"":"&#34;","<":"&lt;",">":"&gt;"};
    for (symbol in histogram)
      tmp_str = tmp_str.split(symbol).join(histogram[symbol]);
    return tmp_str;
  }
  var element;
  try{
    var attribute_str = '';
    for(attribute_name in attributes)
      if (attribute_name!='text')
        attribute_str+= attribute_name+"='"+htmlspecial(o.attributes[attribute_name])+"'";
    element = document.createElement("<"+elementname+" "+attribute_str + ">");//IE
  }catch (e){
    element = document.createElement( elementname );
    for(attribute_name in attributes)
      if (attribute_name!='text')
        element.setAttribute( attribute_name , attributes[attribute_name] );
  }
  if (attributes && attributes['text'])
    element.innerHTML = attributes['text'];
  return element;
}

Thursday, May 28, 2009

iPod Touch

For the economically minded consumer who doesn't need the phone, cell phone camera or gps, but has wi-fi and just needs a solid pda get the ipod touch 8GB 2nd generation. I got a refurbished one for $179.00, and for my chinese work, it is amazing. It does chinese stroke recognition, there are free chinese dictionary apps, skype is came out with a free app as well.



Accessories:

However to use skype you need a microphone for your ipod touch. The charger that comes with it charges off of your computer so if you go on vacation you will need a wall and/or car charger. You will also want to get an audio/video cable set so you can project videos onto your tv set.

JVC Everio

The JVC Everio offers several models. Probably one of the most appealing thing about the everio is that it records to MPEG2 (uncompressed DVD) instead of MPEG4 (highly compressed like a digital camera's video). Its resolution is also DVD resolution 720x480, however it is more like tv quality (interlaced video) and less like digital HD.

It is offering a JVC Everio GZ-MS100 model right now for $180, which is really nice, considering that flash memory will continue to get cheaper. So instead of paying $350 for a hard drive camcorder... get a flash based one, and get a 2GB SD card. In a few years 8GB and 16GB SDHC cards will be cheap, and you can just use that for your camcorder.


For accessories it might be a good idea to get an extra JVC Everio battery. Because even if you have space to record 4 hours of video on your SD card, it doesn't mean your video camera battery will last that long

Tuesday, May 26, 2009

nohup command

nohup ./myscript.sh>log_myscript.log 2>&1 &
tail -f log_myscript.log

nohup ./myscript.sh>log_myscript_`date +%Y%m%d`.log 2>&1 &
tail -f log_myscript_`date +%Y%m%d`.log

`date +%Y%m%d` - grabs current date, inserts it into filename
nohup - script run even after terminal/ssh session ends
>log_myscri... - captures output to log file named log_myscr..
2>&1 - outputs stderr to stdout
& - makes it run in the background
tail -f - watches log, CTRL-C will not stop script

Sunday, May 24, 2009

rsync windows to linux

Scenario: windows has your user data and linux is your backup server.

1. compile cygwin... use the following, place them in your path
(c:\windows\system32 or c:\server\bin\)
rsync.exe
ssh.exe
ssh-keygen.exe
cygcrypto-0.9.8.dll
cygiconv-2.dll
cygintl-8.dll
cygminires.dll
cygpopt-0.dll
cygwin1.dll
cygz.dll

2. on the windows machine, run ssh-keygen at the command promptit will create a file
C:\Documents and Settings\user\.ssh\id_dsa.pub

3. copy C:\Documents and Settings\user\.ssh\id_dsa.pub to the linux machine... then authorize it:
mkdir ~/.ssh
cat id_dsa.pub >>~/.ssh/authorized_keys2
mkdir ~/backups

4. If you want to rsync F:\apps\myfolder then save the following as... backup.bat
-----------
F:
cd \apps
"c:\server\bin\rsync.exe" -arv -e "c:\server\bin\ssh.exe" myfolder user@linux:/home/user/backups/
-----------

Tuesday, May 19, 2009

gpg crontab

1. executing in crontab provides a different set of environment variables, so the --homedir is needed to specify which keyring to use. In the example below, we use root's keyring.
2. --batch is necessary for crontabs because it tells gpg there is no user to interact with
3. 2>&1 is useful because it redirects stderr to stdout so you can better debug any errors you may be having
4. -d is for decrypt. in this case we are decrypting on a cron job

/usr/bin/gpg --batch --homedir /root/.gnupg --passphrase mypassphrase -o /home/output.csv -d /home/input.csv.gpg 2>&1

Monday, April 20, 2009

Curl HTTP Authentication

// HTTP authentication
$url = "http://www.example.com/protected/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "myusername:mypassword");
$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>



source(s): http://devzone.zend.com/article/1081-Using-cURL-and-libcurl-with-PHP

Sunday, April 19, 2009

FLTK in Visual C++ Express 2008

FLTK in Visual C++ Express 2008

1. Download fltk-1.1.9-source.zip
2. Unzip to C:\Server\fltk-1.1.9\
3. Your include folder is C:\Server\fltk-1.1.9\FL\
4. Your lib folder is C:\Server\fltk-1.1.9\include\
5. Go into C:\Server\fltk-1.1.9\vc2005\
6. Open fltk.sln
7. Compile as Debug
8. Compile as Release


9. Build your hello world.
(http://www.fltk.org/documentation.php/doc-1.1/basics.html)

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>

int main(int argc, char **argv) {
  Fl_Window *window = new Fl_Window(300,180);
  Fl_Box *box = new Fl_Box(20,40,260,100,"Hello, World!");
  box->box(FL_UP_BOX);
  box->labelsize(36);
  box->labelfont(FL_BOLD+FL_ITALIC);
  box->labeltype(FL_SHADOW_LABEL);
  window->end();
  window->show(argc, argv);
  return Fl::run();
}


10. Configure the following in your project in Visual C++ Express 2008:

Tools > Options > Projects and Solutions > VC++ Directories >
  INCLUDE: C:\Server\fltk-1.1.9
  LIB: C:\Server\fltk-1.1.9\lib

Project > Project Properties > [Debug and Release] > Linker
    > Input > Additional Dependencies
  wsock32.lib fltk.lib comctl32.lib

Thursday, April 02, 2009

setup vnc server on fedora


# assume we are setting it up to vnc as bsmith
su -

# as root: verify current ip address
ifconfig

# as root: install if needed
yum install vnc-server

# as root: uncomment out 2 lines, replace myusername with bsmith
vim /etc/sysconfig/vncservers

# as bsmith: set vnc password
vncpasswd

# as root: generates ~/.vnc/xstartup
service vncserver start

# as root: sets service to startup with machine
chkconfig vncserver on

# as root: uncomment out line 4 and 5
vim /bsmith/.vnc/xstartup

# as root: applies settings
service vncserver start

# as root: open up port in firewall, note vnc is insecure by protocol
vim /etc/sysconfig/iptables

# as root: apply firewall changes, vnc=insecure so better to use over lan
service iptables restart

Thursday, March 26, 2009

C/C++ win32 programming tutorials and open source projects

http://sourceforge.net/projects/sonne/
http://sourceforge.net/projects/cinputbox/
http://sourceforge.net/projects/win32net/
http://sourceforge.net/projects/notepad-plus/
http://sourceforge.net/projects/smartwin/
http://sourceforge.net/projects/radcpp/
http://sourceforge.net/projects/pwrgrid/
http://sourceforge.net/projects/gettext/
http://sourceforge.net/projects/gqview-win/
http://sourceforge.net/projects/win32gui/
http://sourceforge.net/projects/big3dsol/
http://sourceforge.net/projects/bhwindow/
http://sourceforge.net/projects/mancalacpp/
http://sourceforge.net/projects/win32-framework/

http://winprog.org/tutorial/
http://www.winprog.org/tutorial/msvc.html
http://www.relisoft.com/win32/index.htm
http://www.suite101.com/blog/leckyt/win32_programming_tutorial
http://www.functionx.com/win32/index.htm
http://www.functionx.com/win32/Lesson01.htm
http://www.nullterminator.net/opengl32.html
http://www.zetcode.com/tutorials/winapi/
http://www.vczx.com/tutorial/win32-tutorial/index.html
http://www.tenouk.com/cnwin32tutorials.html
http://www.sgi.com/products/software/opengl/examples/win32_tutorial/
http://www.geocities.com/Heartland/Meadows/9818/win32tut/index.html
http://www.relisoft.com/Win32/winnie.html

Monday, March 23, 2009

sunspider benchmark ie8, ff3.5, safari4, chrome

IE7
Total: 52562.6ms +/- 1.8%
IE8
Total: 8459.8ms +/- 0.3%
Safari4
Total: 1411.2ms +/- 0.6%
Chrome1
Total: 1783.6ms +/- 6.5%
Firefox
Total: 4727.8ms +/- 0.6%
FF3.0
Total: 4831.0ms +/- 3.6%
FF3.5
Total: 2551.4ms +/- 11.5%

Sunday, March 22, 2009

utf8 in mysql

select CONCAT('V',x'c3a1','zquez'), _utf8'Vázquez';

Same result

php - decutf8 decimal to utf8 entity

go to http://www.zedwood.com/unicode_table you will see a unicode table listed by htmlentity number.

echo decutf8(632);//prints ɸ which has htmlentity &#0632;

function decutf8($str)
{
$bin = decbin($str);
$out = 127;
if (strlen($bin)<=7)
{
$bin=sprintf("%08d", $bin);
$out=bindec($bin);
}
else if (strlen($bin)<=11)
{
$bin=sprintf("%011d", $bin);
$out=bindec("110".substr($bin,0,5)."10".substr($bin,5,6));
}
else if (strlen($bin)<=16)
{
$bin=sprintf("%016d", $bin);
$out=bindec("1110".substr($bin,0,4)."10".substr($bin,4,6)."10".substr($bin,4,6));
}
else if (strlen($bin)<=21)
{
$bin=sprintf("%021d", $bin);
$out=bindec("11110".substr($bin,0,3)."10".substr($bin,3,6)."10".substr($bin,9,6)."10".substr($bin,15,6));
}

if ($out <=255)
return chr($out);
else if ($out <=(255 * 256) )
return chr($out/256).chr($out%256);
else if ($out <=(255 * 256 * 256) )
return chr($out/256).chr($out/256).chr($out%256);
else if ($out <=(255 * 256 * 256 * 256) )
return chr($out/256).chr($out/256).chr($out/256).chr($out%256);
}

Wednesday, March 11, 2009

javascript debugging in ie

Firebug rocks, and though there is a version for IE, it isn't the same. So in developing javascript heavy websites, it is always useful to have an IE brower around and debugging tools so you can figure out why your code is breaking in IE and not Firefox.

There are 3 ways to debug javascript in ie:
1. microsoft script debugger
2. visual studio .net
3. microsoft script editor (comes with office xp/2003)

Seeing as [2] and [3] both involve handing money over to micro$oft. We are left with [1]. The microsoft script debugger is no way related to the Internet Explorer Developer Toolbar

The Script Debugger is pretty sad but at least you can visually see what line of code your IE breaks on. It can still leave you scratching your head as to 'why' though. To enable it go to your "internet options" menu and hit uncheck the "Disable Script Debugging (Internet Explorer)" option.

Note to self: This breaks in IE7
var a = { width: 100, height :200 , };
While invalid syntax, IE7 should not be so delicate it gets tripped up by this. Allowing an extra comma in an array or dynamic object allows for cleaner code when generating javascript from another language.

debug ie6

Thursday, February 26, 2009

please mount the unreal tournament play disc cdrom - ut2004 on ubuntu fix

I was trying to install ut2004 on ubuntu and kept getting the message:
"please mount the unreal tournament play disc cdrom"

I think because ubuntu auto-mounts volumes, it mounts them in multiple places, somehow confusing the installer. The answer is to umount it... then manually mount it below as shown.

sudo apt-get install libgtk1.2
umount /media/cdrom
sudo mount /dev/cdrom /media/cdrom
export SETUP_CDROM=/media/cdrom
/media/cdrom/linux-installer.sh
... let it install ...
umount -f /media/cdrom

Note: installing libgtk1.2 is just to have a gui installer instead of console/ascii looking installer

it worked for me.

linux bash xargs cut convert usage

Convert all PSDs to PNGs:
ls *.psd | cut -d . -f 1 | xargs -L1 -i convert {}.psd {}.png

Thursday, February 12, 2009

view rpm binary content

rpm -qpl [package.rpm]

geoip lookup

opensuse 10.3 linux rpm
http://download.opensuse.org/repositories/games:/tools/openSUSE_10.3/i586/


data available from:
http://www.maxmind.com/app/geolitecountry
http://www.maxmind.com/app/geolitecity

Wednesday, February 11, 2009

echo tabs in bash

The -e turns uses escaped characters like \t \n \r instead of treating them literally which is default.
echo -e "FIRSTNAME\tLASTNAME\tOCCUPATION"

Wednesday, January 28, 2009

how to lookup current linux version command line

uname -a
cat /etc/issue
cat /proc/version

How to add mdbg search for firefox search bar

Include the following file in your searchplugins folder
on windows: C:\Program Files\Mozilla Firefox\searchplugins

mdbg.xml
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>MDBG</ShortName>
<Description>MDBG Character Lookup</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16">data:image/x-icon;base64,AAABAAIAEBAQAAAAAAAoAQAAJgAAACAgEAAAAAAA6AIAAE4BAAAoAAAAEAAAACAAAAABAAQAAAAAAIAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////APAAAP//AA//8P//D/D/8P/w//8PD///D/D//w8P/wAP8AAADw/////w//8PD///D/D//w/w//D/8AAA//8AD//w/w/w8AAP//D/D/Dw//D/8PDw8PD//w/w8PDw8P//D/Dw8PDw//8P8A//APD//w/wD/8A8P/w//D///DwAA//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAAAAAAAAAAAAAEAAAABAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD//wD/AAAA/wD/AP//AAD///8A//////////////////////8AAAAAAP////8AAAD/////AAAAAAAP//8AAAAAAP///wAP//8AAP/wAA//8AAP//8AD///8AD/8AD///8AD///AA////AA/wAP////AA///wAP//8AAP8AD//wAAAP//8AAAAAAA//AA//8AAAD///AAAAAAD//wAP/////////wAP//8AD/8AD/////////8AD///AA//AA////8AD///AA///wAP//AA///wAP///wAP//8AD//wAA//AAD///8AAAAAAA///wAAAAAP////AAAAAA//////AAAA////////////////////////////////////////////////AA//AP/wAP8AAAAAD////wAP8AAP8AD/AAAAAAD///8AD/AAD/AA/wAP//AAD///AA/wAA/wAP8AD///AA///wAP8AAP8AD/AA////AA//8ADwAAAPAA/wAP///wAP//AA8A/wDwAP8AD///8AD//wAPAP8A8AD/AA////AA//8ADwD/APAA/wAP///wAP//AAAA/wAAAP8AD///8AD//wAAD//wAAD/AA///wAP//8AAA//8AAA/wAP//AAD///AAAP//AAAP8AAAAAAP///wAAD///AAD/AAAAAA////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</Image>
<Url type="text/html" method="GET" template="http://www.mdbg.net/chindict/chindict.php?page=chardict&amp;cdcanoce=0&amp;cdqchi={searchTerms}&amp;cddmtm=1&amp;cddytm=0"/>
<SearchForm>http://mdbg.com/</SearchForm>
</SearchPlugin>

Friday, January 23, 2009

Saturday, January 10, 2009

How to mount an iso in linux

How to mount an iso in linux

1. make some folder
mkdir /mnt/iso1


2. as root...mount it
mount -o loop abc.iso /mnt/iso1

Friday, January 09, 2009

A8V-VM SE sound on linux

How to configure the onaboard ALC861 sound on the A8V-VM SE motherboard in opensuse:


in opensuse 11.1 set 'model' option to 3stack in yast2