C
Articles related to Software Development in C
OpenSSL loading openssl.cnf
Feb 8th
since the openssl.cnf path is hardcoded in binaries. to alter it on windows set environmental variable (as written):
OPENSSLDIR=C:\PATH\TO\OpenSSL\bin OPENSSL_CONF=C:\PATH\TO\OpenSSL\bin\openssl.cnf
OPENSSL_CONF doesn’t work without OPENSSLDIR even if it is set.
settings these options will allow you to use your custom configuration files when creating certificates.
batch file i use to create certificate
GenCERT.bat [save this file to OpenSSL bin directory]
@echo off md %1 openssl genrsa -des3 -out %1/%1.key 1024 openssl req -new -key %1/%1.key -out %1/%1.csr copy %1/%1.key %1/%1.key.org openssl rsa -in %1/%1.key.org -out %1/%1.key openssl x509 -req -days 365 -in %1/%1.csr -signkey %1/%1.key -out %1/%1.crt openssl x509 -outform der -in %1/%1.crt -out %1/%1.der
Sample
:: Start command line and cd to C:\PATH\TO\OpenSSL\bin :: :: usage: GenCERT.bat domain.com :: GenCERT.bat teknober.com
Batch file I use to create SSL certificate for Web etc server
GenPEM.bat [save this file to OpenSSL bin directory]
@echo off mkdir %1 openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout %1/%1.pem -out %1/%1.pem -config "%1/%1.cfg"
Sample
:: Start command line and cd to C:\PATH\TO\OpenSSL\bin :: :: usage: GenPEM.bat domain.com :: GenPEM.bat teknober.com
for sample ssl configuration file see the bottom of the page: http://www.openssl.org/docs/apps/ca.html
PDO PDOStatement with Select Find, Skip, Take
Jan 13th
Currently working on extending PDOStatement at C level which will allow to use select, join, where, order, group, find, skip, take commands in chain.
the usage will be like:
/* Extended PDO */
$pdo = new PDO(/* dsn */);
$pdo->select('table_x')->find(array('id' => 1));
/* using alias */
$pdo->select('table_x as a')->find(array('a.id = ?'))->bind(array(1));
$pdo->select('table_x', array('table_x.id', 'table_y.name', 'table_y.description')->join_left('table_y', array('table_x.id = table_y.id'))->findAll();
/*
--output type (single)
-- find() => PDORow
-- findToCSV() => comma seperated values
-- findToTDV() => tab delimeted values
-- findToJSON() => json string
-- findToXML() => xml string
--output types (multiple)
-- findAll() => array
-- findAllToCSV() => comma separated values
-- findAllToTDV() => tab delimited values
-- findAllToJSON() => json string
-- findAllToXML() => xml string
*/
$pdo->select('table_x', array('table_x.id', 'table_y.name', 'table_y.description')->join_left('table_y', array('table_x.id = table_y.id'))->findAllToCSV();
$pdo->select('table_x', array('table_x.id', 'table_y.name', 'table_y.description')->join_left('table_y', array('table_x.id = table_y.id'))->findAllToTDV();
$pdo->select('table_x', array('table_x.id', 'table_y.name', 'table_y.description')->join_left('table_y', array('table_x.id = table_y.id'))->findAllToJSON();
$pdo->select('table_x', array('table_x.id', 'table_y.name', 'table_y.description')->join_left('table_y', array('table_x.id = table_y.id'))->findAllToXML();
If you have any suggestions on adding more commands please let me know
MySQL Dump using Command Line
May 16th
Simple Batch File taking database name as argument:
Ref manual: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
dump.bat [fixed for time 0-30-32.sql was breaking the file name.]
:: Date [yy:mm:dd]
For /f "tokens=1-3 delims=/. " %%a in ('date /t') do (
set tws_date_yy=%%c
set tws_date_mm=%%b
set tws_date_dd=%%a
)
:: Time [hh:mm]
For /f "tokens=1-8 delims=/:." %%a in ('time /t') do (
set tws_time_hh=%%a
set tws_time_mm=%%b
)
:: Time [ss]
For /f "tokens=1-3 delims=/:," %%a in ("%TIME%") do (
set tws_time_ss=%%c
)
:: DateTime format
set tws_form=%tws_date_yy%-%tws_date_mm%-%tws_date_dd%_%tws_time_hh%-%tws_time_mm%-%tws_time_ss%
mysqldump.exe --skip-compact --skip-extended-insert --skip-quote-names --skip-add-locks --comments --routines --triggers --events -h 127.0.0.1 -P 3306 -u root %1 -p > %1_%tws_form%.sql
execute
dump.bat dbname
output (file): dbname-YYYY-MM-DD_HH-MM-SS.sql
modify given options for your need


LinkedIn
Twitter
Skype