Code Snippets .NET VB

Dynamically Generate and Display Barcode Image in ASP.Net

n this article I will explain how to dynamically generate and display barcode image using ASP.Net in C# and VB.Net languages.
 
Barcode Font
First you will need to download the Free Barcode Font from the following URL
Once downloaded follow the following steps.
1. Extract the ZIP file.
2. Click and Execute INSTALL.exe file.
3. After installation is completed restart your machine.



 

<form id="form1" runat="server">
<asp:TextBox ID="txtCode" runat="server"></asp:TextBox>
<asp:Button ID="btnGenerate" runat="server" Text="Generate" onclick="btnGenerate_Click" />

<hr />

<asp:PlaceHolder ID="plBarCode" runat="server" />
</form>




 


 
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO

 

 


Protected Sub btnGenerate_Click(sender As Object, e As EventArgs)
    Dim barCode As String = txtCode.Text
    Dim imgBarCode As New System.Web.UI.WebControls.Image()
    Using bitMap As New Bitmap(barCode.Length * 40, 80)
        Using graphics__1 As Graphics = Graphics.FromImage(bitMap)
            Dim oFont As New Font("IDAutomationHC39M", 16)
            Dim point As New PointF(2.0F, 2.0F)
            Dim blackBrush As New SolidBrush(Color.Black)
            Dim whiteBrush As New SolidBrush(Color.White)
            graphics__1.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height)
            graphics__1.DrawString("*" & barCode & "*", oFont, blackBrush, point)
        End Using
        Using ms As New MemoryStream()
            bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
            Dim byteImage As Byte() = ms.ToArray()
 
            Convert.ToBase64String(byteImage)
            imgBarCode.ImageUrl = "data:image/png;base64," & Convert.ToBase64String(byteImage)
        End Using
        plBarCode.Controls.Add(imgBarCode)
    End Using
End Sub

 

 

 

 

https://www.aspsnippets.com/Articles/Dynamically-Generate-and-Display-Barcode-Image-in-ASPNet.aspx

Tutorials

Freetextbox

Aparentemente o website official já não está disponivel.


Imports FreeTextBoxControls
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim toolbar1 As New Toolbar()
toolbar1.Items.Add(New ParagraphMenu())
toolbar1.Items.Add(New FontSizesMenu())

FreeTextBox1.Toolbars.Add(toolbar1)
Dim toolbar2 As New Toolbar()
toolbar2.Items.Add(New Bold())
toolbar2.Items.Add(New Italic())
toolbar2.Items.Add(New Underline())
toolbar2.Items.Add(New ToolbarSeparator())
toolbar2.Items.Add(New BulletedList())
toolbar2.Items.Add(New NumberedList())
FreeTextBox1.Toolbars.Add(toolbar2)
End Sub
End Class

propriedade ToolbarLayout:

ParagraphMenu, FontFacesMenu, FontSizesMenu, FontForeColorsMenu
,  FontForeColorPicker, FontBackColorsMenu, FontBackColorPicker
, Bold, Italic, Underline, Strikethrough, Superscript, Subscript
, InsertImageFromGallery, CreateLink, Unlink,  RemoveFormat
, JustifyLeft, JustifyRight, JustifyCenter, JustifyFull
, BulletedList, NumberedList, Indent, Outdent, Cut, Copy, Paste
, Delete, Undo, Redo, Print, Save,  ieSpellCheck, StyleMenu
, SymbolsMenu, InsertHtmlMenu, InsertRule, InsertDate, InsertTime
, WordClean, InsertImage, InsertTable, EditTable, InsertTableRowBefore
,   InsertTableRowAfter, DeleteTableRow, InsertTableColumnBefore
, InsertTableColumnAfter, DeleteTableColumn, InsertForm, InsertForm
, InsertTextBox, InsertTextArea,  InsertRadioButton, InsertCheckBox
, InsertDropDownList, InsertButton, InsertDiv,  InsertImageFromGallery
, Preview, SelectAll, EditStyle.

 

Nota: Se você for usar o componente para enviar mensagens não esqueça de desabilitar o ValidateRequest definindo na página ASPX o seu valor como false:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" validateRequest="false" %>

ArcGIS

Coordenadas GPS

Graus, minutos e segundos (DMS): 41°24’12.2″N 2°10’26.5″E
Graus e minutos decimais (DMM): 41 24.2028, 2 10.4418
Graus decimais (DD): 41.40338, 2.17403

Code Snippets

Tips for Coding Email Preheaders

Hidden preheader text

