<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>algorithm | MaxVergelli.com</title>
	<atom:link href="https://www.maxvergelli.com/tag/algorithm/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.maxvergelli.com</link>
	<description>sourcecode repository</description>
	<lastBuildDate>Tue, 07 Apr 2020 13:42:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i2.wp.com/www.maxvergelli.com/wp-content/uploads/2020/04/wp-1586823685141.png?fit=32%2C32&#038;ssl=1</url>
	<title>algorithm | MaxVergelli.com</title>
	<link>https://www.maxvergelli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">34603511</site>	<item>
		<title>Convert a DateTime string to a Unix timestamp in VbScript / Classic ASP</title>
		<link>https://www.maxvergelli.com/convert-a-datetime-string-to-a-unix-timestamp-in-vbscript-classic-asp/</link>
					<comments>https://www.maxvergelli.com/convert-a-datetime-string-to-a-unix-timestamp-in-vbscript-classic-asp/#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Wed, 18 Mar 2020 14:10:43 +0000</pubDate>
				<category><![CDATA[Classic ASP]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MS Access]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[String Manipulation Algorithms]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[classic-asp]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[date-conversion]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[datetime-conversion]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[mysql-datetime]]></category>
		<category><![CDATA[mysql-datetime-conversion]]></category>
		<category><![CDATA[string-conversion]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[timestamp]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[unix-timestamp]]></category>
		<category><![CDATA[vbscript]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=124</guid>

					<description><![CDATA[<p>To convert a datetime string value like &#8220;YYYY-MM-DD HH:MM:SS&#8221; to a Unix timestamp (the seconds from 01/01/1970 to the input datetime) You can use a conversion function as the following: Then, to get back the datetime from the Unix timestamp &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/convert-a-datetime-string-to-a-unix-timestamp-in-vbscript-classic-asp/" aria-label="Convert a DateTime string to a Unix timestamp in VbScript / Classic ASP">Read More</a></p>
<p>The post <a href="https://www.maxvergelli.com/convert-a-datetime-string-to-a-unix-timestamp-in-vbscript-classic-asp/">Convert a DateTime string to a Unix timestamp in VbScript / Classic ASP</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>To convert a datetime string value like &#8220;YYYY-MM-DD HH:MM:SS&#8221; to a Unix timestamp (the seconds from 01/01/1970 to the input datetime) You can use a conversion function as the following:</p>


<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;vbscript&quot;,&quot;mime&quot;:&quot;text/vbscript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;VBScript&quot;,&quot;modeName&quot;:&quot;vb&quot;}">Function ConvertToUnixTimeStamp(input_datetime) 'As String 
  Dim d
  d = CDate(input_datetime) 
  ConvertToUnixTimeStamp = CStr(DateDiff(&quot;s&quot;, &quot;01/01/1970 00:00:00&quot;, d)) 
End Function</pre></div>



<p>Then, to get back the datetime from the Unix timestamp use the following code:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;vbscript&quot;,&quot;mime&quot;:&quot;text/vbscript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;VBScript&quot;,&quot;modeName&quot;:&quot;vb&quot;}">Function ConvertUnixTimeStampToDateTime(input_unix_timestamp) 'As String [regular datetime] 
  ConvertUnixTimeStampToDateTime = CStr(DateAdd(&quot;s&quot;, input_unix_timestamp, &quot;01/01/1970 00:00:00&quot;)) 
End Function</pre></div>



<p></p><p>The post <a href="https://www.maxvergelli.com/convert-a-datetime-string-to-a-unix-timestamp-in-vbscript-classic-asp/">Convert a DateTime string to a Unix timestamp in VbScript / Classic ASP</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/convert-a-datetime-string-to-a-unix-timestamp-in-vbscript-classic-asp/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">124</post-id>	</item>
		<item>
		<title>Base64 encoding / decoding functions in VbScript / Classic ASP</title>
		<link>https://www.maxvergelli.com/base64-encoding-decoding-functions-in-vbscript-classic-asp/</link>
					<comments>https://www.maxvergelli.com/base64-encoding-decoding-functions-in-vbscript-classic-asp/#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Fri, 06 Mar 2020 13:43:10 +0000</pubDate>
				<category><![CDATA[Classic ASP]]></category>
		<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[classic-asp]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[decoding]]></category>
		<category><![CDATA[decryption]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-conversion]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[vbscript]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=122</guid>

					<description><![CDATA[<p>With the following functions Base64Encode(sText) and Base64Decode(ByVal vCode), You can easly encode/decode a text in/from base64 in VBScript/Classic ASP:</p>
<p>The post <a href="https://www.maxvergelli.com/base64-encoding-decoding-functions-in-vbscript-classic-asp/">Base64 encoding / decoding functions in VbScript / Classic ASP</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><span id="result_box" class="" lang="en">With the following functions <em>Base64Encode(sText)</em> and <em>Base64Decode(ByVal vCode)</em>, You can easly encode/decode a text in/from base64 in VBScript/Classic ASP:</span></p>


<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;vbscript&quot;,&quot;mime&quot;:&quot;text/vbscript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;VBScript&quot;,&quot;modeName&quot;:&quot;vb&quot;}">Function Base64Encode(sText)
  Dim oXML, oNode
  Set oXML = CreateObject(&quot;Msxml2.DOMDocument.3.0&quot;)
  Set oNode = oXML.CreateElement(&quot;base64&quot;)
  oNode.dataType = &quot;bin.base64&quot;
  oNode.nodeTypedValue = Stream_StringToBinary(sText)
  Base64Encode = oNode.text
  Set oNode = Nothing
  Set oXML = Nothing
End Function

Function Base64Decode(ByVal vCode)
  Dim oXML, oNode
  Set oXML = CreateObject(&quot;Msxml2.DOMDocument.3.0&quot;)
  Set oNode = oXML.CreateElement(&quot;base64&quot;)
  oNode.dataType = &quot;bin.base64&quot;
  oNode.text = vCode
  Base64Decode = Stream_BinaryToString(oNode.nodeTypedValue)
  Set oNode = Nothing
  Set oXML = Nothing
End Function

Private Function Stream_StringToBinary(Text)
  Const adTypeText = 2
  Const adTypeBinary = 1
  Dim BinaryStream 'As New Stream
  Set BinaryStream = CreateObject(&quot;ADODB.Stream&quot;)
  BinaryStream.Type = adTypeText
  BinaryStream.CharSet = &quot;us-ascii&quot;
  BinaryStream.Open
  BinaryStream.WriteText Text
  BinaryStream.Position = 0
  BinaryStream.Type = adTypeBinary
  BinaryStream.Position = 0
  Stream_StringToBinary = BinaryStream.Read
  Set BinaryStream = Nothing
End Function

Private Function Stream_BinaryToString(Binary)
  Const adTypeText = 2
  Const adTypeBinary = 1
  Dim BinaryStream 'As New Stream
  Set BinaryStream = CreateObject(&quot;ADODB.Stream&quot;)
  BinaryStream.Type = adTypeBinary
  BinaryStream.Open
  BinaryStream.Write Binary
  BinaryStream.Position = 0
  BinaryStream.Type = adTypeText
  BinaryStream.CharSet = &quot;us-ascii&quot;
  Stream_BinaryToString = BinaryStream.ReadText
  Set BinaryStream = Nothing
End Function</pre></div>



<p></p><p>The post <a href="https://www.maxvergelli.com/base64-encoding-decoding-functions-in-vbscript-classic-asp/">Base64 encoding / decoding functions in VbScript / Classic ASP</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/base64-encoding-decoding-functions-in-vbscript-classic-asp/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">122</post-id>	</item>
		<item>
		<title>How to export an ASP Associative Array to XML</title>
		<link>https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/</link>
					<comments>https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Sat, 15 Feb 2020 16:27:57 +0000</pubDate>
				<category><![CDATA[Classic ASP]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MS Access]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[array-function]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[asp-associative-array]]></category>
		<category><![CDATA[associative-array]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[data-layer]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[datetime-conversion]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[enumerating]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-conversion]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[wrapper-class]]></category>
		<category><![CDATA[xml]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=82</guid>

					<description><![CDATA[<p>&#8220;Asp Associative Array Class&#8221; provides a method to easly export all items to a well formatted XML string. For example, You can create a new *.ASP file : [sourcecode language=&#8221;vb&#8221;] &#60;!&#8211;#include file=&#34;AssociativeArrayClass.asp&#34; &#8211;&#62; &#60;% Dim Person, God Set Person = &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/" aria-label="How to export an ASP Associative Array to XML">Read More</a></p>
<p>The post <a href="https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/">How to export an ASP Associative Array to XML</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><a href="https://sourceforge.net/projects/asp-assoc-array/files/ASP_Associative_Array.rar/download" target="_blank" rel="noopener noreferrer">&#8220;Asp Associative Array Class&#8221;</a> provides a method to easly export all items to a well formatted XML string. For example, You can create a new *.ASP file :</p>
<p>[sourcecode language=&#8221;vb&#8221;]<br />
&lt;!&#8211;#include file=&quot;AssociativeArrayClass.asp&quot; &#8211;&gt;<br />
&lt;%<br />
Dim Person, God<br />
Set Person = New AssociativeArray<br />
Set God = New AssociativeArray<br />
Person(&quot;name&quot;) = &quot;Max&quot;<br />
Person(&quot;surname&quot;) = &quot;Vergelli&quot;<br />
God(&quot;name&quot;) = &quot;Jesus&quot;<br />
God(&quot;surname&quot;) = &quot;Christ&quot;<br />
Dim World<br />
Set World = New AssociativeArray<br />
World(1) = Person<br />
World(2) = God<br />
response.Write World.ToXML()<br />
%&gt;<br />
[/sourcecode]</p>
<p>And You will get out the following XML:</p>
<p>[sourcecode language=&#8221;xml&#8221;]<br />
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br />
&lt;array&gt;<br />
      &lt;key&gt;<br />
            &lt;name&gt;&lt;![CDATA[1]]&gt;&lt;/name&gt;<br />
            &lt;value&gt;<br />
                    &lt;key&gt;<br />
                           &lt;name&gt;&lt;![CDATA[name]]&gt;&lt;/name&gt;<br />
                           &lt;value&gt;&lt;![CDATA[Max]]&gt;&lt;/value&gt;<br />
                    &lt;/key&gt;<br />
                    &lt;key&gt;<br />
                           &lt;name&gt;&lt;![CDATA[surname]]&gt;&lt;/name&gt;<br />
                           &lt;value&gt;&lt;![CDATA[Vergelli]]&gt;&lt;/value&gt;<br />
                   &lt;/key&gt;<br />
           &lt;/value&gt;<br />
      &lt;/key&gt;<br />
      &lt;key&gt;<br />
             &lt;name&gt;&lt;![CDATA[2]]&gt;&lt;/name&gt;<br />
             &lt;value&gt;<br />
                    &lt;key&gt;<br />
                           &lt;name&gt;&lt;![CDATA[name]]&gt;&lt;/name&gt;<br />
                           &lt;value&gt;&lt;![CDATA[Jesus]]&gt;&lt;/value&gt;<br />
                    &lt;/key&gt;<br />
                    &lt;key&gt;<br />
                          &lt;name&gt;&lt;![CDATA[surname]]&gt;&lt;/name&gt;<br />
                          &lt;value&gt;&lt;![CDATA[Christ]]&gt;&lt;/value&gt;<br />
                    &lt;/key&gt;<br />
             &lt;/value&gt;<br />
       &lt;/key&gt;<br />
&lt;/array&gt;<br />
[/sourcecode]</p><p>The post <a href="https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/">How to export an ASP Associative Array to XML</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">82</post-id>	</item>
		<item>
		<title>VBScript Class to create easly Associative Arrays in ASP like in PHP</title>
		<link>https://www.maxvergelli.com/vbscript-class-to-create-easly-associative-arrays-in-asp-like-in-php/</link>
					<comments>https://www.maxvergelli.com/vbscript-class-to-create-easly-associative-arrays-in-asp-like-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Wed, 22 Jan 2020 15:53:47 +0000</pubDate>
				<category><![CDATA[Classic ASP]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MS Access]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[asp-associative-array]]></category>
		<category><![CDATA[associative-array]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[classic-asp]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[data-layer]]></category>
		<category><![CDATA[datatype]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[ms-access]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[wrapper-class]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=76</guid>

					<description><![CDATA[<p>I&#8217;ve posted a project at Source Forge with an ASP/VBScript class to create easly associative arrays like in PHP; visit http://sourceforge.net/projects/asp-assoc-array/ It is possible also load in an associative-array the data coming from MySQL or MS Access databases, then You &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/vbscript-class-to-create-easly-associative-arrays-in-asp-like-in-php/" aria-label="VBScript Class to create easly Associative Arrays in ASP like in PHP">Read More</a></p>
<p>The post <a href="https://www.maxvergelli.com/vbscript-class-to-create-easly-associative-arrays-in-asp-like-in-php/">VBScript Class to create easly Associative Arrays in ASP like in PHP</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve posted a project at Source Forge with an ASP/VBScript class to create easly associative arrays like in PHP; visit <a href="http://sourceforge.net/projects/asp-assoc-array/">http://sourceforge.net/projects/asp-assoc-array/</a></p>
<p>It is possible also load in an associative-array the data coming from MySQL or MS Access databases, then You can programmatically manage the structured data; You can also export associative arrays to XML.</p>
<p>Associative arrays are usefull when it is necessary manage many variables at once (for example when we pass multiple values at once to a method/function) or just to store data in a well structured array and reusing  its values anytime.</p><p>The post <a href="https://www.maxvergelli.com/vbscript-class-to-create-easly-associative-arrays-in-asp-like-in-php/">VBScript Class to create easly Associative Arrays in ASP like in PHP</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/vbscript-class-to-create-easly-associative-arrays-in-asp-like-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">76</post-id>	</item>
		<item>
		<title>vb.net Bitmap object locks images (impossible to move/delete jpg/gif files) &#8211; .Dispose() Method common problem</title>
		<link>https://www.maxvergelli.com/vb-net-bitmap-object-locks-images-impossible-to-move-delete-jpg-gif-files-dispose-method-common-problem/</link>
					<comments>https://www.maxvergelli.com/vb-net-bitmap-object-locks-images-impossible-to-move-delete-jpg-gif-files-dispose-method-common-problem/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Tue, 14 Jan 2020 15:47:04 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[bitmap]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[dispose]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vb.net]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=74</guid>

					<description><![CDATA[<p>Many people are in trouble and on forums asking why the .Net Bitmap object does not release an image with its .Dispose() method. The Bitmap object (after its destruction too) seems to lock the image file, then we are not &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/vb-net-bitmap-object-locks-images-impossible-to-move-delete-jpg-gif-files-dispose-method-common-problem/" aria-label="vb.net Bitmap object locks images (impossible to move/delete jpg/gif files) &#8211; .Dispose() Method common problem">Read More</a></p>
<p>The post <a href="https://www.maxvergelli.com/vb-net-bitmap-object-locks-images-impossible-to-move-delete-jpg-gif-files-dispose-method-common-problem/">vb.net Bitmap object locks images (impossible to move/delete jpg/gif files) – .Dispose() Method common problem</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Many people are in trouble and on forums asking why the .Net Bitmap object does not release an image with its .Dispose() method. The Bitmap object (after its destruction too) seems to lock the image file, then we are not able to move or delete that image file through the file system.</p>
<p>This is a known problem and it occurs when we declare and instantiate a Bitmap object and destruct that like in the following code:</p>
<p>[sourcecode language=&#8221;vb&#8221;]</p>
<p>                &#8216;create a bitmap object<br />
                Dim myBitmap As New Bitmap(&quot;c:myimage.jpg&quot;)</p>
<p>                &#8216;editing image routines, right here<br />
                &#8216;&#8230;</p>
<p>                &#8216;release all Bitmap object resources<br />
                myBitmap.Dispose()</p>
<p>[/sourcecode]</p>
<p>The above code it is formally correct, however in same circumstances the .net garbage collector cannot recognize bitmap&#8217;s disposing; Dispose() method leaves the image file in an unusable state, then as <a href="http://msdn.microsoft.com/en-us/library/8th8381z.aspx">MSDN</a> said, we MUST release explicitly any reference after a Dispose() call;</p>
<p>with the following code, You will not encounter any problem, and after Dispose() You can edit, move, delete the image file by the filesystem functions&#8230;</p>
<p>[sourcecode language=&#8221;vb&#8221;]<br />
                &#8216;create a bitmap object<br />
                Dim myBitmap As New Bitmap(&quot;c:myimage.jpg&quot;)</p>
<p>                &#8216;editing image routines, right here<br />
                &#8216;&#8230;</p>
<p>                &#8216;release image reference<br />
                While myBitmap IsNot Nothing<br />
                    myBitmap.Dispose()<br />
                    myBitmap = Nothing  &#8216;&lt;&#8211; tells .net garbage collector to release resources<br />
                End While</p>
<p>[/sourcecode]</p>
<p>Happy image editing! 🙂</p><p>The post <a href="https://www.maxvergelli.com/vb-net-bitmap-object-locks-images-impossible-to-move-delete-jpg-gif-files-dispose-method-common-problem/">vb.net Bitmap object locks images (impossible to move/delete jpg/gif files) – .Dispose() Method common problem</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/vb-net-bitmap-object-locks-images-impossible-to-move-delete-jpg-gif-files-dispose-method-common-problem/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">74</post-id>	</item>
		<item>
		<title>How to draw a shadow for a bitmap (Drop Shadow Effect in VB.NET / ASP.NET)</title>
		<link>https://www.maxvergelli.com/how-to-draw-a-shadow-for-a-bitmap-drop-shadow-effect-in-vb-net-asp-net/</link>
					<comments>https://www.maxvergelli.com/how-to-draw-a-shadow-for-a-bitmap-drop-shadow-effect-in-vb-net-asp-net/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Thu, 09 Jan 2020 15:41:16 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[backcolor]]></category>
		<category><![CDATA[background-color]]></category>
		<category><![CDATA[bitamp-library]]></category>
		<category><![CDATA[bitmap]]></category>
		<category><![CDATA[bitmap-effect]]></category>
		<category><![CDATA[bitmap-fx]]></category>
		<category><![CDATA[bitmap-manipulation]]></category>
		<category><![CDATA[bitmap-processing]]></category>
		<category><![CDATA[bitmap-programming]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[digital-image-processing]]></category>
		<category><![CDATA[draw]]></category>
		<category><![CDATA[draw-bitmap]]></category>
		<category><![CDATA[drawing]]></category>
		<category><![CDATA[drop-shadow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[fx]]></category>
		<category><![CDATA[graphic-manipulation]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[image-filter]]></category>
		<category><![CDATA[image-fx]]></category>
		<category><![CDATA[image-height]]></category>
		<category><![CDATA[image-library]]></category>
		<category><![CDATA[image-manipulation]]></category>
		<category><![CDATA[image-manipulation-algorithm]]></category>
		<category><![CDATA[image-matrix]]></category>
		<category><![CDATA[image-processing]]></category>
		<category><![CDATA[image-processing-algorithm]]></category>
		<category><![CDATA[image-width]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[matrix-manipulation]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[opacity]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[shadow]]></category>
		<category><![CDATA[shadow-effect]]></category>
		<category><![CDATA[thread-safe]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[wrapper-class]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=72</guid>

					<description><![CDATA[<p>I wrote a vb.net subroutine to draw easly a shadow for a Bitmap object; It is possible get a charming shadow in different ways&#8230; Normal black shadow to the bottom right corner Red shadow to the bottom right corner Shadow &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-draw-a-shadow-for-a-bitmap-drop-shadow-effect-in-vb-net-asp-net/" aria-label="How to draw a shadow for a bitmap (Drop Shadow Effect in VB.NET / ASP.NET)">Read More</a></p>
<p>The post <a href="https://www.maxvergelli.com/how-to-draw-a-shadow-for-a-bitmap-drop-shadow-effect-in-vb-net-asp-net/">How to draw a shadow for a bitmap (Drop Shadow Effect in VB.NET / ASP.NET)</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>I wrote a vb.net subroutine to draw easly a shadow for a Bitmap object; It is possible get a charming shadow in different ways&#8230;</p>
<table>
<tbody>
<tr>
<td>Normal black shadow to the bottom right corner</td>
<td><img src="https://i1.wp.com/www.maxvergelli.com/wp-content/uploads/2016/06/test_shadow_01_black_to_white.jpg?w=1140" data-recalc-dims="1" /></td>
</tr>
<tr>
<td>Red shadow to the bottom right corner</td>
<td><img src="https://i1.wp.com/www.maxvergelli.com/wp-content/uploads/2016/06/test_shadow_02_red_to_white.jpg?w=1140" data-recalc-dims="1" /></td>
</tr>
<tr>
<td>Shadow to the bottom left corner</td>
<td><img src="https://i2.wp.com/www.maxvergelli.com/wp-content/uploads/2016/06/test_shadow_04_d_bottomleft.jpg?w=1140" data-recalc-dims="1" /></td>
</tr>
<tr>
<td>Shadow to the top left corner</td>
<td><img src="https://i0.wp.com/www.maxvergelli.com/wp-content/uploads/2016/06/test_shadow_05_d_topleft.jpg?w=1140" data-recalc-dims="1" /></td>
</tr>
<tr>
<td>Shadow to the top right corner</td>
<td><img src="https://i0.wp.com/www.maxvergelli.com/wp-content/uploads/2016/06/test_shadow_06_d_topright.jpg?w=1140" data-recalc-dims="1" /></td>
</tr>
<tr>
<td>Shadow with Opacity: &#8220;128&#8221;</td>
<td><img src="https://i2.wp.com/www.maxvergelli.com/wp-content/uploads/2016/06/test_shadow_07_opacity.jpg?w=1140" data-recalc-dims="1" /></td>
</tr>
<tr>
<td>Shadow with Opacity: &#8220;128&#8221; and Softness: &#8220;8&#8221;</td>
<td><img src="https://i1.wp.com/www.maxvergelli.com/wp-content/uploads/2016/06/test_shadow_08_opacityandsoftness.jpg?w=1140" data-recalc-dims="1" /></td>
</tr>
<tr>
<td>Shadow with Opacity: &#8220;128&#8221;, Softness: &#8220;8&#8221; and Distance: &#8220;10&#8221;</td>
<td><img src="https://i1.wp.com/www.maxvergelli.com/wp-content/uploads/2016/06/test_shadow_09_opacitysoftnessanddistance.jpg?w=1140" data-recalc-dims="1" /></td>
</tr>
<tr>
<td>Shadow without rounded edges</td>
<td><img src="https://i0.wp.com/www.maxvergelli.com/wp-content/uploads/2016/06/test_shadow_10_noroundededges.jpg?w=1140" data-recalc-dims="1" /></td>
</tr>
</tbody>
</table>
<p>Copy and paste my following vb.net code in your application. it does all the hard job&#8230;</p>
<p>[sourcecode language=&#8221;vb&#8221;]</p>
<p>    &#8216;ShadowDirection:<br />
    &#8216;       TOP_RIGHT = 1<br />
    &#8216;       BOTTOM_RIGHT = 2<br />
    &#8216;       BOTTOM_LEFT = 3<br />
    &#8216;       TOP_LEFT = 4<br />
    &#8216;ShadowOpacity: from 0 to 255<br />
    &#8216;ShadowSoftness: from 1 to 30<br />
    &#8216;ShadowDistance: from 1 to 50<br />
    &#8216;ShadowRoundedEdges: True or False</p>
<p>    &#8216;Note:<br />
    &#8216;If You set &quot;transparent&quot; as background color, this is replaced with white color.</p>
<p>    Public Enum ShadowDirections As Integer<br />
        TOP_RIGHT = 1<br />
        BOTTOM_RIGHT = 2<br />
        BOTTOM_LEFT = 3<br />
        TOP_LEFT = 4<br />
    End Enum</p>
<p>    &lt;STAThread()&gt; _<br />
    Public Sub DropShadow(ByRef SourceImage As Drawing.Bitmap, _<br />
                            ByVal ShadowColor As Drawing.Color, _<br />
                            ByVal BackgroundColor As Drawing.Color, _<br />
                            Optional ByVal ShadowDirection As ShadowDirections = _<br />
                                                  ShadowDirections.BOTTOM_RIGHT, _<br />
                            Optional ByVal ShadowOpacity As Integer = 190, _<br />
                            Optional ByVal ShadowSoftness As Integer = 4, _<br />
                            Optional ByVal ShadowDistance As Integer = 5, _<br />
                            Optional ByVal ShadowRoundedEdges As Boolean = True)<br />
        Dim ImgTarget As Bitmap = Nothing<br />
        Dim ImgShadow As Bitmap = Nothing<br />
        Dim g As Graphics = Nothing<br />
        Try<br />
            If SourceImage IsNot Nothing Then<br />
                If ShadowOpacity &lt; 0 Then<br />
                    ShadowOpacity = 0<br />
                ElseIf ShadowOpacity &gt; 255 Then<br />
                    ShadowOpacity = 255<br />
                End If<br />
                If ShadowSoftness &lt; 1 Then<br />
                    ShadowSoftness = 1<br />
                ElseIf ShadowSoftness &gt; 30 Then<br />
                    ShadowSoftness = 30<br />
                End If<br />
                If ShadowDistance &lt; 1 Then<br />
                    ShadowDistance = 1<br />
                ElseIf ShadowDistance &gt; 50 Then<br />
                    ShadowDistance = 50<br />
                End If<br />
                If ShadowColor = Color.Transparent Then<br />
                    ShadowColor = Color.Black<br />
                End If<br />
                If BackgroundColor = Color.Transparent Then<br />
                    BackgroundColor = Color.White<br />
                End If</p>
<p>                &#8216;get shadow<br />
                Dim shWidth As Integer = CInt(SourceImage.Width / ShadowSoftness)<br />
                Dim shHeight As Integer = CInt(SourceImage.Height / ShadowSoftness)<br />
                ImgShadow = New Bitmap(shWidth, shHeight)<br />
                g = Graphics.FromImage(ImgShadow)<br />
                g.Clear(Color.Transparent)<br />
                g.InterpolationMode = InterpolationMode.HighQualityBicubic<br />
                g.SmoothingMode = SmoothingMode.AntiAlias<br />
                Dim sre As Integer = 0<br />
                If ShadowRoundedEdges = True Then sre = 1<br />
                g.FillRectangle(New SolidBrush(Color.FromArgb(ShadowOpacity, ShadowColor)), _<br />
                                      sre, sre, shWidth, shHeight)<br />
                g.Dispose()</p>
<p>                &#8216;draw shadow<br />
                Dim d_shWidth As Integer = SourceImage.Width + ShadowDistance<br />
                Dim d_shHeight As Integer = SourceImage.Height + ShadowDistance<br />
                ImgTarget = New Bitmap(d_shWidth, d_shHeight)<br />
                g = Graphics.FromImage(ImgTarget)<br />
                g.Clear(BackgroundColor)<br />
                g.InterpolationMode = InterpolationMode.HighQualityBicubic<br />
                g.SmoothingMode = SmoothingMode.AntiAlias<br />
                g.DrawImage(ImgShadow, New Rectangle(0, 0, d_shWidth, d_shHeight), _<br />
                                        0, 0, ImgShadow.Width, ImgShadow.Height, GraphicsUnit.Pixel)<br />
                Select Case ShadowDirection<br />
                    Case ShadowDirections.BOTTOM_RIGHT<br />
                        g.DrawImage(SourceImage, _<br />
                            New Rectangle(0, 0, SourceImage.Width,SourceImage.Height), _<br />
                               0, 0, SourceImage.Width, SourceImage.Height, GraphicsUnit.Pixel)<br />
                    Case ShadowDirections.BOTTOM_LEFT<br />
                        g.Dispose()<br />
                        ImgTarget.RotateFlip(RotateFlipType.RotateNoneFlipX)<br />
                        g = Graphics.FromImage(ImgTarget)<br />
                        g.DrawImage(SourceImage, _<br />
                             New Rectangle(ShadowDistance, 0, SourceImage.Width, SourceImage.Height), _<br />
                                    0, 0, SourceImage.Width, SourceImage.Height, GraphicsUnit.Pixel)<br />
                    Case ShadowDirections.TOP_LEFT<br />
                        g.Dispose()<br />
                        ImgTarget.RotateFlip(RotateFlipType.Rotate180FlipNone)<br />
                        g = Graphics.FromImage(ImgTarget)<br />
                        g.DrawImage(SourceImage, _<br />
                                      New Rectangle(ShadowDistance, ShadowDistance, _<br />
                                                        SourceImage.Width, SourceImage.Height), _<br />
                                      0, 0, SourceImage.Width, SourceImage.Height, GraphicsUnit.Pixel)<br />
                    Case ShadowDirections.TOP_RIGHT<br />
                        g.Dispose()<br />
                        ImgTarget.RotateFlip(RotateFlipType.RotateNoneFlipY)<br />
                        g = Graphics.FromImage(ImgTarget)<br />
                        g.DrawImage(SourceImage, _<br />
                           New Rectangle(0, ShadowDistance, SourceImage.Width, SourceImage.Height), _<br />
                                  0, 0, SourceImage.Width, SourceImage.Height, GraphicsUnit.Pixel)<br />
                End Select</p>
<p>                g.Dispose()<br />
                g = Nothing<br />
                ImgShadow.Dispose()<br />
                ImgShadow = Nothing</p>
<p>                SourceImage = New Bitmap(ImgTarget)<br />
                ImgTarget.Dispose()<br />
                ImgTarget = Nothing<br />
            End If</p>
<p>        Catch ex As Exception<br />
            If g IsNot Nothing Then<br />
                g.Dispose()<br />
                g = Nothing<br />
            End If<br />
            If ImgShadow IsNot Nothing Then<br />
                ImgShadow.Dispose()<br />
                ImgShadow = Nothing<br />
            End If<br />
            If ImgTarget IsNot Nothing Then<br />
                ImgTarget.Dispose()<br />
                ImgTarget = Nothing<br />
            End If<br />
        End Try</p>
<p>    End Sub<br />
[/sourcecode]</p>
<p>Besides, You can use this sub as in the following example (take a look at the comments&#8230;) :</p>
<p>[sourcecode language=&#8221;vb&#8221;]<br />
        Dim file_input As String = &quot;c:myfile.jpg&quot;<br />
        Dim file_output As String = &quot;c:myfilewithshadow.jpg&quot;</p>
<p>        &#8216;get bitmap&#8230;<br />
        Dim sourceImage As System.Drawing.Image = System.Drawing.Image.FromFile(file_input)<br />
        Dim format As System.Drawing.Imaging.ImageFormat = sourceImage.RawFormat<br />
        Dim bmpOut As System.Drawing.Bitmap = New Bitmap(sourceImage)</p>
<p>        &#8216;release any reference to the original file&#8230;<br />
        While sourceImage IsNot Nothing<br />
            sourceImage.Dispose()<br />
            sourceImage = Nothing<br />
        End While</p>
<p>        &#8216;drop black shadow on new bitmap with white background&#8230;<br />
        DropShadow(bmpOut, Color.Black, Color.White)</p>
<p>        &#8216;save file&#8230;<br />
        If bmpOut IsNot Nothing Then<br />
            bmpOut.Save(file_output, format)<br />
            bmpOut.Dispose()<br />
            bmpOut = Nothing<br />
        End If<br />
[/sourcecode]</p>
<p>PS:<br />
The subroutine executes only in &#8220;STAThread&#8221; so it&#8217;s thread-safe drawing.</p>
<p>Happy coding&#8230;</p>
<p>Max 🙂</p><p>The post <a href="https://www.maxvergelli.com/how-to-draw-a-shadow-for-a-bitmap-drop-shadow-effect-in-vb-net-asp-net/">How to draw a shadow for a bitmap (Drop Shadow Effect in VB.NET / ASP.NET)</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-draw-a-shadow-for-a-bitmap-drop-shadow-effect-in-vb-net-asp-net/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">72</post-id>	</item>
		<item>
		<title>PHP Date or Datetime to MySQL Datetime and viceversa</title>
		<link>https://www.maxvergelli.com/php-date-or-datetime-to-mysql-datetime-and-viceversa/</link>
					<comments>https://www.maxvergelli.com/php-date-or-datetime-to-mysql-datetime-and-viceversa/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Sat, 21 Dec 2019 15:10:11 +0000</pubDate>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[String Manipulation Algorithms]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[conversione]]></category>
		<category><![CDATA[data-layer]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[datetime-conversion]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql-datetime]]></category>
		<category><![CDATA[mysql-datetime-conversion]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-conversion]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=59</guid>

					<description><![CDATA[<p>Two useful PHP functions to convert normal date/datetime (&#8220;25.12.2010 12:10:00&#8221; or &#8220;25.12.2010&#8221;) to MySQL datetime (like &#8220;2010-12-25 12:10:00&#8221; or &#8220;2010-12-25 00:00:00&#8243;); You can get back a date/datetime from MySQL datetime too: [sourcecode language=&#8221;php&#8221;] function datetime2mysqldatetime($datetime){ // &#8216;25.12.2010 12:10:00&#8217; -&#62; &#8216;2010-12-25 &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/php-date-or-datetime-to-mysql-datetime-and-viceversa/" aria-label="PHP Date or Datetime to MySQL Datetime and viceversa">Read More</a></p>
<p>The post <a href="https://www.maxvergelli.com/php-date-or-datetime-to-mysql-datetime-and-viceversa/">PHP Date or Datetime to MySQL Datetime and viceversa</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Two useful PHP functions to convert normal date/datetime (&#8220;25.12.2010 12:10:00&#8221; or &#8220;25.12.2010&#8221;) to MySQL datetime (like &#8220;2010-12-25 12:10:00&#8221; or &#8220;2010-12-25 00:00:00&#8243;); You can get back a date/datetime from MySQL datetime too:</p>
<p>[sourcecode language=&#8221;php&#8221;]<br />
	function datetime2mysqldatetime($datetime){				// &#8216;25.12.2010 12:10:00&#8217; -&gt; &#8216;2010-12-25 12:10:00&#8217;<br />
		return date(&#8216;Y-m-d H:i:s&#8217;, strtotime($datetime)); 	// &#8216;25.12.2010&#8217; 		 -&gt; &#8216;2010-12-25 00:00:00&#8217;<br />
	}</p>
<p>	function mysqldatetime2datetime($mysql_datetime){	// &#8216;2010-12-25 12:10:00&#8217; -&gt; &#8216;25.12.2010 12:10:00&#8217;<br />
		$d = split(&#8216; &#8216;, $mysql_datetime);				// &#8216;2010-12-25&#8217; 		 -&gt; &#8216;25.12.2010&#8217;<br />
		if($d &amp;&amp; count($d)&gt;1){<br />
			list($year, $month, $day) = split(&#8216;-&#8216;, $d[0]);<br />
			list($hour, $minute, $second) = split(&#8216;:&#8217;, $d[1]);<br />
			$d = date(&#8216;d.m.Y H:i:s&#8217;, mktime($hour, $minute, $second, $month, $day, $year));}<br />
		else if($d &amp;&amp; count($d)==1){<br />
			list($year, $month, $day) = split(&#8216;-&#8216;, $d[0]);<br />
			$d = date(&#8216;d.m.Y&#8217;, mktime(0, 0, 0, $month, $day, $year));<br />
		} else {<br />
			$d = NULL;<br />
		}<br />
		return $d;<br />
	}<br />
[/sourcecode]</p>
<p>Max 🙂</p><p>The post <a href="https://www.maxvergelli.com/php-date-or-datetime-to-mysql-datetime-and-viceversa/">PHP Date or Datetime to MySQL Datetime and viceversa</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/php-date-or-datetime-to-mysql-datetime-and-viceversa/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">59</post-id>	</item>
		<item>
		<title>Easy-to-use and strong Encrypt/Decrypt PHP functions</title>
		<link>https://www.maxvergelli.com/easy-to-use-strong-encrypt-decrypt-php-functions/</link>
					<comments>https://www.maxvergelli.com/easy-to-use-strong-encrypt-decrypt-php-functions/#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Tue, 10 Dec 2019 15:04:26 +0000</pubDate>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[decryption]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[hashing]]></category>
		<category><![CDATA[MD5]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rijndael]]></category>
		<category><![CDATA[SHA1]]></category>
		<category><![CDATA[SHA256]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[String-class]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=57</guid>

					<description><![CDATA[<p>I wrote those two following PHP functions to encrypt and decrypt strings easly and with a stronger encryption module than the other examples on the net (please, note that &#8220;strong&#8221; does not equals &#8220;secure&#8221;!); Happy encryption/decryption! 🙂 Max [sourcecode language=&#8221;php&#8221;] &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/easy-to-use-strong-encrypt-decrypt-php-functions/" aria-label="Easy-to-use and strong Encrypt/Decrypt PHP functions">Read More</a></p>
<p>The post <a href="https://www.maxvergelli.com/easy-to-use-strong-encrypt-decrypt-php-functions/">Easy-to-use and strong Encrypt/Decrypt PHP functions</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>I wrote those two following PHP functions to encrypt and decrypt strings easly and with a stronger encryption module than the other examples on the net (please, note that &#8220;strong&#8221; does not equals &#8220;secure&#8221;!);</p>
<p>Happy encryption/decryption! 🙂</p>
<p>Max</p>
<p>[sourcecode language=&#8221;php&#8221;]<br />
	function encrypt($input_string, $key){<br />
		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);<br />
		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);<br />
		$h_key = hash(&#8216;sha256&#8217;, $key, TRUE);<br />
		return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $h_key, $input_string, MCRYPT_MODE_ECB, $iv));<br />
	}</p>
<p>	function decrypt($encrypted_input_string, $key){<br />
		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);<br />
		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);<br />
		$h_key = hash(&#8216;sha256&#8217;, $key, TRUE);<br />
		return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $h_key, base64_decode($encrypted_input_string), MCRYPT_MODE_ECB, $iv));<br />
	}<br />
[/sourcecode]</p><p>The post <a href="https://www.maxvergelli.com/easy-to-use-strong-encrypt-decrypt-php-functions/">Easy-to-use and strong Encrypt/Decrypt PHP functions</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/easy-to-use-strong-encrypt-decrypt-php-functions/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">57</post-id>	</item>
		<item>
		<title>Javascript isArray() function</title>
		<link>https://www.maxvergelli.com/javascript-isarray-function/</link>
					<comments>https://www.maxvergelli.com/javascript-isarray-function/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Fri, 01 Nov 2019 14:50:42 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[array-function]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[datatype]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[isarray-function]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[typeof]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=55</guid>

					<description><![CDATA[<p>Javascript does not provide a function to recognize if a variable is an array or not; you can make a &#8220;typeof&#8221; of the variable however u&#8217;ll get an &#8216;object&#8217; datatype, as in the following code [sourcecode language=&#8221;javascript&#8221;] var myarray = &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/javascript-isarray-function/" aria-label="Javascript isArray() function">Read More</a></p>
<p>The post <a href="https://www.maxvergelli.com/javascript-isarray-function/">Javascript isArray() function</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Javascript does not provide a function to recognize if a variable is an array or not; you can make a &#8220;typeof&#8221; of the variable however u&#8217;ll get an &#8216;object&#8217; datatype, as in the following code<br />
[sourcecode language=&#8221;javascript&#8221;]<br />
var myarray = [1, 2, 3];<br />
var myobject = { key: &#8216;value&#8217; };<br />
alert(typeof myarray); //return &#8216;object&#8217;<br />
alert(typeof myobject); //return &#8216;object&#8217;<br />
[/sourcecode]</p>
<p>to recognize a data type &#8216;object&#8217; from &#8216;array&#8217;, you need a specialized function like this&#8230;<br />
[sourcecode language=&#8221;javascript&#8221;]<br />
function isArray(value){<br />
	var b = typeof value;<br />
	if(b === &#8216;object&#8217;){<br />
		if(value){<br />
			b = (typeof value.length === &#8216;number&#8217; &amp;&amp;<br />
				!(value.propertyIsEnumerable(&#8216;length&#8217;)) &amp;&amp;<br />
				typeof value.splice === &#8216;function&#8217;) ? true : false;<br />
		}else{<br />
			b = false;<br />
		};<br />
	};<br />
	return b;<br />
};<br />
var myarray = [1, 2, 3];<br />
var myobject = { key: &#8216;value&#8217; };<br />
alert(isArray(myarray)); //return true<br />
alert(isArray(myobject)); //return false<br />
[/sourcecode]</p>
<p>Good work!<br />
Max 🙂</p><p>The post <a href="https://www.maxvergelli.com/javascript-isarray-function/">Javascript isArray() function</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/javascript-isarray-function/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">55</post-id>	</item>
		<item>
		<title>How to stringify an object in Javascript: converting an object to a padded &#038; well-formatted string or simply inline</title>
		<link>https://www.maxvergelli.com/how-to-stringify-an-object-in-javascript-converting-an-object-to-a-padded-well-formatted-string-or-simply-inline/</link>
					<comments>https://www.maxvergelli.com/how-to-stringify-an-object-in-javascript-converting-an-object-to-a-padded-well-formatted-string-or-simply-inline/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Tue, 01 Oct 2019 14:45:36 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[String Manipulation Algorithms]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[formatting]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[stringification]]></category>
		<category><![CDATA[stringify]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=53</guid>

					<description><![CDATA[<p>I wrote a function to convert an object in a string (stringification) without using a JSON library; you can convert an object to a well formatted string with padding or simply to an unique line: [sourcecode language=&#8221;javascript&#8221;] function stringify(object, padding, &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-stringify-an-object-in-javascript-converting-an-object-to-a-padded-well-formatted-string-or-simply-inline/" aria-label="How to stringify an object in Javascript: converting an object to a padded &#038; well-formatted string or simply inline">Read More</a></p>
<p>The post <a href="https://www.maxvergelli.com/how-to-stringify-an-object-in-javascript-converting-an-object-to-a-padded-well-formatted-string-or-simply-inline/">How to stringify an object in Javascript: converting an object to a padded & well-formatted string or simply inline</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>I wrote a function to convert an object in a string (stringification) without using a JSON library; you can convert an object to a well formatted string with padding or simply to an unique line:</p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
function stringify(object, padding, margin){<br />
	var o = (typeof object == &#8216;object&#8217; || typeof object == &#8216;function&#8217;) &amp;&amp; object != null ? object : null;<br />
	var p = typeof padding == &#8216;boolean&#8217; &amp;&amp; padding ? true : false;<br />
	var m = typeof margin == &#8216;number&#8217; &amp;&amp; margin&gt;0 &amp;&amp; p ? margin : 0;<br />
	if(o != null){<br />
		var s = &#8221;;<br />
		var a = function(o){return (typeof o === &#8216;object&#8217; &amp;&amp; o ? ((typeof o.length === &#8216;number&#8217; &amp;&amp;!(o.propertyIsEnumerable(&#8216;length&#8217;)) &amp;&amp; typeof o.splice === &#8216;function&#8217;) ? true : false) : false);}; //is array?<br />
		for(var v in o){<br />
			s += typeof o[v] === &#8216;object&#8217; ? (o[v] ? (<br />
					(typeof o[v].length === &#8216;number&#8217; &amp;&amp; !(o[v].propertyIsEnumerable(&#8216;length&#8217;)) &amp;&amp; typeof o[v].splice === &#8216;function&#8217;) ?<br />
					(m&gt;0 ? Array(m).join(&#8216; &#8216;):&#8221;) + v + &#8216;:&#8217; + (p ? &#8216; &#8216;:&#8221;) + &#8216;[&#8216; + (p ? &#8216;rn&#8217;:&#8221;) + stringify(o[v],p,(m&gt;0?m:1)+v.length+4) + (p!=true ? &#8221; : &#8216;rn&#8217; + Array((m&gt;0?m:1)+v.length+2).join(&#8216; &#8216;)) + &#8216;],&#8217; + (p ? &#8216;rn&#8217;:&#8221;) :<br />
					(m&gt;0 ? Array(m).join(&#8216; &#8216;):&#8221;) + v + &#8216;:&#8217; + (p ? &#8216; &#8216;:&#8221;) + &#8216;{&#8216; + (p ? &#8216;rn&#8217;:&#8221;) + stringify(o[v],p,(m&gt;0?m:1)+v.length+4) + (p!=true ? &#8221; : &#8216;rn&#8217; + Array((m&gt;0?m:1)+v.length+2).join(&#8216; &#8216;)) + &#8216;},&#8217; + (p ? &#8216;rn&#8217;:&#8221;)<br />
				) : (m&gt;0 ? Array(m).join(&#8216; &#8216;):&#8221;) + v + &#8216;:&#8217; + (p ? &#8216; &#8216;:&#8221;) + o[v] + &#8216;,&#8217; + (p ? &#8216;rn&#8217;:&#8221;))<br />
			: (m&gt;0 ? Array(m).join(&#8216; &#8216;):&#8221;) + v + &#8216;:&#8217; + (p ? &#8216; &#8216;:&#8221;) + (typeof o[v] == &#8216;string&#8217; ? &#8221;&#8217; + o[v].replace(/&#8217;/g,&#8217;\&#8221;) + &#8221;&#8217; : o[v]) + &#8216;,&#8217; + (p ? &#8216;rn&#8217;:&#8221;);<br />
		};<br />
		o = s.length&gt;0 &amp;&amp; p!=true ? s.substring(0, s.length-1) : (s.length&gt;2 ? s.substring(0, s.length-3) : s);<br />
	}else{<br />
		o = object;<br />
	};<br />
	return o;<br />
};<br />
[/sourcecode]</p>
<p><strong>a little example, you declare same variable&#8230;.</strong></p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
var associative_array = new Array();<br />
associative_array[&#8216;one&#8217;] = 1;<br />
associative_array[&#8216;two&#8217;] = 2;<br />
associative_array[&#8216;undefinedvar&#8217;];</p>
<p>var myobject = {<br />
					mystring: &#8216;value&#8217;,<br />
					myquoted: &#8216;string with &#8216;single quotation mark&#8221;,<br />
					mynumber: 1,<br />
					myboolean: true,<br />
					myarray: [1, 2, 3],<br />
					myassocarray: associative_array,<br />
					myobject: {<br />
								obj_string: &#8216;hi!&#8217;,<br />
								obj_number: 1,<br />
								obj_array: [<br />
												&#8216;just&#8217;, &#8216;a&#8217;, &#8216;test&#8217;, 1, false,<br />
												[&#8216;array&#8217;, &#8216;inside&#8217;, &#8216;array&#8217;],<br />
												{<br />
													object: &#8216;inside array&#8217;,<br />
													array: [1,2,3,4,5,6,7,8,9]<br />
												},</p>
<p>											]<br />
								},<br />
					mynullvalue: null,<br />
					myundefined: associative_array[&#8216;undefinedvar&#8217;],<br />
					myfunction: function(){ var s = &#8216;hello!&#8217;; return s; }<br />
				};<br />
[/sourcecode]</p>
<p><strong>then, for an inline stringification, you can use</strong></p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
var str = stringify(myobject);<br />
[/sourcecode]</p>
<p><strong>and &#8220;str&#8221; value will be a string as</strong></p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
mystring:&#8217;value&#8217;,myquoted:&#8217;string with &#8216;single quotation mark&#8221;,mynumber:1,myboolean:true,myarray:[0:1,1:2,2:3],myassocarray:[one:1,two:2],myobject:{obj_string:&#8217;hi!&#8217;,obj_number:1,obj_array:[0:&#8217;just&#8217;,1:&#8217;a&#8217;,2:&#8217;test&#8217;,3:1,4:false,5:[0:&#8217;array&#8217;,1:&#8217;inside&#8217;,2:&#8217;array&#8217;],6:{object:&#8217;inside array&#8217;,array:[0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9]}]},mynullvalue:null,myundefined:undefined,myfunction:function () {<br />
    var s = &quot;hello!&quot;;<br />
    return s;<br />
}<br />
[/sourcecode]</p>
<p><strong>Instead, for a stringification with a well formatted padding, you can use</strong></p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
var str_formatted = stringify(myobject, true);<br />
[/sourcecode]</p>
<p><strong>and this is the &#8220;str_formatted&#8221; value:</strong></p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
mystring: &#8216;value&#8217;,<br />
myquoted: &#8216;string with &#8216;single quotation mark&#8221;,<br />
mynumber: 1,<br />
myboolean: true,<br />
myarray: [<br />
           0: 1,<br />
           1: 2,<br />
           2: 3<br />
         ],<br />
myassocarray: [<br />
                one: 1,<br />
                two: 2<br />
              ],<br />
myobject: {<br />
            obj_string: &#8216;hi!&#8217;,<br />
            obj_number: 1,<br />
            obj_array: [<br />
                         0: &#8216;just&#8217;,<br />
                         1: &#8216;a&#8217;,<br />
                         2: &#8216;test&#8217;,<br />
                         3: 1,<br />
                         4: false,<br />
                         5: [<br />
                              0: &#8216;array&#8217;,<br />
                              1: &#8216;inside&#8217;,<br />
                              2: &#8216;array&#8217;<br />
                            ],<br />
                         6: {<br />
                              object: &#8216;inside array&#8217;,<br />
                              array: [<br />
                                       0: 1,<br />
                                       1: 2,<br />
                                       2: 3,<br />
                                       3: 4,<br />
                                       4: 5,<br />
                                       5: 6,<br />
                                       6: 7,<br />
                                       7: 8,<br />
                                       8: 9<br />
                                     ]<br />
                            }<br />
                       ]<br />
          },<br />
mynullvalue: null,<br />
myundefined: undefined,<br />
myfunction: function () {<br />
    var s = &quot;hello!&quot;;<br />
    return s;<br />
}<br />
[/sourcecode]</p>
<p>Finally, when you pass a variable to stringify() that is not an object, it will just return the value.</p>
<p>Happy stringifications!</p>
<p>Max 🙂</p><p>The post <a href="https://www.maxvergelli.com/how-to-stringify-an-object-in-javascript-converting-an-object-to-a-padded-well-formatted-string-or-simply-inline/">How to stringify an object in Javascript: converting an object to a padded & well-formatted string or simply inline</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-stringify-an-object-in-javascript-converting-an-object-to-a-padded-well-formatted-string-or-simply-inline/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">53</post-id>	</item>
	</channel>
</rss>
