working on it ...


Explore Public Snippets

Sort by

Found 2,014 snippets matching: __

    public by fabio.nosenzo @ Amazon_AWS_Python_API  588235  5  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/] Learn more about S3Con
    import boto.utils
    from boto.connection import AWSAuthConnection
    class S3Connection(AWSAuthConnection):
        DefaultHost = boto.config.get('s3', 'host', '')
        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,
            if isinstance(calling_format, str):
            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,

    public by JKCPR  2314  0  5  0

    Relational Operators

    These are primarily used to compare numeric and date/time types.
    // < less than
    // <= less than or equal to
    // > greater than
    // >= greater than or equal to
    SELECT <columns> FROM <table> WHERE <column name> < <value>;
    SELECT <columns> FROM <table> WHERE <column name> <= <value>;
    SELECT <columns> FROM <table> WHERE <column name> > <value>;
    SELECT <columns> FROM <table> WHERE <column name> >= <value>;

    public by fabio.nosenzo  3190  3  6  2

    Get column letter Excel VBA

    Given the column number, this function returns the letter(s) corrisponding to the excel column. Thanks to brettdj
    Function Col_Letter(lngCol As Long) As String
    Dim vArr
    vArr = Split(Cells(1, lngCol).Address(True, False), "$")
    Col_Letter = vArr(0)
    End Function
    'test the code
    Sub Test()
    MsgBox Col_Letter(100)
    End Sub            

    public by juntalis  874  0  3  0

    Not-quite-compatible implementation of NASM's __utf16__ keyword for YASM.

    Not-quite-compatible implementation of NASM's __utf16__ keyword for YASM.: utf16_for_yasm.asm
    BITS 32
    %macro __utf16__ 1
    	%assign idx 1
    	%xdefine wstring 
    	%xdefine cstring %1
    	%strlen cstrlen cstring
    	%rep cstrlen
    		%substr cchar cstring idx
    		%if idx = 1
    			%xdefine wstring cchar, 0x0
    		%elif idx = cstrlen
    			%xdefine wstring wstring cchar, 0x0
    			%xdefine wstring wstring cchar, 0x0,
    		%assign idx idx+1
    	db wstring
    %define u(S) __utf16__ S
    	xor eax, eax
    	add eax, wsDllPath - $
    	dw 0x0

    public by Lubluborsh  361  0  4  0



    public by lbottaro  4547  2  8  5

    Functions as first class objects in Python

    Python allows the coder to treat functions as objects, also known as first class objects. Usually a first class object is an entity that can be dynamically created, destroyed, passed to a function, returned as a value, and have all the rights as other variables in the programming language have. In this case the functional programming paradigm al
    def add(a, b):
      return a + b
    def subtract(a, b):
      return a - b
    def multiply(a, b):
      return a * b
    def divide(a, b):
      if b:
        return a /b
        return "Error, divide by zero!"
    def power(a, b):
      return a ** b
    def modulus(a, b):
      return a % b
    functions = [add, subtract, multiply, divide, power, modulus]
    for function in functions:
      name = function.__name__
      result = function(4.0,5.0)
      print(name + ": " + str(result))

    public by Geometry  1338  1  5  0


    // P/Invoke declare for the FPU control helper in the C runtime // errno_t __cdecl _controlfp_s(_Out_opt_ unsigned int *_CurrentState, _In_ unsigned int _NewValue, _In_ unsigned int _Mask);
    using System;
    using System.ComponentModel;
    using System.Runtime.InteropServices;
    // P/Invoke declare for the FPU control helper in the C runtime
    // errno_t __cdecl _controlfp_s(_Out_opt_ unsigned int *_CurrentState, _In_ unsigned int _NewValue, _In_ unsigned int _Mask);
    [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl, PreserveSig = true)]
    static extern int _controlfp_s(out uint currentState, uint newValue, uint mask);

    public by imagelesskink  4819  3  5  0

    Python code error

    Hi guys, I need help to figure out how to fix errors in my Python code Assignment. Basically I need create a program that should calculate the monthly average price for Google and tell us the best and worst six-month period for Google. The average price is defined as ((v1*c1)+(v2*c2)+(v3*c3)+(v4*c4)...+(vn*cn)) / (v1+v2+v3+v4...+vn) where vi i
    # I commented out the original code that was causing the errors and put comments by my fixes.
    def get_values():
            the "csv" file is a "comma-separated file", so we can split the data on commas.
            The following function will read a file, split the lines in the file on commas,
            and put the data in to a list that is returned. The result is a list of lists
            where each line
            is a list. Also, every item is a string.
    import operator
    data_file = open("googlePrices.csv")
    def get_data_list(file_name):
        data_list = []  # always start with an open list
        for line_str in data_file:
            data_list.append(line_str.strip().split(','))  # removes all commas from the csv file
        return data_list
    averageList = [] # variables that were assigned (with an '=') in a function are local to that function.
                     # even if you assigned them in a larger scope, whenever you use the assignment operator it creates a local copy.
    def monthlyAverage(list_of_tuples=[]):
        '''Calculates monthly average
           The average price is defined as
           ((v1*c1)+(v2*c2)+(v3*c3)+(v4*c4)...+(vn*cn)) / (v1+v2+v3+v4...+vn)
           where vi is the volume for day i and ci is the adjusted close price
           for day i.
        #averageList = []
        currentYear_int = 2012
        month_int = 11
        sum_float = float()
        count = 0
        date_year_str = "" # The assignment below is skipped if list_of_tuples is empty, so it needs to be set here so it at leasts exists if you try to use it.
        for a_tuple in list_of_tuples:
            dateStr = a_tuple[0]
            Floatdata = a_tuple[1]
            listdate = dateStr.split(',')
            Year_int = int(listdate[0])
            month_int = int(listdate[1])
            date_year_str = "Date: " + str(month_int) + "-" + str(currentYear_int)
        if month_int != currentYear_int:
            float_average = sum_float / count
            list_average = [date_year_str , float_average]
            average_tuple = tuple(list_average)
            averageList.append(average_tuple) # this is fine, since methods called on objects in higher scopes operate on that object, instead of making a copy.
            current_month_int = month_int
            sum_float = 0.0
            count = 0
            sum_float += Floatdata
            count += 1
        #return averageList
    #the return was no longer needed, since averageList is a global variable
    #def best_6_month(averageList):
    def best_6_month(): # If you define a function with a parameter, it needs to be called with the same number of parameters, unless they are given default values.
        print("The 6 best months fo google are: ")
    #def worst_6_month(averageList):
    def worst_6_month():
        print("The 6 worst months for google are: ")
    optionStr = ""
    if optionStr != "0":
        print("\n Google Stock Prices. 2004 - 2012")
        print("Please choose an option")
        print("1.    Calculate Average")
        print("2.    View best six months")
        print("3.    View worst six months")
        print("0.    Exit program")
    optionStr = input("Enter you choice now: ")
    if (len(optionStr) != 1) or (optionStr not in "0123"):
        print("You have entered an invalid number!")
        print("Please try again")
    elif optionStr == "1":
    elif optionStr == "2":
    elif optionStr == "3":
    elif optionStr == "0":
        print("\n Exiting program... Goodbye.")
        print("\n Bad option")

    public by msdn  15041  0  5  0


    static DetailsClass()
    private static void __Contacts_Inserting(global::LightSwitchApplication.ApplicationDataService d, global::LightSwitchApplication.Contact e)

    public by msdn  12724  0  6  0


    static DetailsClass()
    private static bool __Pets_CanDelete(global::LightSwitchApplication.ApplicationDataService d)
        bool result = true;
        d.Pets_CanDelete(ref result);
        return result;
    • Public Snippets
    • Channels Snippets