DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets

  • submit to reddit

Recent Snippets

                    # Sample 1: 
RewriteRule ^about$ about.php [L]
 
# Sample 2: 
RewriteCond /%{REQUEST_FILENAME}.php -f
RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.php                
                    # Source: http://www.apphp.com/index.php?snippet=htaccess-different-directory-index-page

# Sample 1: 
DirectoryIndex index2.html
 
# Sample 2: 
DirectoryIndex index2.php                
                    # Sample 1: 
DirectoryIndex index2.html
 
# Sample 2: 
DirectoryIndex index2.php                
                    -- 1st example
UPDATE files SET filepath = REPLACE(filepath,'path/to/search','path/to/replace');
 
-- 2nd example
UPDATE customers SET address = REPLACE(address,'_CODE_',postcode);                
                    <!-- First way -->
<input type="button" value="This is
a Really
Tall
 Button">
<!-- Second way -->
<button>This is<br/>a Really<br/>Tall<br/>Button</button>                
                    <!-- This is a comment. Comments are not displayed in the browser. -->
 
<div id="header">
   <p>Some text</p>
</div> <!-- END div-header -->
 
<script type="text/javascript">
<!--
function ShowMessage()
{
  alert("Hello World!")
}
//-->
</script>

                
                    //The Sample code shows how to export VSD to VDX

//[C# Sample]
 
//Call the diagram constructor to load diagram from a VSD file
Diagram diagram = new Diagram("D:\\Drawing1.vsd");
this.Response.Clear();
this.Response.ClearHeaders();
this.Response.ContentType = "application/vnd.ms-visio";
this.Response.AppendHeader("Content-Disposition", "attachment; filename=Diagram.vdx");
this.Response.Flush();
System.IO.Stream vdxStream = this.Response.OutputStream;

//Save input VSD as VDX
diagram.Save(vdxStream, SaveFileFormat.VDX);
this.Response.End();

//[VB.NET Code Sample]

'Call the diagram constructor to load diagram from a VSD file
Dim diagram As New Diagram("D:\Drawing1.vsd")

Me.Response.Clear()
Me.Response.ClearHeaders()
Me.Response.ContentType = "application/vnd.ms-visio"
Me.Response.AppendHeader("Content-Disposition", "attachment; filename=Diagram.vdx")
Me.Response.Flush()
Dim vdxStream As System.IO.Stream = Me.Response.OutputStream

'Save inpupt VSD as VDX
diagram.Save(vdxStream, SaveFileFormat.VDX)
Me.Response.End()

//The Sample code shows how to export VSD to VSX format.

[C# Code Sample]

// Call the diagram constructor to load diagram from a VSD file
Diagram diagram = new Diagram("D:\\Drawing1.vsd");
this.Response.Clear();
this.Response.ClearHeaders();
this.Response.ContentType = "application/vnd.ms-visio";
this.Response.AppendHeader("Content-Disposition", "attachment; filename=Diagram.vsx");
this.Response.Flush();
System.IO.Stream vsxStream = this.Response.OutputStream;

//Save input VSD as VSX
diagram.Save(vsxStream, SaveFileFormat.VSX);
this.Response.End()

//[VB.NET Code Sample]

'Call the diagram constructor to load diagram from a VSD file
Dim diagram As New Diagram("D:\Drawing1.vsd")

Me.Response.Clear()
Me.Response.ClearHeaders()
Me.Response.ContentType = "application/vnd.ms-visio"
Me.Response.AppendHeader("Content-Disposition", "attachment; filename=Diagram.vsx")
Me.Response.Flush()
Dim vsxStream As System.IO.Stream = Me.Response.OutputStream

'Save input VSD as VSX
diagram.Save(vsxStream, SaveFileFormat.VSX)
Me.Response.End()
                
                    <style type="text/css">
.break {
    -ms-word-break: break-all;
    word-break: break-all;
    word-break: break-word; 
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    hyphens: auto;
}
 
.ellipsis {
    width: 250px;
    white-space: nowrap;
    overflow: hidden;
    -ms-text-overflow: ellipsis; /* Required for IE8 */
    -o-text-overflow: ellipsis; /* Required for Opera */
    text-overflow: ellipsis;
}
</style>                
                    <style type="text/css">
.tooltip-container {
    /* Forces tooltip to be relative to the element, not the page */
    position:relative;  
    cursor:help;
}
 
.tooltip {
    display:block;
    position:absolute;
    width:150px;
    padding:5px 15px;
    left:50%;
    bottom:25px;
    margin-left:-95px;
    /* Tooltip Style */
    color:#fff;
    border:2px solid rgba(34,34,34,0.9);
    background:rgba(51,51,51,0.9);
    text-align:center;
    border-radius:3px;
    /* Tooltip Style */
    opacity:0;
    box-shadow:0px 0px 3px rgba(0, 0, 0, 0.3);
    -webkit-transition:all 0.2s ease-in-out;
    -moz-transition:all 0.2s ease-in-out;
    -0-transition:all 0.2s ease-in-out;
    -ms-transition:all 0.2s ease-in-out;
    transition:all 0.2s ease-in-out;
    -webkit-transform:scale(0);
    -moz-transform:scale(0);
    -o-transform:scale(0);
    -ms-transform:scale(0);
    transform:scale(0);
    /* Reset tooltip, to not use container styling */
    font-size:14px;
    font-weight:normal;
    font-style:normal;
}
 
.tooltip:before, .tooltip:after{
    content:"";
    position:absolute;
    bottom:-13px;
    left:50%;
    margin-left:-9px;
    width:0;
    height:0;
    border-left:10px solid transparent;
    border-right:10px solid transparent;
    border-top:10px solid rgba(0,0,0,0.1);
}
.tooltip:after{
    bottom:-12px;
    margin-left:-10px;
    border-top:10px solid rgba(34,34,34,0.9);
}
 
.tooltip-container:hover .tooltip, a:hover .tooltip {
    /* Makes the Tooltip slightly transparent, Lets the barely see though it */
    opacity:0.9;
    /* Changes the scale from 0 to 1 - This is what animtes our tooltip! */
    -webkit-transform:scale(1);
    -moz-transform:scale(1);
    -o-transform:scale(1);
    -ms-transform:scale(1);
    transform:scale(1);
}
 
/* Custom Classes */
.tooltip-style1 {
    color:#000;
    border:2px solid #fff;
    background:rgba(246,246,246,0.9);
    font-style:italic;
}
.tooltip-style1:after{
    border-top:10px solid #fff;
}
</style>
 
<i class="tooltip-container"><b>Lorem ipsum dolor sit amet</b><span class="tooltip">Hello! This is a first tooltip!</span></i>
 
<em class="tooltip-container"><b>Pellentesque id auctor sem</b><span class="tooltip tooltip-style1">This is a second tooltip!</span></em>                
                    <script language="javascript">
FormValidator = function(){
 
    // private data member (property)
    var _digits = "0123456789";
 
    // public data member (property)
    this.digits = "0123456789";
    
    // private data function (method)
    var _isEmpty = function(s){ return((s==null)||(s.length==0))};    
 
    // publick data function (method)
    this.isEmpty = function(s){ return((s==null)||(s.length==0))};        
}
 
/* create a new instance of Validator object */ 
var jsFormValidator = new FormValidator();
 
/* wrong access, errors will be produced */
alert(jsFormValidator._digits);
alert(jsFormValidator._isEmpty());
 
/* valid access */
alert(jsFormValidator.digits);
alert(jsFormValidator.isEmpty());
</script>