here are a lot of designs that just won’t accommodate visible preheader text, or it become undesirable for branding reasons. If you’d like to add hidden preheader text to your email, don’t worry, it’s not hard!
To begin with, you’ll want to pick a place where the preheader text won’t cause issues in your layout. Usually the text will take up, at most, one pixel of vertical space, but in some cases this can bump down content. If you’re putting the preheader text into an existing header, you may want to give it a row to itself, so that if any content below is moved, it will all be moved the same amount.
To hide the text, you’ll want to include the following inline styles:


<td style="display:none !important; visibility:hidden; mso-hide:all; font-size:1px; color:#ffffff; line-height:1px; max-height:0px; max-width:0px; opacity:0; overflow:hidden;">
  This is preheader text.            
</td>

As you can see, I have hidden the text in a multitude of ways. Many of these are fallbacks for clients that don’t recognize or play nicely with some of the other styles in the list.

One tip from my own personal experience: Don’t put placeholder text here! You may want to add placeholder text for testing, but make sure to remove it after. The last thing you want is for an email to go out with “This is preheader text” as the actual preheader text… unless you are intentionally making a “This is Spinal Tap” reference. It’s much better to have an email go out with no preheader text than with placeholder text.

Preheader character limits

Just how much preheader text should you include? We recommend 50-100 characters. Though some clients are capable of showing more than this, it’s usually only under special circumstances (like a very wide browser window). Check out this chart to see the limits of some popular email clients.

Preheader Character Limits

Email Client Limit
iPhone (5S) 64
Gmail (Web Client) 100
Gmail (iOS Client, 5S) 34
iPad 5, Mail App 64
Android 4.4 97
Apple Mail 8 50-100
Outlook 2013 60-100
Outlook.com 124-236
Yahoo! Mail 135-202

source:
https://www.emailonacid.com/blog/article/email-development/tips-for-coding-email-preheaders

.NET ASP.Net 2.0 IIS

The page was not displayed because the request entity is too large. iis7

“The page was not displayed because the request entity is too large.”

 

I think this will fix the issue IF you have SSL enabled:

Setting uploadReadAheadSize in applicationHost.config file on IIS7.5 would resolve your issue in both cases. You can modify this value directly in applicationhost.config.

1) Select the site under Default Web Site

2) Select Configuration Editor

3) Within Section Dropdown, select “system.webServer/serverRuntime”

4) Enter a higher value for “uploadReadAheadSize” such as 1048576 bytes. Default is 49152 bytes.

During client renegotiation process, the request entity body must be preloaded using SSL preload. SSL preload will use the value of the UploadReadAheadSize metabase property, which is used for ISAPI extensions

Reference: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/7e0d74d3-ca01-4d36-8ac7-6b2ca03fd383.mspx?mfr=true

 

Code Snippets SQL Server Transact-SQL

DBCC SHRINKFILE (Transact-SQL)

A. Shrinking a data file to a specified target size

The following example shrinks the size of a data file named DataFile1 in the UserDB user database to 7 MB.


USE UserDB;
GO
DBCC SHRINKFILE (DataFile1, 7);
GO

B. Shrinking a log file to a specified target size

The following example shrinks the log file in the AdventureWorks database to 1 MB. To allow the DBCC SHRINKFILE command to shrink the file, the file is first truncated by setting the database recovery model to SIMPLE.


USE AdventureWorks2012;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE AdventureWorks2012
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks2012_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE AdventureWorks2012
SET RECOVERY FULL;
GO

C. Truncating a data file

The following example truncates the primary data file in the AdventureWorks database. The sys.database_files catalog view is queried to obtain the file_id of the data file.


&nbsp;

USE AdventureWorks2012;
GO
SELECT file_id, name
FROM sys.database_files;
GO
DBCC SHRINKFILE (1, TRUNCATEONLY);

D. Emptying a file

The following example demonstrates the procedure for emptying a file so that it can be removed from the database. For the purposes of this example, a data file is first created and it is assumed that the file contains data.


USE AdventureWorks2012;
GO
-- Create a data file and assume it contains data.
ALTER DATABASE AdventureWorks2012
ADD FILE (
NAME = Test1data,
FILENAME = 'C:\t1data.ndf',
SIZE = 5MB
);
GO
-- Empty the data file.
DBCC SHRINKFILE (Test1data, EMPTYFILE);
GO
-- Remove the data file from the database.
ALTER DATABASE AdventureWorks2012
REMOVE FILE Test1data;
GO

https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-shrinkfile-transact-sql

Code Snippets Networking NTP

Windows Domain and NTP Servers

Find your PDC Emulator

Get-ADDomainController -Discover -Service PrimaryDC

Transfer domain roles if needed

https://technet.microsoft.com/pt-pt/library/cc816944(v=ws.10).aspx

ntp Servers Pt

http://www.pool.ntp.org/zone/pt
pool.ntp.org

Set NTP

