working on it ...

Filters

Explore Public Snippets

Sort by

Found 7,014 snippets matching: initial

    public by fabio.nosenzo @ Amazon_AWS_Python_API modified Aug 1, 2013  587992  4  8  -1

    Amazon S3 Aws - S3Connection object from python boto API

    This snippet is about the S3Connection object provided by python boto package for Amazon AWS API. Here the __init__ method is listed with all its variables. The AWSAuthConnection object is initialized and it handles all the data for managing requests and response from Amazon AWS service. Path: [boto/s3/connection.py] Learn more about S3Con
    import boto.utils
    from boto.connection import AWSAuthConnection
    
    class S3Connection(AWSAuthConnection):
        DefaultHost = boto.config.get('s3', 'host', 's3.amazonaws.com')
        DefaultCallingFormat = boto.config.get('s3', 'calling_format', 'boto.s3.connection.SubdomainCallingFormat')
        QueryString = 'Signature=%s&Expires=%d&AWSAccessKeyId=%s'
    
        def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
                     is_secure=True, port=None, proxy=None, proxy_port=None,
                     proxy_user=None, proxy_pass=None,
                     host=DefaultHost, debug=0, https_connection_factory=None,
                     calling_format=DefaultCallingFormat, path='/',
                     provider='aws', bucket_class=Bucket, security_token=None,
                     suppress_consec_slashes=True, anon=False,
                     validate_certs=None):
            if isinstance(calling_format, str):
                calling_format=boto.utils.find_class(calling_format)()
            self.calling_format = calling_format
            self.bucket_class = bucket_class
            self.anon = anon
            AWSAuthConnection.__init__(self, host,
                    aws_access_key_id, aws_secret_access_key,
                    is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
                    debug=debug, https_connection_factory=https_connection_factory,
                    path=path, provider=provider, security_token=security_token,
                    suppress_consec_slashes=suppress_consec_slashes,
                    validate_certs=validate_certs)

    public by marksimon232 modified Jul 6, 2015  283209  0  7  1

    Swift 2: Custom logger that mimics NSLog

    Using this initializer, you can easily build a custom logger that mimics NSLog:
    public func SWLog(format: String, _ args: CVarArgType...) {
        let dateFormatter = NSDateFormatter()
        dateFormatter.dateFormat = 
            NSDateFormatter.dateFormatFromTemplate(
                "mm:ss:SSS", options: 0, 
                locale: NSLocale.currentLocale())
        let timeString = 
            dateFormatter.stringFromDate(NSDate())
        print("\(timeString): " + 
            String(format: format, arguments: args))
    }

    public by JPM modified Nov 14, 2017  1419  0  7  0

    initialize the beneficiaries

    public void initBeneficiary() {
    		selectedBeneficiary = new Beneficiary2SarfDTO();
    		beneficiarySummaryDTO = new BeneficiarySummaryDTO();
    		selectedBank = new Bank();
    		selectedBank = null;
    		selectedPersonType = null;
    		editDeleteButtons=true;
    	}

    public by cghersi modified May 22, 2014  2309  0  6  1

    Add initial content to each line of a given text in Java

    Adds the given textToAdd at the beginning of each line of the given text @param text text to split into lines and manage @param textToAdd text to place at the beginning of each line @return the augmented text
    public static final String LINE_SEPARATOR = System.getProperty("line.separator");
    
    public static String addTextToEachLine(String text, String textToAdd) {
        if (Utils.isNullOrEmpty(textToAdd) || Utils.isNullOrEmpty(textToAdd))
            return text;
        
        //split into lines:
        String[] lines = text.split(Utils.LINE_SEPARATOR);
        if (Utils.isNullOrEmpty(lines))
            return text;
        
        //re-compose the text:
        StringBuilder str = new StringBuilder();
        for (String line : lines) {
            str.append(textToAdd).append(line).append(Utils.LINE_SEPARATOR);
        }
        return str.toString();        
    }

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

    Create: Creates a matrix with all values set to a given value.

    Creates a matrix with all values set to a given value. The number of rows in the matrix. The number of columns in the matrix. The initial values for the matrix. A matrix of the specified size.
    /// <summary>
            ///   Creates a matrix with all values set to a given value.
            /// </summary>
            /// 
            /// <param name="rows">The number of rows in the matrix.</param>
            /// <param name="columns">The number of columns in the matrix.</param>
            /// <param name="values">The initial values for the matrix.</param>
            /// 
            /// <returns>A matrix of the specified size.</returns>
            /// 
    #if NET45
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
    #endif
            public static T[][] Create<T>(int rows, int columns, params T[] values)
            {
                if (values.Length == 0)
                    return Zeros<T>(rows, columns);
                return values.Reshape(rows, columns).ToJagged();
            }

    public by Geometry modified Jul 28, 2016  39322  0  4  0

    Allows to InitializeGenerators

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Linq;
    using System.Reflection;
    
    [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "These are simple type factories and cannot be split up.")]
    private static Dictionary<Type, Func<long, object>> InitializeGenerators()
    {
        return new Dictionary<Type, Func<long, object>>
        {
            { typeof(Boolean), index => true },
            { typeof(Byte), index => (Byte)64 },
            { typeof(Char), index => (Char)65 },
            { typeof(DateTime), index => DateTime.Now },
            { typeof(DateTimeOffset), index => new DateTimeOffset(DateTime.Now) },
            { typeof(DBNull), index => DBNull.Value },
            { typeof(Decimal), index => (Decimal)index },
            { typeof(Double), index => (Double)(index + 0.1) },
            { typeof(Guid), index => Guid.NewGuid() },
            { typeof(Int16), index => (Int16)(index % Int16.MaxValue) },
            { typeof(Int32), index => (Int32)(index % Int32.MaxValue) },
            { typeof(Int64), index => (Int64)index },
            { typeof(Object), index => new object() },
            { typeof(SByte), index => (SByte)64 },
            { typeof(Single), index => (Single)(index + 0.1) },
            { 
                typeof(String), index =>
                {
                    return String.Format(CultureInfo.CurrentCulture, "sample string {0}", index);
                }
            },
            { 
                typeof(TimeSpan), index =>
                {
                    return TimeSpan.FromTicks(1234567);
                }
            },
            { typeof(UInt16), index => (UInt16)(index % UInt16.MaxValue) },
            { typeof(UInt32), index => (UInt32)(index % UInt32.MaxValue) },
            { typeof(UInt64), index => (UInt64)index },
            { 
                typeof(Uri), index =>
                {
                    return new Uri(String.Format(CultureInfo.CurrentCulture, "http://webapihelppage{0}.com", index));
                }
            },
        };
    }

    public by lbottaro modified Jan 14, 2013  2043  3  6  2

    Array initialization in C

    This example program illustrates array initialization in C. Thanks to: http://www.lemoda.net/c/array-initialization/index.html
    #include <stdio.h>
    
    #define ARRAY_SIZE 10
    
    int main ()
    {
        int i;
        /* Initialize all the elements. */
        int array_all[ARRAY_SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        /* If only the first elements are initialized, the remaining
           elements are all set to zero. */
        int array_first_two[ARRAY_SIZE] = { 1, 2 };
        /* So, if the first element is set to zero, then everything else
           is, too. */
        int array_zero[ARRAY_SIZE] = { 0 };
        /* But if nothing is initialized, the whole array contains random
           junk. */
        int array_not_static[ARRAY_SIZE];
        /* Unless the array is declared using "static", in which case it
           is zeroed. */
        static int array_static[ARRAY_SIZE];
    
        /* This prints out the contents of the arrays. */
        for (i = 0; i < ARRAY_SIZE; i++) {
            printf ("%2d: %2d %d %d %12d %d\n",
                    i,
                    array_all[i],
                    array_first_two[i],
                    array_zero[i],
                    array_not_static[i],
                    array_static[i]
                    );
        }
    
        return 0;
    }

    public by Geometry modified Aug 7, 2016  2120  16  5  0

    CreateGrayscaleImage: Create and initialize new grayscale image.

    Create and initialize new grayscale image. Image width. Image height. Returns new created grayscale image. Accord.Imaging.Image.CreateGrayscaleImage() function could be used instead, which does the some. But it was not used to get rid of dependency on AForge.Imaing library.
    /// <summary>
    /// Create and initialize new grayscale image.
    /// </summary>
    /// 
    /// <param name="width">Image width.</param>
    /// <param name="height">Image height.</param>
    /// 
    /// <returns>Returns new created grayscale image.</returns>
    /// 
    /// <remarks><para>Accord.Imaging.Image.CreateGrayscaleImage() function
    /// could be used instead, which does the some. But it was not used to get
    /// rid of dependency on AForge.Imaing library.</para></remarks>
    /// 
    public static Bitmap CreateGrayscaleImage( int width, int height )
    {
        // create new image
        Bitmap image = new Bitmap( width, height, PixelFormat.Format8bppIndexed );
        // get palette
        ColorPalette cp = image.Palette;
        // init palette with grayscale colors
        for ( int i = 0; i < 256; i++ )
        {
            cp.Entries[i] = Color.FromArgb( i, i, i );
        }
        // set palette back
        image.Palette = cp;
        // return new image
        return image;
    }

    public by cghersi modified Oct 27, 2013  3223  1  6  0

    Initialize FastJson utility

    Basic settings to initialize an instance of FastJson to serialize C# objects in JSON
    public static fastJSON.JSON InitJSONUtils()
    {
        fastJSON.JSON res = fastJSON.JSON.Instance;
        res.SerializeNullValues = true;
        res.ShowReadOnlyProperties = true;
        res.UseUTCDateTime = true;
        res.IndentOutput = false;
        res.UsingGlobalTypes = true;
        res.UseSerializerExtension = false;
        return res;
    }
    

    public by Geometry modified Jul 28, 2016  1538  2  4  0

    GetHelpPageApiModel: Gets the model that represents an API displayed on the help page. The model is initialized on the first call and cached for subsequent calls.

    Gets the model that represents an API displayed on the help page. The model is initialized on the first call and cached for subsequent calls. The . The ID. An
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Linq;
    using System.Net.Http;
    using System.Net.Http.Headers;
    using System.Web.Http;
    using System.Web.Http.Controllers;
    using System.Web.Http.Description;
    using PowerBIRestDemo.Areas.HelpPage.ModelDescriptions;
    using PowerBIRestDemo.Areas.HelpPage.Models;
    
    private const string ApiModelPrefix = "MS_HelpPageApiModel_";
    
    /// <summary>
    /// Gets the model that represents an API displayed on the help page. The model is initialized on the first call and cached for subsequent calls.
    /// </summary>
    /// <param name="config">The <see cref="HttpConfiguration"/>.</param>
    /// <param name="apiDescriptionId">The <see cref="ApiDescription"/> ID.</param>
    /// <returns>
    /// An <see cref="HelpPageApiModel"/>
    /// </returns>
    public static HelpPageApiModel GetHelpPageApiModel(this HttpConfiguration config, string apiDescriptionId)
    {
        object model;
        string modelId = ApiModelPrefix + apiDescriptionId;
        if (!config.Properties.TryGetValue(modelId, out model))
        {
            Collection<ApiDescription> apiDescriptions = config.Services.GetApiExplorer().ApiDescriptions;
            ApiDescription apiDescription = apiDescriptions.FirstOrDefault(api => String.Equals(api.GetFriendlyId(), apiDescriptionId, StringComparison.OrdinalIgnoreCase));
            if (apiDescription != null)
            {
                model = GenerateApiModel(apiDescription, config);
                config.Properties.TryAdd(modelId, model);
            }
        }
    
        return (HelpPageApiModel)model;
    }
    • Public Snippets
    • Channels Snippets