Software development tutorials and demos lasting no more than 60 seconds.
No in-depth explanations, no off-topic rants, and no slides. One small topic per video - only code, console, config, and client.
All videos come with a corresponding blog entry, and all code is available on GitHub.
if(!Array.prototype.map){
Array.prototype.map =function(callback/*, thisArg*/){var T, A, k;if(this==null){thrownew TypeError('this is null or not defined');}var O = Object(this);var len = O.length>>>0;if(typeof callback !=='function'){thrownew TypeError(callback +' is not a function');}if(arguments.length>1){
T = arguments[1];}
A =new Array(len);
k =0;while(k < len){var kValue, mappedValue;if(k in O){
kValue = O[k];
mappedValue = callback.call(T, kValue, k, O);
A[k]= mappedValue;}
k++;}return A;};}
With .NET 5, you get a new concept called record . Lots of cool things, one of which is that you can serialize and deserialize with JSON just like a class, except you don't need to define properties one at a time, or even the body of the type. Apparently XML serialization doesn't quite work, so stick with JSON. View code on GitHub
rem dptnt.com/2009/04/how-to-add-date-time-stamp-to-jpeg-photos-using-free-software/ @ ECHO OFF SETLOCAL FOR / R %%G IN ( *.jpg ) DO CALL :process "%%G" GOTO :end :process SET _inname = %1 identify - format %%w %_inname% > dttmpfile set / p width = < dttmpfile Set / a pointsize = %width% / 50 rem echo ZZ >> dttempfile DEL dttmpfile ECHO Processing %_inname% ... convert %_inname% - gravity SouthEast - font Arial - pointsize %pointsize% - fill orange - annotate +%pointsize%+%pointsize% "%%[exif:DateTimeOriginal]" %_inname% EXIT / B :end
Rather than try to make it happen in one big command, here’s breaking it out into many commands. Whether or not you use the transaction is up to you and your use case – you could always have a “Completed” column and only set that to true after success, if you wanted to skip a transaction. First, insert a record, leaving the blob column as an empty byte array, making sure you have access to the primary key of the record you just inserted: using var conn = new SqlConnection ( _config . GetConnectionString ( " MyDB " ) ) ; await conn . OpenAsync ( ) . ConfigureAwait ( false ) ; using var tran = ( SqlTransaction ) await conn . BeginTransactionAsync ( ) ; int fileID ; using ( var comm = conn . CreateCommand ( ) ) { comm . Transaction = tran ; comm . CommandText = @" insert dbo.Files (FileName, FileContents) values (@FileName, 0x); ...
Comments
Post a Comment