working on it ...

Filters

Explore Public Snippets

Sort by

Found 49k snippets matching: count

    public by fabio.nosenzo modified Feb 9, 2016  235816  6  5  -1

    Count unique values excel formula

    General formula to calculate unique values with MS Excel
    //replace the values "*****" with your data range
    
    SUM(IF(FREQUENCY(IF(LEN(*****)>0,MATCH(*****,*****,0),""), IF(LEN(*****)>0,MATCH(*****,*****,0),""))>0,1))
    
    // remember to insert formula as an array formula with ctrl+shift+enter

    public by Geometry modified Aug 6, 2016  258703  1  5  0

    SetUnmanagedMemory: Fill memory region with specified value.

    Fill memory region with specified value. Destination pointer. Filler byte's value. Memory block's length to fill. Return's value of - pointer to destination.
    /// <summary>
    /// Fill memory region with specified value.
    /// </summary>
    /// 
    /// <param name="dst">Destination pointer.</param>
    /// <param name="filler">Filler byte's value.</param>
    /// <param name="count">Memory block's length to fill.</param>
    /// 
    /// <returns>Return's value of <paramref name="dst"/> - pointer to destination.</returns>
    /// 
    public static unsafe byte* SetUnmanagedMemory(byte* dst, int filler, int count)
    {
        return memset(dst, filler, count);
    }

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

    CopyUnmanagedMemory: Copy block of unmanaged memory.

    Copy block of unmanaged memory. Destination pointer. Source pointer. Memory block's length to copy. Return's value of - pointer to destination. This function is required because of the fact that .NET does not provide any way to copy unmanaged blocks, but provides only methods to copy from unmanaged memory to managed memory and vi
    /// <summary>
    /// Copy block of unmanaged memory.
    /// </summary>
    /// 
    /// <param name="dst">Destination pointer.</param>
    /// <param name="src">Source pointer.</param>
    /// <param name="count">Memory block's length to copy.</param>
    /// 
    /// <returns>Return's value of <paramref name="dst"/> - pointer to destination.</returns>
    /// 
    /// <remarks><para>This function is required because of the fact that .NET does
    /// not provide any way to copy unmanaged blocks, but provides only methods to
    /// copy from unmanaged memory to managed memory and vise versa.</para></remarks>
    /// 
    public static unsafe byte* CopyUnmanagedMemory(byte* dst, byte* src, int count)
    {
        return memcpy(dst, src, count);
    }

    public by qxshower modified Apr 24, 2015  186465  1  5  0

    GetDownloadCount

    Get download count VS Gallery Download Count Feed
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.IO;
    using System.Reflection;
    using System.ServiceModel.Syndication;
    using System.Xml;
    using ErikEJ.SqlCeScripting;
    using Microsoft.VisualStudio.Data.Core;
    using Microsoft.VisualStudio.Data.Services;
    using Microsoft.Win32;
    using Exceptionless;
    using ErikEJ.SqlCeToolbox.Dialogs;
    using ErikEJ.SQLiteScripting;
    
    public static string GetDownloadCount()
    {
        try
        {
            XmlReader reader = XmlReader.Create("http://sqlcompact.dk/vsgallerycounter/downloadfeed.axd?extensionId=0e313dfd-be80-4afb-b5e9-6e74d369f7a1");
            SyndicationFeed feed = SyndicationFeed.Load(reader);
            foreach (var item in feed.Items)
            {
                return string.Format("- {0:0,0} downloads", double.Parse(item.Summary.Text));
            }
        }
        catch { }
        return string.Format("- more than {0:0,0} downloads", 340000d);
    }            

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

    CopyUnmanagedMemory: Copy block of unmanaged memory.

    Copy block of unmanaged memory. Destination pointer. Source pointer. Memory block's length to copy. Return's value of - pointer to destination. This function is required because of the fact that .NET does not provide any way to copy unmanaged blocks, but provides only methods to copy from unmanaged memory to managed memory and vi
    /// <summary>
    /// Copy block of unmanaged memory.
    /// </summary>
    /// 
    /// <param name="dst">Destination pointer.</param>
    /// <param name="src">Source pointer.</param>
    /// <param name="count">Memory block's length to copy.</param>
    /// 
    /// <returns>Return's value of <paramref name="dst"/> - pointer to destination.</returns>
    /// 
    /// <remarks><para>This function is required because of the fact that .NET does
    /// not provide any way to copy unmanaged blocks, but provides only methods to
    /// copy from unmanaged memory to managed memory and vise versa.</para></remarks>
    ///
    public static IntPtr CopyUnmanagedMemory(IntPtr dst, IntPtr src, int count)
    {
        unsafe
        {
            CopyUnmanagedMemory((byte*)dst.ToPointer(), (byte*)src.ToPointer(), count);
        }
        return dst;
    }

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

    SetUnmanagedMemory: Fill memory region with specified value.

    Fill memory region with specified value. Destination pointer. Filler byte's value. Memory block's length to fill. Return's value of - pointer to destination.
    /// <summary>
    /// Fill memory region with specified value.
    /// </summary>
    /// 
    /// <param name="dst">Destination pointer.</param>
    /// <param name="filler">Filler byte's value.</param>
    /// <param name="count">Memory block's length to fill.</param>
    /// 
    /// <returns>Return's value of <paramref name="dst"/> - pointer to destination.</returns>
    /// 
    public static IntPtr SetUnmanagedMemory(IntPtr dst, int filler, int count)
    {
        unsafe
        {
            SetUnmanagedMemory((byte*)dst.ToPointer(), filler, count);
        }
        return dst;
    }

    public by Peter Johnson a.k.a. insertcoffee modified Apr 29, 2015  77879  0  2  0

    Pelias category counts - OSM planet Apr 29 - 2015

    Pelias category counts - OSM planet Apr 29 - 2015: cat-counts.json
    {
      "took": 344,
      "timed_out": false,
      "_shards": {
        "total": 40,
        "successful": 40,
        "failed": 0
      },
      "hits": {
        "total": 165113284,
        "max_score": 0,
        "hits": [
          
        ]
      },
      "aggregations": {
        "popular": {
          "doc_count_error_upper_bound": 0,
          "sum_other_doc_count": 0,
          "buckets": [
            {
              "key": "retail",
              "doc_count": 2035329
            },
            {
              "key": "food",
              "doc_count": 1052789
            },
            {
              "key": "education",
              "doc_count": 1012070
            },
            {
              "key": "transport",
              "doc_count": 999489
            },
            {
              "key": "recreation",
              "doc_count": 913755
            },
            {
              "key": "nightlife",
              "doc_count": 622372
            },
            {
              "key": "transport:public",
              "doc_count": 618726
            },
            {
              "key": "professional",
              "doc_count": 532643
            },
            {
              "key": "religion",
              "doc_count": 505962
            },
            {
              "key": "government",
              "doc_count": 439336
            },
            {
              "key": "entertainment",
              "doc_count": 438220
            },
            {
              "key": "health",
              "doc_count": 359072
            },
            {
              "key": "accomodation",
              "doc_count": 294060
            },
            {
              "key": "finance",
              "doc_count": 184095
            },
            {
              "key": "transport:rail",
              "doc_count": 121378
            },
            {
              "key": "transport:station",
              "doc_count": 93877
            },
            {
              "key": "transport:air",
              "doc_count": 69042
            },
            {
              "key": "food:regional",
              "doc_count": 41614
            },
            {
              "key": "transport:air:aerodrome",
              "doc_count": 41028
            },
            {
              "key": "food:pizza",
              "doc_count": 31708
            },
            {
              "key": "food:burger",
              "doc_count": 30856
            },
            {
              "key": "food:cuisine:italian",
              "doc_count": 25551
            },
            {
              "key": "transport:bus",
              "doc_count": 21524
            },
            {
              "key": "food:cuisine:chinese",
              "doc_count": 16937
            },
            {
              "key": "food:coffee_shop",
              "doc_count": 13232
            },
            {
              "key": "food:sandwich",
              "doc_count": 11735
            },
            {
              "key": "food:cuisine:german",
              "doc_count": 10021
            },
            {
              "key": "food:cuisine:japanese",
              "doc_count": 8048
            },
            {
              "key": "food:cuisine:mexican",
              "doc_count": 7967
            },
            {
              "key": "food:cuisine:indian",
              "doc_count": 7397
            },
            {
              "key": "food:kebab",
              "doc_count": 7280
            },
            {
              "key": "food:cuisine:american",
              "doc_count": 7203
            },
            {
              "key": "transport:taxi",
              "doc_count": 7138
            },
            {
              "key": "food:cuisine:french",
              "doc_count": 6603
            },
            {
              "key": "food:chicken",
              "doc_count": 6556
            },
            {
              "key": "food:cuisine:asian",
              "doc_count": 6527
            },
            {
              "key": "food:ice_cream",
              "doc_count": 6345
            },
            {
              "key": "food:cuisine:greek",
              "doc_count": 6028
            },
            {
              "key": "transport:sea",
              "doc_count": 5795
            },
            {
              "key": "food:cuisine:thai",
              "doc_count": 4291
            },
            {
              "key": "food:cuisine:international",
              "doc_count": 4203
            },
            {
              "key": "food:sushi",
              "doc_count": 4122
            },
            {
              "key": "food:fish_and_chips",
              "doc_count": 3505
            },
            {
              "key": "food:cuisine:turkish",
              "doc_count": 2660
            },
            {
              "key": "food:steak",
              "doc_count": 2343
            },
            {
              "key": "food:seafood",
              "doc_count": 2315
            },
            {
              "key": "food:cuisine:spanish",
              "doc_count": 2177
            },
            {
              "key": "food:fish",
              "doc_count": 1414
            },
            {
              "key": "food:cuisine:vietnamese",
              "doc_count": 1400
            },
            {
              "key": "food:noodle",
              "doc_count": 1236
            },
            {
              "key": "food:vegetarian",
              "doc_count": 1164
            },
            {
              "key": "food:cuisine:korean",
              "doc_count": 796
            },
            {
              "key": "food:barbecue",
              "doc_count": 746
            },
            {
              "key": "food:donut",
              "doc_count": 740
            },
            {
              "key": "food:friture",
              "doc_count": 740
            },
            {
              "key": "food:cuisine:bavarian",
              "doc_count": 736
            },
            {
              "key": "food:mediterranean",
              "doc_count": 673
            },
            {
              "key": "food:cake",
              "doc_count": 460
            },
            {
              "key": "food:crepe",
              "doc_count": 421
            },
            {
              "key": "food:cuisine:lebanese",
              "doc_count": 362
            },
            {
              "key": "food:curry",
              "doc_count": 314
            },
            {
              "key": "food:cuisine:russian",
              "doc_count": 287
            },
            {
              "key": "food:tapas",
              "doc_count": 272
            },
            {
              "key": "food:bagel",
              "doc_count": 233
            },
            {
              "key": "food:pasta",
              "doc_count": 225
            },
            {
              "key": "food:cuisine:portuguese",
              "doc_count": 218
            },
            {
              "key": "food:sausage",
              "doc_count": 204
            },
            {
              "key": "food:pancake",
              "doc_count": 203
            },
            {
              "key": "food:cuisine:polish",
              "doc_count": 191
            },
            {
              "key": "food:cuisine:african",
              "doc_count": 190
            },
            {
              "key": "food:cuisine:croatian",
              "doc_count": 171
            },
            {
              "key": "food:cuisine:arab",
              "doc_count": 167
            },
            {
              "key": "food:cuisine:malagasy",
              "doc_count": 158
            },
            {
              "key": "food:cuisine:balkan",
              "doc_count": 154
            },
            {
              "key": "food:vegan",
              "doc_count": 153
            },
            {
              "key": "food:cuisine:brazilian",
              "doc_count": 151
            },
            {
              "key": "food:cuisine:caribbean",
              "doc_count": 146
            },
            {
              "key": "food:cuisine:argentinian",
              "doc_count": 136
            },
            {
              "key": "food:cuisine:hungarian",
              "doc_count": 132
            },
            {
              "key": "food:savory_pancakes",
              "doc_count": 108
            },
            {
              "key": "food:cuisine:peruvian",
              "doc_count": 96
            },
            {
              "key": "food:couscous",
              "doc_count": 79
            },
            {
              "key": "food:pie",
              "doc_count": 78
            },
            {
              "key": "food:sub",
              "doc_count": 78
            },
            {
              "key": "food:cuisine:czech",
              "doc_count": 77
            },
            {
              "key": "food:fried_food",
              "doc_count": 69
            },
            {
              "key": "food:cuisine:basque",
              "doc_count": 66
            },
            {
              "key": "food:cuisine:latin_american",
              "doc_count": 54
            },
            {
              "key": "food:cuisine:danish",
              "doc_count": 48
            },
            {
              "key": "food:cuisine:cantonese",
              "doc_count": 44
            },
            {
              "key": "food:cuisine:australian",
              "doc_count": 38
            },
            {
              "key": "food:dessert",
              "doc_count": 37
            },
            {
              "key": "food:empanada",
              "doc_count": 31
            },
            {
              "key": "food:cuisine:pakistani",
              "doc_count": 30
            },
            {
              "key": "food:cuisine:iranian",
              "doc_count": 29
            },
            {
              "key": "food:cuisine:gaucho",
              "doc_count": 27
            },
            {
              "key": "food:wings",
              "doc_count": 27
            },
            {
              "key": "food:cuisine:sichuan",
              "doc_count": 10
            },
            {
              "key": "food:cuisine:mineira",
              "doc_count": 8
            },
            {
              "key": "food:gyro",
              "doc_count": 8
            },
            {
              "key": "food:bougatsa",
              "doc_count": 5
            },
            {
              "key": "food:cuisine:baiana",
              "doc_count": 5
            },
            {
              "key": "food:cuisine:okinawa_ryori",
              "doc_count": 4
            },
            {
              "key": "food:cuisine:capixaba",
              "doc_count": 3
            },
            {
              "key": "food:cuisine:belarusian",
              "doc_count": 2
            },
            {
              "key": "food:cuisine:hunan",
              "doc_count": 2
            },
            {
              "key": "food:cuisine:shandong",
              "doc_count": 2
            }
          ]
        }
      }
    }
    
    

    public by zonaro modified Nov 25, 2015  340  1  6  0

    Count Rows of DataReader

    Simple function to count rows of a OleDbDataReader, returns positive integer or -1 if error
    public static int CountRows(this OleDbDataReader Reader)
           {
               int cnt = 0;try{ while (Reader.Read()) { cnt++; } return cnt; }catch (Exception) { return -1; }
           }
    

    public by snip2code modified Sep 27, 2013  730  1  4  0

    Filtered COUNT (*) in Linq

    This is a very effective method to count in-memory a given collection (Users), with an established filter (active == true). Really fast, really simple, Linq style!!
    (from user in Users where user.Active == true select user).Count();

    public by marksimon232 modified Jun 23, 2014  2096  3  6  1

    Array reference guide for Swift

    Below are the different examples on Swift Arrays.
    //1.Creating an empty array
    var empty = [];
         
    //2.Create an initialized array
    var names=["Mark","Kelly","Susan"]
    var names2:String[] = ["Mark","Kelly","Susan"] //with explicit type convention
     
    var numbers = [1,2,4,5,6,7,8]
     
    //3.Get the count of an array
    println(numbers.count)
     
     
    //4. Iterate through each element in array
    //Method 1
    for (var i=0;i<numbers.count;i++)
    {
            println(numbers[i])
    }
     
    //Method 2
    for num in numbers
    {
            println(num)
    }
     
    //Method 3
    for (index,value)  in enumerate(numbers)
    {
            println("Index \(index): value  \(value)")
    }
     
     
     
    //5.Create sub array with index range
     var subnumbers = numbers[2..4] //4,5
        subnumbers = numbers[2...4] //4,5,6
     
         
    //6.To add an element
    numbers.append(10);
     
    //7.To insert at specific index
    numbers.insert(12,atIndex: 5)
     
    //8.Remove element at index
    var removed = numbers.removeAtIndex(0)
     
    //9.Remve last element
    var removed = numbers.removeLast()
    • Public Snippets
    • Channels Snippets