https://blogs.technet.microsoft.com/nepapfe/2013/03/01/its-simple-time-configuration-in-active-directory/

Using w32tm.exe

Run the following command on the PDC emulator:

w32tm /config /manualpeerlist:timeserver /syncfromflags:manual /reliable:yes /update

(where timeserver is a –space delimited– list of your time source servers)

Once done, restart W32Time service.

net stop w32time
net start w32time

Run the following command on all other DCs (that are not PDC):

w32tm /config /syncfromflags:domhier /update

Once done, restart W32Time service.

FIND DC’servers

PS   nltest /dclist:mydomain.local

 

Configurar o NTP no Linux
https://pplware.sapo.pt/linux/ntp-sincronize-o-relogio-do-seu-linux/

1- Vamos começar por instalar o ntp

yum install ntp

2- Agora activamos o serviço

chkconfig ntpd on

Indicação do servidor a usar para sincronizar o nosso relógio. Para esse vou usar um dos disponibilizados pelo Observatório Astronómico de Lisboa

ntpdate ntp02.oal.ul.pt

Nota: O Observatório Astronómico de Lisboa disponibiliza 2 servidores para configuração dos relógios. Quem pretender usar os dois deve editar o ficheiro /etc/ntp.conf e incluir a seguinte informação:

server ntp02.oal.ul.pt
server ntp04.oal.ul.pt

3- Iniciar o serviço do ntpd

/etc/init.d/ntpd start&nbsp;
Code Snippets

Windows server 2K12R2 Second hard drive says write-protected

Find your PDC Emulator

Get-ADDomainController -Discover -Service PrimaryDC

Transfer domain roles if needed

https://technet.microsoft.com/pt-pt/library/cc816944(v=ws.10).aspx

ntp Servers Pt

http://www.pool.ntp.org/zone/pt
pool.ntp.org

Set NTP

https://blogs.technet.microsoft.com/nepapfe/2013/03/01/its-simple-time-configuration-in-active-directory

Using w32tm.exe

Run the following command on the PDC emulator:

w32tm /config /manualpeerlist:timeserver /syncfromflags:manual /reliable:yes /update

(where timeserver is a –space delimited– list of your time source servers)

Once done, restart W32Time service.

net stop w32time
net start w32time

Run the following command on all other DCs (that are not PDC):

w32tm /config /syncfromflags:domhier /update

Once done, restart W32Time service.

FIND DC servers

PS C:\Users\Administrador> nltest /dclist:mydomain.local
Tips & tricks Utils

Lista com compilação de algumas entidades de multibanco úteis:

omo saber a quem pertence uma entidade / referência MB de pagamento de serviços?

read more »

Code Snippets SQL

MySQL DATE_FORMAT

DATE_FORMAT(date,format)

%a    Abbreviated weekday name (Sun-Sat)
%b    Abbreviated month name (Jan-Dec)
%c    Month, numeric (0-12)
%D    Day of month with English suffix (0th, 1st, 2nd, 3rd, ?)
%d    Day of month, numeric (00-31)
%e    Day of month, numeric (0-31)
%f    Microseconds (000000-999999)
%H    Hour (00-23)
%h    Hour (01-12)
%I    Hour (01-12)
%i    Minutes, numeric (00-59)
%j    Day of year (001-366)
%k    Hour (0-23)
%l    Hour (1-12)
%M    Month name (January-December)
%m    Month, numeric (00-12)
%p    AM or PM
%r    Time, 12-hour (hh:mm:ss followed by AM or PM)
%S    Seconds (00-59)
%s    Seconds (00-59)
%T    Time, 24-hour (hh:mm:ss)
%U    Week (00-53) where Sunday is the first day of week
%u    Week (00-53) where Monday is the first day of week
%V    Week (01-53) where Sunday is the first day of week, used with %X
%v    Week (01-53) where Monday is the first day of week, used with %x
%W    Weekday name (Sunday-Saturday)
%w    Day of the week (0=Sunday, 6=Saturday)
%X    Year for the week where Sunday is the first day of week, four digits, used with %V
%x    Year for the week where Monday is the first day of week, four digits, used with %v
%Y    Year, numeric, four digits
%y    Year, numeric, two digits

The following script uses the DATE_FORMAT() function to display different formats. We will use the NOW() function to get the current date/time:

DATE_FORMAT(NOW(),’%b %d %Y %h:%i %p’)
DATE_FORMAT(NOW(),’%m-%d-%Y’)
DATE_FORMAT(NOW(),’%d %b %y’)
DATE_FORMAT(NOW(),’%d %b %Y %T:%f’)

The result would look something like this:

Nov 04 2014 11:45 PM
11-04-2014
04 Nov 14
04 Nov 2014 11:45:34:243