working on it ...

Filters

Explore Public Snippets

Sort by

Found 19k snippets matching: sample

    public by cghersi @ Thotpot alumni modified May 4, 2013  302873  0  5  0

    Java: generate hprof during runtime

    To generate hprof may be interesting for debug purpose, most of all before an OutOfMemory occurs on production applications! This .ini option halps to create an hprof to be analyzed before the occurrence of memory errors. See http://docs.oracle.com/javase/7/docs/technotes/samples/hprof.html for further details
    java -Xrunhprof:heap=sites,depth=10,thread=y,doe=y ...other jvm options in ini file...

    public by johansonkatherine modified May 8, 2014  219392  1  6  2

    C# Code Sample to Replace Multiple Texts inside PDF File Using Cloud API

    The following code sample shows how developers can replace multiple texts in a single API call in a PDF file using Aspose.Pdf for Cloud API in their applications. Developers can use Aspose REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.
    AsposeApp.AppSID  = "77***********************************";
    AsposeApp.AppKey = "9a*******************************";
    
    //build URI
    stringstrURI = "http://api.aspose.com/v1.1/pdf/test.pdf/replaceTextList";
    
    //sign URI
    stringsignedURI = Utils.Sign(strURI);
    
    //build JSON to post
    TextReplace textReplace1 = new TextReplace();
    textReplace1.OldValue = "[!firm!]";
    textReplace1.NewValue = "Aspose";
    textReplace1.Regex = "false";
    
    //build JSON to post
    TextReplace textReplace2 = new TextReplace();
    textReplace2.OldValue = "[!client!]";
    textReplace2.NewValue = "Mark";
    textReplace2.Regex = "false";
    
    MultipleTextReplacestextReplaces = new MultipleTextReplaces();
    textReplaces.TextReplaces = new TextReplace[] { textReplace1, textReplace2 };
    stringstrJSON = JsonConvert.SerializeObject(textReplaces);
    Console.Write(strJSON);
    Utils.ProcessCommand(signedURI, "POST", strJSON);
    
    //build URI
    strURI = "http://api.aspose.com/v1.1/storage/file/test.pdf";
    
    //sign URI
    signedURI = Utils.Sign(strURI);
    
    Stream responseStream = Utils.ProcessCommand(signedURI, "GET");
    using (Stream fileStream = System.IO.File.OpenWrite(@"test.pdf"))
    {
    Utils.CopyStream(responseStream, fileStream);
    }
    responseStream.Close();
    
    //Following are required classes
    public class MultipleTextReplaces
        {
    publicTextReplace[] TextReplaces { get; set; }
        }
    public class TextReplace
        {
    publicTextReplace() { }
    
    public string OldValue { get; set; }
    public string NewValue { get; set; }
    public string Regex { get; set; }
    
        }
    

    public by RSrini modified Jun 17, 2015  237184  39  3  0

    Installing db-sample-schema in windows (https://github.com/oracle/db-sample-schemas)

    Installing db-sample-schema in windows (https://github.com/oracle/db-sample-schemas): db-sample-schemas
    https://github.com/oracle/db-sample-schemas
    
    download the zip file and extract to "D:\app\rsrini7\product\12.1.0\dbhome_1\demo\schema"
    
    here rsrini7 is my username. extract the zip file to the dir according to your installation.
    
    open command prompt as administrator
    d: enter
    cd D:\app\rsrini7\product\12.1.0\dbhome_1\demo\schema
    
    mkdir log
    
    perl -p -i.bak -e 's#__SUB__CWD__#'D:/app/rsrini7/product/12.1.0/dbhome_1/demo/schema/'#g' *.sql */*.sql */*.dat
    
    (to install perl and other unix related tools - install babun - rocking tool for windows users. i love this )
    
    edit mksample.sql and all '_main.sql' files and follow the below instructions
    
    this is required : http://www.dba-oracle.com/t_ora_65096_create_user_12c_without_c_prefix.htm
    
    1. in connect statement 
    	add at the end 'as sysdba'
    2. after the connect statement add the below line
    	alter session set "_oracle_script"=true;
    
    type in the command prompt : sqlplus enter
    connect oracle with sys as sysdba and enter
    type the dba-password 
    
    At final execute the below script from sql prompt
    	
    @?/demo/schema/mksample <dba-password> <dba-password> password password password password password password EXAMPLE TEMP D:/app/rsrini7/product/12.1.0/dbhome_1/demo/schema/log/
    
    replace <dba-password> with the actual dba password
    
    happy learning:)
    
    

    public by Geometry modified Aug 6, 2016  93142  0  5  0

    Convert: Converts a signed 16-bit integer sample into a 32-bit signed integer sample.

    Converts a signed 16-bit integer sample into a 32-bit signed integer sample. The original sample. The resulting sample.
    /// <summary>
    ///   Converts a signed 16-bit integer sample
    ///   into a 32-bit signed integer sample.
    /// </summary>
    /// 
    /// <param name="from">The original sample.</param>
    /// <param name="to">The resulting sample.</param>
    /// 
    public static void Convert(Int16 from, out Int32 to)
    {
        to = (byte)(((from) >> 8) + 128);
    }

    public by Geometry modified Aug 6, 2016  88548  0  6  0

    ToSampleFormat: Converts a <see cref="WaveFormatEncoding"/> and bits per sample information into an appropriate <see cref="SampleFormat"/>.

    Converts a and bits per sample information into an appropriate . The wave format tag. The bits per sample.
    /// <summary>
    ///   Converts a <see cref="WaveFormatEncoding"/> and bits per sample information
    ///   into an appropriate <see cref="SampleFormat"/>.
    /// </summary>
    /// 
    /// <param name="tag">The wave format tag.</param>
    /// <param name="bitsPerSample">The bits per sample.</param>
    /// 
    public static SampleFormat ToSampleFormat(this WaveFormatEncoding tag, int bitsPerSample)
    {
        if (tag == WaveFormatEncoding.Pcm)
        {
            if (bitsPerSample == 16)
                return SampleFormat.Format16Bit;
            else if (bitsPerSample == 32)
                return SampleFormat.Format32Bit;
        }
        else if (tag == WaveFormatEncoding.IeeeFloat)
        {
            if (bitsPerSample == 32)
                return SampleFormat.Format32BitIeeeFloat;
            else if (bitsPerSample == 64)
                return SampleFormat.Format64BitIeeeFloat;
        }
    
        throw new ArgumentOutOfRangeException("tag", "Unsupported format tag.");
    }

    public by Geometry modified Aug 6, 2016  47322  0  5  0

    Convert: Converts a unsigned 8-bit byte sample into a 16-bit short integer sample.

    Converts a unsigned 8-bit byte sample into a 16-bit short integer sample. The original sample. The resulting sample.
    /// <summary>
    ///   Converts a unsigned 8-bit byte sample
    ///   into a 16-bit short integer sample.
    /// </summary>
    /// 
    /// <param name="from">The original sample.</param>
    /// <param name="to">The resulting sample.</param>
    /// 
    public static void Convert(byte from, out Int16 to)
    {
        to = (Int16)((from - 128) << 8);
    }

    public by Geometry modified Aug 7, 2016  125182  0  5  0

    FromFile: Load bitmap from file.

    Load bitmap from file. File name to load bitmap from. Returns loaded bitmap. The method is provided as an alternative of method to solve the issues of locked file. The standard .NET's method locks the source file until image's object is disposed, so the file can not be deleted or overwritten. This method workarounds the issue and
    /// <summary>
    /// Load bitmap from file.
    /// </summary>
    /// 
    /// <param name="fileName">File name to load bitmap from.</param>
    /// 
    /// <returns>Returns loaded bitmap.</returns>
    /// 
    /// <remarks><para>The method is provided as an alternative of <see cref="System.Drawing.Image.FromFile(string)"/>
    /// method to solve the issues of locked file. The standard .NET's method locks the source file until
    /// image's object is disposed, so the file can not be deleted or overwritten. This method workarounds the issue and
    /// does not lock the source file.</para>
    /// 
    /// <para>Sample usage:</para>
    /// <code>
    /// Bitmap image = Accord.Imaging.Image.FromFile( "test.jpg" );
    /// </code>
    /// </remarks>
    /// 
    public static System.Drawing.Bitmap FromFile(string fileName)
    {
        Bitmap loadedImage = null;
        FileStream stream = null;
    
        try
        {
            // read image to temporary memory stream
            stream = File.OpenRead(fileName);
            MemoryStream memoryStream = new MemoryStream();
    
            byte[] buffer = new byte[10000];
            while (true)
            {
                int read = stream.Read(buffer, 0, 10000);
    
                if (read == 0)
                    break;
    
                memoryStream.Write(buffer, 0, read);
            }
    
            loadedImage = (Bitmap)Bitmap.FromStream(memoryStream);
        }
        finally
        {
            if (stream != null)
            {
                stream.Close();
                stream.Dispose();
            }
        }
    
        return loadedImage;
    }

    public by Geometry modified Aug 6, 2016  50551  0  6  0

    ToWaveFormat: Converts a sample format into an appropriate <see cref="WaveFormatEncoding"/>.

    Converts a sample format into an appropriate . The sample format.
    /// <summary>
    ///   Converts a sample format into an appropriate <see cref="WaveFormatEncoding"/>.
    /// </summary>
    /// 
    /// <param name="sampleFormat">The sample format.</param>
    /// 
    public static WaveFormatEncoding ToWaveFormat(this SampleFormat sampleFormat)
    {
        switch (sampleFormat)
        {
            case SampleFormat.Format8Bit:
            case SampleFormat.Format32Bit:
            case SampleFormat.Format16Bit:
                return WaveFormatEncoding.Pcm;
    
            case SampleFormat.Format64BitIeeeFloat:
            case SampleFormat.Format32BitIeeeFloat:
                return WaveFormatEncoding.IeeeFloat;
        }
    
        throw new ArgumentOutOfRangeException("sampleFormat", "Unsupported sample format.");
    }

    public by Geometry modified Aug 6, 2016  75862  0  5  0

    Convert: Converts a array of signed 32-bit integer samples into a array of 32-bit floating point samples.

    Converts a array of signed 32-bit integer samples into a array of 32-bit floating point samples. The original sample. The resulting sample.
    /// <summary>
    ///   Converts a array of signed 32-bit integer samples
    ///   into a array of 32-bit floating point samples.
    /// </summary>
    /// 
    /// <param name="from">The original sample.</param>
    /// <param name="to">The resulting sample.</param>
    /// 
    public static void Convert(Int32[] from, Int32[] to)
    {
        for (int i = 0; i < from.Length; i++)
            to[i] = (int)((double)from[i] * 0x7FFFFFFF);
    }

    public by Geometry modified Aug 6, 2016  63266  0  3  0

    Convert: Converts a matrix of unsigned 8-bit byte samples into a array of 16-bit short integer samples.

    Converts a matrix of unsigned 8-bit byte samples into a array of 16-bit short integer samples. The original sample. The resulting sample.
    #endregion
    
    
    #region From UInt8 (byte)
    
    #region From UInt8 (byte) to Int16 (short)
    /// <summary>
    ///   Converts a matrix of unsigned 8-bit byte samples
    ///   into a array of 16-bit short integer samples.
    /// </summary>
    /// 
    /// <param name="from">The original sample.</param>
    /// <param name="to">The resulting sample.</param>
    /// 
    public static void Convert(byte[][] from, Int16[][] to)
    {
        for (int i = 0; i < from.Length; i++)
            for (int j = 0; j < from[0].Length; j++)
                to[i][j] = (Int16)((from[i][j] - 128) << 8);
    }
    • Public Snippets
    • Channels Snippets