myList.RemoveAt(myList.Count - 1);
This blog shares my journey as a software engineer, along with personal reviews and life experiences I’ve gained along the way. “I have not failed. I've just found 10,000 ways that won't work.” — Thomas Edison. If you enjoy my content, please support it by clicking on ads (free for you, big help for me!) or by buying me a coffee on Ko-fi. Thank you!
Wednesday, July 15, 2015
Boot Strap Search Box with glyphicon glypicon-search
Adding to Code Library OPEN SOURCE
<div class="row"> <div class="container"> <div class="col-md-offset-3 col-md-6 col-md-offset-3"> <div class="input-group"> <span class="input-group-btn"> <input type="text" id="txtGlobalSearch" class="form-control" placeholder="Search Site..." onkeypress="return submitglobal(this, event);"/> <button type="button" class="btn btn-default" runat="server" onclick="GlobalSearch(); return false;"><span class="glyphicon glyphicon-search"></span></button> </span> </div><!-- /input-group --> </div><!-- /.col-md-12 --> </div><!-- Container --> </div><!-- Row -->
Monday, July 06, 2015
Caching --- How to ensure you optimize
IIS, Optimising Performance, 304 status codes, and one stupid browser…
How to prevent 304 responses and be sure to know that Chrome acts different with DEV tools --- Great article by Terry Brown... http://idisposable.co.uk/2011/03/iis-optimising-performance-304-status-codes-and-one-stupid-browser/#comment-2119464518
Note when use the Chrome Developer tools looks at two columns ---
Note when use the Chrome Developer tools looks at two columns ---
Wednesday, June 17, 2015
What is the difference between ByVal and ByRef?
Xiaoyun Li MSFT answers ---
https://social.msdn.microsoft.com/forums/vstudio/en-US/07b9d3b9-5658-49ed-9218-005564e8209e/what-is-the-difference-between-byval-and-byref
https://social.msdn.microsoft.com/forums/vstudio/en-US/07b9d3b9-5658-49ed-9218-005564e8209e/what-is-the-difference-between-byval-and-byref
When you write a subroutine or function, you can pass variables from your main code to that subroutine or function.
If you want to pass the value of the variable, use the ByVal syntax. By passing the value of the variable instead of a reference to the variable, any changes to the variable made by code in the subroutine or function will not be passed back to the main code. This is the default passing mechanism when you don’t decorate the parameters by using ByVal or ByRef.
If you want to change the value of the variable in the subroutine or function and pass the revised value back to the main code, use the ByRef syntax. This passes the reference to the variable and allows its value to be changed and passed back to the main code.
For more information about passing Arguments by Value and by Reference, please refer to MSDN document:
C# ---
.NET Coding: Argument as ByRef (ref in C#) or ByVal (default in C#)
Thursday, June 11, 2015
Wednesday, June 10, 2015
Thursday, June 04, 2015
Time Span Check for Store Hours to show... Using a .NET Literal Control
I have done this countless times, but senior moments are happening.
That is all for today....
Now I will always refer back to the My Blog to review...
I like how the conditional logic is written
LowerBound <= Value <= Upper Bound
AndAlso for short circuiting
Till Next Post.
Const timeHourOpen As Integer = 8 Const timeHourClosed As Integer = 16 'Set one hour less because at 5:00 the store will close
If (timeHourOpen <= DateTime.Now.Hour AndAlso DateTime.Now.Hour <= timeHourClosed) Then'Account for greater than 17 hundred hours aka 17:01 callCenterOpen.Visible = True Else callCenterOpen.Visible = False End If
That is all for today....
Now I will always refer back to the My Blog to review...
I like how the conditional logic is written
LowerBound <= Value <= Upper Bound
AndAlso for short circuiting
Till Next Post.
Thursday, May 21, 2015
Auto load content on scroll down
First Special Thanks to --- Adam Khoury @ www.DevelopPHP.com - https://www.developphp.com/video/JavaScript/Scroll-Load-Dynamic-Content-When-User-Reach-Bottom-Ajax
I extended this a bit to include some back to top feature.
I extended this a bit to include some back to top feature.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="JavaScripAutoScroll.aspx.vb" Inherits="JavaScripAutoScroll" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>JavaScript Auto Populate the page | MMWebs.biz</title>
<style type="text/css"> div#status{ position: fixed;font-size: 24px;} div#wrap{ width: 800px; margin: 0 auto} div.newData{ height: 1000px;background: #09F;margin: 10px 10px;} .back-to-top { position: fixed; bottom: 2em; right: 0px; z-index: 999; text-decoration: none; color: #000000; background-color: rgba(235, 235, 235, 0.80); font-size: 12px; padding: 1em; display: none; } .back-to-top:hover { background-color: rgba(135, 135, 135, 0.50); } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function yHandler() { var wrap = document.getElementById('wrap'); var contentHeidht = wrap.offsetHeight; // Gets page content height var yOffset = window.pageYOffset; //Gets the vertical scroll position var y = yOffset + window.innerHeight; if (y >= contentHeidht) { wrap.innerHTML += '<div class="newData"></div>'; // Ajax call to get more dynamic data goes here } var status = document.getElementById('status'); status.innerHTML = contentHeidht + " | " + y; } window.onscroll = yHandler; </script> </head> <body> <a href="#" class="back-to-top">Back to Top</a> <form id="form1" runat="server"> <div> <div id="status">0 | 0</div> <div id="wrap"><img src="framework/images/tempMatrix.gif" width="800px" height="1200px" /></div> </div> </form> </body> </html> <script type="text/javascript"> var offset = 220; var duration = 500; jQuery(window).scroll(function () { if (jQuery(this).scrollTop() > offset) { jQuery('.back-to-top').fadeIn(duration); } else { jQuery('.back-to-top').fadeOut(duration); } }); jQuery('.back-to-top').click(function (event) { event.preventDefault(); jQuery('html, body').animate({ scrollTop: 0 }, duration); return false; }); </script>
Thursday, May 14, 2015
Web site performance - Keys to running a high performance Web site
So you have built your site and lets say it is an eCommerce site which displays tens of thousands of static images and gets 500,000 session per month.
TEST PERFORMANCE
http://www.webpagetest.org/ (Best performance tester on the Web)
However, you are seeing poor performance from servers around the world. How do you fix this. Well in the coming weeks I will tell you. Right now I am doing research on this very thing and I will return to let you know the results.
Test 1 --- Servers hosted in NC and the site being hit from OR--- Currently the site I am supporting has a first hit load time of 6.226 seconds, but with caching this is reduced to 2.750 seconds on the second hit. However the 6.226 seconds is still way to long.
Test 2 --- Servers hosted in NC and the site being hit from NY --- Currently the site I am supporting has a first hit load time of 4.053 seconds, but with caching this is reduced to 1.319 seconds on the second hit. However the 4.053 seconds is still way to long.
Test 3 --- Servers hosted in NC and the site being hit from VA --- Currently the site I am supporting has a first hit load time of 5.211 seconds, but with caching this is reduced to 3.428 seconds on the second hit. However the 5.211seconds is still way to long.
"F" --- Currently the key issues are the First Byte Time --
TEST PERFORMANCE
http://www.webpagetest.org/ (Best performance tester on the Web)
However, you are seeing poor performance from servers around the world. How do you fix this. Well in the coming weeks I will tell you. Right now I am doing research on this very thing and I will return to let you know the results.
Test 1 --- Servers hosted in NC and the site being hit from OR--- Currently the site I am supporting has a first hit load time of 6.226 seconds, but with caching this is reduced to 2.750 seconds on the second hit. However the 6.226 seconds is still way to long.
Test 2 --- Servers hosted in NC and the site being hit from NY --- Currently the site I am supporting has a first hit load time of 4.053 seconds, but with caching this is reduced to 1.319 seconds on the second hit. However the 4.053 seconds is still way to long.
Test 3 --- Servers hosted in NC and the site being hit from VA --- Currently the site I am supporting has a first hit load time of 5.211 seconds, but with caching this is reduced to 3.428 seconds on the second hit. However the 5.211seconds is still way to long.
"F" --- Currently the key issues are the First Byte Time --
First Byte Time | Applicable Objects | Time to First Byte for the page (back-end processing + redirects) |
---|---|---|
What is checked | The target time is the time needed for the DNS, socket and SSL negotiations + 100ms. A single letter grade will be deducted for every 100ms beyond the target. |
The second issue is Cache of static content, however I cannot cache this content as this is an eCommerce site and you have to be sure you follow PCI rules https://www.pcisecuritystandards.org/
How do you decrease this 6.226 seconds issue --- My attempts will be to use Content Delivery Network (CDN) aka EDGE SERVERS.
In the coming weeks I will be updating this blog to give the results.
My work will be to off load the Images, JavaScript Files (JS), and Cascading Style Sheets (CSS), to increase performance of the site.
I will be very curious to see if that 500,000 sessions will increase once we implement CDN to increase the sites performance.
More to come.
Thursday, March 26, 2015
7 things to check to resolve “A network-related or instance-specific error occurred while establishing a connection to SQL Server…” by Donabel Santos, edited by Moojjoo
If you get the following SQL
Server Error:
“A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) ”
“A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) ”
Things to check:
1. Make sure your database engine is configured to accept remote connections
1. Make sure your database engine is configured to accept remote connections
• If you are not using a domain account as a service account (for example if you are using NETWORK SERVICE), you may want to switch this first before proceeding
3. If you are using a named SQL Server instance, make sure you are
using that instance name in your connection strings in your ASweb P.NET
application
• Usually the format needed to specify the database server is machinename\instancename
• Check your connection string as well
• Usually the format needed to specify the database server is machinename\instancename
• Check your connection string as well
<connectionStrings>
<add name="SampleConnectionString"
connectionString="Data Source=machinename\instancename;Initial
Catalog=AdventureWorks;Integrated Security=SSPI;Min Pool Size=5;Max Pool
Size=60;Connect Timeout=30″ providerName="System.Data.SqlClient"/>
</connectionStrings>
4. You may need to create an exception on the firewall for the SQL
Server instance and port you are using
• Start > Run > Firewall.cpl
• Click on exceptions tab
• Add the sqlservr.exe (typically located in C:\Program Files (x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Binn, check your installs for the actual folder path), and port (default is 1433)
• Check your connection string as well
• Start > Run > Firewall.cpl
• Click on exceptions tab
• Add the sqlservr.exe (typically located in C:\Program Files (x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Binn, check your installs for the actual folder path), and port (default is 1433)
• Check your connection string as well
5. If you are using a named SQL Server instance, make sure you are
using that instance name in your connection strings
6. Check SQLBrowser; check that it is running. You may also need to create an exception in
your firewall for SQLBrowser.
7. Check that you have connectivity to the SQL Server.
Note what you are using to connect: machine name, domain name or IP address? Use this when checking connectivity. For example if you are using myserver
• Start > Run > cmd
•netstat -ano right click on the window title and use find 1433
•telnet myserver 1433
•ping -a myserver
Note what you are using to connect: machine name, domain name or IP address? Use this when checking connectivity. For example if you are using myserver
• Start > Run > cmd
•netstat -ano right click on the window title and use find 1433
•telnet myserver 1433
•ping -a myserver
Check what ports are IP addresses are being returned.
If you still can’t get any connection, you may want to create a
SQL account on the server, a corresponding SQL user on the database in
question, and just use this username/password combo in your web application.
Friday, February 13, 2015
SQL Server How to Drop Connections
ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE dbname SET MULTI_USER GO
Friday, January 16, 2015
IIS 7.5 FTP and Virtual Directory not displaying in FileZilla - 550 Keyset does not exist
Software -
- Windows 2003 R2 - IIS 7.5 using FTP
- FileZilla (Protocol=FTP; Encryption=Require explicit FTP over TLS; Logon Type:=Normal; UserName=****; Passwword=****** Currently there are 3 virtual drives and when I connect via FileZilla they all display fine, however when I try to configure a 4th virtual directory it will not display in FileZilla.
I am actually getting a sporadic failure all together after the directory is created:
Command: LIST Error: GnuTLS error -110: The TLS connection was non-properly terminated. Status: Server did not properly shut down TLS connection Error: Transfer connection interrupted: ECONNABORTED - Connection aborted Response: 550 Keyset does not exist Error: Failed to retrieve directory listing
If I delete the Virtual Directory the directories will display again. What is wrong, all the permissions are identical. Is there something with the SSL that has to be configured on the directory? Any assistance would be great.
SOLUTION
Navigate on the Windows Server 2008 R2 using Windows Explorer
1. %ALLUSERSPROFILE%\Microsoft\Crypto\RSA\MachineKeys
2. Right Click on Machine Key = 76944fb33636aeddb9590521c2e8815a_GUID
3. Granted the FTP Account -- Read & Execute; Read Access... Problem resolved.
I hope this helps someone. Give me a 1+ if it does, because it stumped me for a good 2 days.
Friday, January 02, 2015
Force Kill Process - MSDN
Working on some Windows 2008 R2 FTP issues and the services got hung. After some Goolge searching I found the following article to KILL THE Services Process that was hung.
In this case it was the ftpsvc process.
1) Open Task Manger
2) Go to the Services Tab
3) Take note of the PID
http://technet.microsoft.com/en-us/library/cc725602.aspx
In this case it was the ftpsvc process.
1) Open Task Manger
2) Go to the Services Tab
3) Take note of the PID
taskkill /pid #### /f
/f forces --- Problem solved yes I was sweating bullets.
http://technet.microsoft.com/en-us/library/cc725602.aspx
Tuesday, November 11, 2014
Wednesday, October 29, 2014
Get httpPostedFileBase FileName only code or extract last portion of file director path
var httpPostedFileBase = Request.Files.Get("DocumentFileName"); var myFileName = string.Empty; if (httpPostedFileBase != null) { int position = httpPostedFileBase.FileName.LastIndexOf('\\'); myFileName = httpPostedFileBase.FileName.Substring(position + 1); }
Friday, October 24, 2014
Wednesday, October 15, 2014
Reading Keys from Web.config file.
Try using the WebConfigurationManager class instead. For example:
C# string userName = WebConfigurationManager.AppSettings["PFUserName"];
OR
VB.NET Dim userName as String = WebConfigurationManager.AppSettings("PFUserName")
Read file using FileStream - Reference - http://www.csharp-examples.net/filestream-read-file/
Read file using FileStream
First create FileStream to open a file for reading. Then call FileStream.Read in a loop until the whole file is read. Finally close the stream.
[C#]using System.IO; public static byte[] ReadFile(string filePath) { byte[] buffer; FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read); try { int length = (int)fileStream.Length; // get file length buffer = new byte[length]; // create buffer int count; // actual number of bytes read int sum = 0; // total number of bytes read // read until Read method returns 0 (end of the stream has been reached) while ((count = fileStream.Read(buffer, sum, length - sum)) > 0) sum += count; // sum is a buffer offset for next reading } finally { fileStream.Close(); } return buffer; }
Wednesday, October 01, 2014
jQuery $.ajax call add functions you will need to call after the html is rendered.
I am adding the following blog post because I spent a good amount of time working on figuring the following out.
Using the jQuery function $.ajax I learned that you need to be sure to add all the functions you want to perform actions on after the $.ajax loads the new content to the page.
CORRECT CODE
<script type="text/javascript">
$("#addItem").click(function () {
$.ajax({
url: this.href,
cache: false,
success: function (html) {
$("#editorRows").append(html);
$("a.deleteRow").on("click", function () {
$(this).parents("div.editorRow:first").remove();
return false;
});
}
});
return false;
});
</script>
This makes 100% sense because if you code it as follows it will never work because the .append(html) is not on the page currently when the jQuery loads.
BAD CODE
<script type="text/javascript">
$("#addItem").click(function () {
$.ajax({
url: this.href,
cache: false,
success: function (html) {
$("#editorRows").append(html);
}
});
return false;
});
//Following will not be called --- because it is not on the page currently
$("a.deleteRow").on("click", function () {
$(this).parents("div.editorRow:first").remove();
return false;
});
</script>
Hope this helps. Have fun coding.
Subscribe to:
Posts (Atom)