working on it ...

Filters

Explore Public Snippets

Sort by

Found 4,272 snippets matching: header

    public by lbottaro  429419  14  7  3

    HTML header - footer layout using CSS and DIV

    This code renders a HTML basic layout with header, main and footer contents. The main content has 2 columns and the right one contains two rows. Source: http://stackoverflow.com/questions/6778808
    <html>
        <head>
        <style type="text/css">
        #maincontent {
            width:950px;
            height:100%;
            margin:0 auto;
        }
        #header {
            width:946px;
            height:150px;
            border:#000 solid;
            border-width:2px 2px 1px 2px;
        }
        #leftcolumn {
            width:395px;
            height:703px;
            border:#000 solid;
            border-width:1px 1px 1px 2px;
            float:left;
        }
        #toprow {
            width:549px;
            height:351px;
            border:#000 solid;
            border-width:1px 2px 1px 1px;
            float:left;
        }
        #bottomrow {
            width:549px;
            height:350px;
            border:#000 solid;
            border-width:1px 2px 1px 1px;
            float:left;
        }
        #footer {
            width:946px;
            height:150px;
            border:#000 solid;
            border-width:1px 2px 2px 2px;
            clear:both;
        }
        </style>
        <body>
        <div id="maincontent">
            <div id="header">Header Content</div>
            <div id="leftcolumn">Leftcolumn Content</div>
            <div id="toprow">Toprow Content</div>
            <div id="bottomrow">Bottomrow Content</div>
            <div id="footer">Footer Content</div>
        </div>
        </body>
        </html>

    public by Geometry  78410  0  4  0

    SerializeHeader: Block headers are sent in a headers packet in response to a getheaders message.

    Block headers are sent in a headers packet in response to a getheaders message. https://en.bitcoin.it/wiki/Protocol_specification#Block_Headers nodejs: https://github.com/zone117x/node-stratum-pool/blob/master/lib/blockTemplate.js#L85
    using System;
    using System.IO;
    using System.Text;
    using CoiniumServ.Jobs;
    using CoiniumServ.Utils.Extensions;
    using CoiniumServ.Utils.Helpers;
    using Gibbed.IO;
    
    /// <summary>
    /// Block headers are sent in a headers packet in response to a getheaders message.
    /// </summary>
    /// <remarks>
    /// https://en.bitcoin.it/wiki/Protocol_specification#Block_Headers
    /// </remarks>
    /// <example>
    /// nodejs: https://github.com/zone117x/node-stratum-pool/blob/master/lib/blockTemplate.js#L85
    /// </example>
    /// <param name="job"></param>
    /// <param name="merkleRoot"></param>
    /// <param name="nTime"></param>
    /// <param name="nonce"></param>
    /// <returns></returns>
    public static byte[] SerializeHeader(IJob job, byte[] merkleRoot, UInt32 nTime, UInt32 nonce)
    {
        byte[] result;
    
        using (var stream = new MemoryStream())
        {
            stream.WriteValueU32(nonce.BigEndian());
            stream.WriteValueU32(Convert.ToUInt32(job.EncodedDifficulty, 16).BigEndian());
            stream.WriteValueU32(nTime.BigEndian());
            stream.WriteBytes(merkleRoot);
            stream.WriteBytes(job.PreviousBlockHash.HexToByteArray());
            stream.WriteValueU32(job.BlockTemplate.Version.BigEndian());
    
            result = stream.ToArray();
            result = result.ReverseBytes();
        }
    
        return result;
    }

    public by Geometry  859  0  4  0

    Read and process FITS header. After the header is read stream pointer will point to data or extension.

    Read and process FITS header. After the header is read stream pointer will point to data or extension.
    // Read and process FITS header. After the header is read stream pointer will
    // point to data or extension.
    private static FITSImageInfo ReadHeader(Stream stream)
    {
        byte[] headerRecord = new byte[80];
        int recordsRead = 1;
        bool endKeyWasFound = false;
    
        FITSImageInfo imageInfo = new FITSImageInfo();
    
        // read first record and check for correct image
        if (
            (Tools.ReadStream(stream, headerRecord, 0, 80) < 80) ||
            (Encoding.UTF8.GetString(headerRecord, 0, 8) != "SIMPLE  "))
        {
            throw new FormatException("The stream does not contatin FITS image.");
        }
        else
        {
            // check if the image has standard FITS format
            if (Encoding.UTF8.GetString(headerRecord, 10, 70).Split('/')[0].Trim() != "T")
            {
                throw new NotSupportedException("The stream contains not standard FITS data file.");
            }
        }
    
        // read header and locate data block
        while (true)
        {
            // read next record
            if (Tools.ReadStream(stream, headerRecord, 0, 80) < 80)
            {
                throw new ArgumentException("The stream does not contain valid FITS image.");
            }
            recordsRead++;
    
            // get keyword
            string keyword = Encoding.UTF8.GetString(headerRecord, 0, 8);
    
            // skip commenct and history
            if ((keyword == "COMMENT ") || (keyword == "HISTORY "))
                continue;
    
            // check if it is end of header keyword
            if (keyword == "END     ")
                endKeyWasFound = true;
    
            if (endKeyWasFound)
            {
                if (recordsRead % 36 == 0)
                {
                    // found data or extension header
    
                    // make a small check of some header values
                    if ((imageInfo.BitsPerPixel == 0) || (imageInfo.Width == 0) || (imageInfo.Height == 0))
                    {
                        imageInfo.TotalFrames = 0;
                    }
    
                    // let's return here and let other routines process data
                    break;
                }
            }
            else
            {
                // get string representation of value/comments
                string strValue = Encoding.UTF8.GetString(headerRecord, 10, 70);
    
                // check important keywords
                if (keyword == "BITPIX  ")
                {
                    int value = ExtractIntegerValue(strValue);
    
                    if ((value != 8) && (value != 16) && (value != 32) && (value != -32) && (value != -64))
                    {
                        throw new NotSupportedException("Data format (" + value + ") is not supported.");
                    }
    
                    // bits per pixel
                    imageInfo.BitsPerPixel = (value == 8) ? 8 : 16;
                    imageInfo.OriginalBitsPerPixl = value;
                }
                else if (Encoding.UTF8.GetString(headerRecord, 0, 5) == "NAXIS")
                {
                    // information about data axis
                    int value = ExtractIntegerValue(strValue);
    
                    // check axis
                    switch (headerRecord[5])
                    {
                        // number of axis
                        case (byte)' ':
                            switch (value)
                            {
                                case 1:
                                default:
                                    throw new NotSupportedException("FITS files with data dimension of " + value + " are not supported.");
                                case 0:
                                    // the stream does not have an image, do nothing
                                    break;
                                case 2:
                                    // the stream has 1 2D image
                                    imageInfo.TotalFrames = 1;
                                    break;
                                case 3:
                                    // the stream has 3D image - series of 2D images
                                    break;
                            }
                            break;
                        // length of 1st axis
                        case (byte)'1':
                            imageInfo.Width = value;
                            break;
                        // length of 2nd axis
                        case (byte)'2':
                            imageInfo.Height = value;
                            break;
                        // length of 3rd axis
                        case (byte)'3':
                            imageInfo.TotalFrames = value;
                            break;
                    }
                }
                else if (keyword == "TELESCOP")
                {
                    imageInfo.Telescope = ExtractStringValue(strValue);
                }
                else if (keyword == "OBJECT  ")
                {
                    imageInfo.Object = ExtractStringValue(strValue);
                }
                else if (keyword == "OBSERVER")
                {
                    imageInfo.Observer = ExtractStringValue(strValue);
                }
                else if (keyword == "INSTRUME")
                {
                    imageInfo.Instrument = ExtractStringValue(strValue);
                }
    
                // --- for debugging ---
                /* if ( keyword[0] != ' ' )
                {
                    System.Diagnostics.Debug.Write( keyword );
                    if ( headerRecord[8] == '=' )
                    {
                        System.Diagnostics.Debug.WriteLine( " = " + strValue );
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine( "" );
                    }
                } */
                // --- ---
            }
        }
    
        // scan all available data to find minimum and maximum values,
        // which will be used for scaling. the scan is done here (not while
        // reading actual frame) because FITS file may have set of images
        // packed into data cube, so entire scan of all the data is required.
    
        // if is stream is seekable
        if (!stream.CanSeek)
        {
            throw new ArgumentException("The stream must be seekable.");
        }
    
        // remember current position
        long dataPos = stream.Seek(0, SeekOrigin.Current);
    
        // data size
        int lineLength = imageInfo.Width * (Math.Abs(imageInfo.OriginalBitsPerPixl) / 8);
        int totalLines = imageInfo.Height * imageInfo.TotalFrames;
        int originalBitsPerPixel = imageInfo.OriginalBitsPerPixl;
    
        byte[] buffer = new byte[lineLength];
        byte[] temp = new byte[8];
    
        // min and max values
        double min = double.MaxValue;
        double max = double.MinValue;
    
        for (int i = 0; i < totalLines; i++)
        {
            // read next line
            if (Tools.ReadStream(stream, buffer, 0, lineLength) < lineLength)
                throw new ArgumentException("The stream does not contain valid FITS image.");
    
            // scan the line
            for (int j = 0; j < lineLength; )
            {
                double value = 0;
    
                // read values accordint to their format
                switch (originalBitsPerPixel)
                {
                    case 8:    // 8 bit unsigned integer
                        value = buffer[j++];
                        break;
                    case 16:    // 16 bit signed integer
                        {
                            short tempValue = 0;
                            unchecked
                            {
                                tempValue = (short)((buffer[j++] << 8) | buffer[j++]);
                            }
                            value = tempValue;
                            break;
                        }
                    case 32:    // 32 bit signed integer
                        {
                            temp[3] = buffer[j++];
                            temp[2] = buffer[j++];
                            temp[1] = buffer[j++];
                            temp[0] = buffer[j++];
    
                            value = BitConverter.ToInt32(temp, 0);
    
                            break;
                        }
                    case -32:   // 32 bit float
                        {
                            temp[3] = buffer[j++];
                            temp[2] = buffer[j++];
                            temp[1] = buffer[j++];
                            temp[0] = buffer[j++];
    
                            value = BitConverter.ToSingle(temp, 0);
                            break;
                        }
                    case -64:   // 64 bit double
                        {
                            temp[7] = buffer[j++];
                            temp[6] = buffer[j++];
                            temp[5] = buffer[j++];
                            temp[4] = buffer[j++];
                            temp[3] = buffer[j++];
                            temp[2] = buffer[j++];
                            temp[1] = buffer[j++];
                            temp[0] = buffer[j++];
    
                            value = BitConverter.ToDouble(temp, 0);
                            break;
                        }
                }
    
                if (value > max)
                    max = value;
                if (value < min)
                    min = value;
            }
        }
    
        imageInfo.MaxDataValue = max;
        imageInfo.MinDataValue = min;
    
        // restore stream position to the begining of data
        stream.Seek(dataPos, SeekOrigin.Begin);
    
        return imageInfo;
    }

    public by JonahM  4849  11  6  2

    Full width header Image

    A great method for designing a full width responsive header image. Using Twitter Bootstrap also. Site: http://j.mp/1oilINn
    <div class="container-fluid" id="fit" style="background: url(header.png) no-repeat center center fixed;
    			-webkit-background-size: cover;
    			-moz-background-size: cover;
    			-o-background-size: cover;
    			background-size: cover;">
    		
    		<h1 class="container header strip-md" style="text-align:center; color:white;">
    				Header Title
    		</h1>
    		
    </div>

    public by manolenso  3144  0  4  0

    Script bash pour reinstaller ma config ecran apres un update linux header

    Script bash pour reinstaller ma config ecran apres un update linux header: screen-update.sh
    #!/bin/bash
    
    sudo apt-get update
    sudo apt-get install build-essential linux-headers-$(uname -r)
    sudo apt-get install virtualbox-ose-guest-x11
    
    ##### pour connaitre la configuration a ecrire $  cvt 1920 1080  ####
    ####  pour remettre en 16/9 specifique (à ma config) ####
    
    xrandr --newmode "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
    
    ##### pour recrire le fichier de config ######
    
    xrandr --addmode VBOX0 1920x1080_60.00
    
    
    
    

    public by chilly_bang  2482  1  6  2

    PHP 301 redirect non-HTTPS requests to https://

    Redirects based on port and protocol
    <?php
    if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
    if(!headers_sent()) {
    header("Status: 301 Moved Permanently");
    header(sprintf(
    'Location: https://%s%s',
    $_SERVER['HTTP_HOST'],
    $_SERVER['REQUEST_URI']
    ));
    exit();
    }
    }
    ?>
    
    <?php
    if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == ""){
    $redirect = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    header("HTTP/1.1 301 Moved Permanently")
    header("Location: $redirect");
    }
    ?>
    
    <?php
    if ($_SERVER["SERVER_PORT"] != 443) {
    $redir = "Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    header($redir);
    header("HTTP/1.1 301 Moved Permanently");
    exit();
    }
    ?>
    

    public by manolenso  2088  0  4  0

    compass header

    compass header: index.html
    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <link href="stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />
      <link href="stylesheets/print.css" media="print" rel="stylesheet" type="text/css" />
      <!--[if IE]>
        <link href="stylesheets/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
      <![endif]-->
      <title>Compass Header</title>
    </head>
    <body>
    
    </body>
    </html>
    
    
    

    public by markymark87  1589  1  6  0

    Add Auth Header to HTTP Request

    Add Auth Header to HTTP Request
    public static void addAuthHeader(HttpURLConnection http, String uid, String pwd) {
    	String hdr = uid + ":" + pwd;
    	String encode = base64Encode(hdr);
    	http.addRequestProperty("Authorization", "Basic " + encode);
    }            

    public by ImedB  1616  0  4  0

    Add asterisk to header of columns

    Add asterisk for header of grid using XPATH
    var columnHeaders:XMLList=lastRecievedXML.grid.metadata.columns;
    
    columnHeaders.column.(@dataelement == "col_name" ).@heading = columnHeaders.column.(@dataelement == "col_name").@heading +"*";

    public by shadowchamber  432  2  4  0

    class header summary

    Creates class header empty documentation to prevent BP warnings
    /// <summary>
    ///     
    /// </summary>
    • Public Snippets
    • Channels Snippets