working on it ...

Filters

snippets
40
followers
7
Published by marksimon232

Cool stuff by marksimon232

This channel collects the brain compositions of this guy
Sort by

Found 35 snippets

    public by marksimon232 modified Jan 24, 2015  2257  1  5  2

    SQL SERVER 2012

    Am migrating sql server 2005 to sql server 2012 . what are all the changes need to be done in stored procedures/ discontinued features in 2012?.Thanks in advance.
    The simplest solution I see is just do follows;
    
    In General guide for upgrading the database.
    
        1) Run upgrade advisor on the databases for the instance you want to upgrade.
        2) If any issues found, talk to your dev team/ Vendor for fixing the same.
        3) If issues fixed proceed with the actual upgrade. -- Do check for the other dependencies on the database which might effect the functionality if the instance gets upgraded or something like that.
        4) Get the downtime for the database.
        5) create a latest full backup of the database -- any other strategy will also work, just make sure you can recover the database.
        6) take a clone of the server if its a virtual server to roll back any changes.
        7) run the upgrade on the sql 2005 instance from the 2012 set up. -- do check the pre-requirements for upgrade to sql 2012.
        8) If everything fine then you have a upgraded instance.
        9) also check the compatibility of the databases.
        10)if all fine then congrats you have upgraded your sql server instance.
    
    When you migrating to SQL 2012, this points needs to be consider first.
    
    - Using the SQL 2012 Upgrade Advisor
    - Reviewing the “breaking changes” section in the Books Online
    - Reviewing the “behavioral changes” section in the Books Online
    - Executing DBCC CHECKDB WITH DATA_PURITY (DBCC CHECKDB WITH DATA_PURITY;)
    - Executing DBCC UPDATEUSAGE command (DBCC UPDATEUSAGE(db_name);)
    - Updating statistics (USE db_name; GO EXEC sp_updatestats;) with full scan (USE db_name; GO EXEC sp_MSforeachtable @command1='UPDATE STATISTICS ? WITH FULLSCAN';)
    - Refreshing your views using sp_refreshview
    - Taking backups
    - Upgrading your hardware (As SQL Server 2012 does not support AWE)
    
    Upgrades are a necessary part of any development lifecycle. The chances of having a successful upgrade increases along with the amount of planning and preparation you invest in building a proper upgrade process.
    

    public by marksimon232 modified Dec 19, 2014  2395  0  5  0

    meta tag code snippet

    How can find my window meta tag code snippet
    In the window you can find the meta tag code snippet that our system will look for in order to verify your site. All you have to do is copy and paste this snippet into the head section of the index file at the URL you're verifying.
    
    To verify that you are the owner of the ad space, we have implemented a site verification mechanism.
    Verifying your site is possible once you have successfully added an ad space to the Ad Spaces tab on your publisher profile. In the top right hand corner of each listed ad space you will find the icon. If you click this, you open the verification window.
    
    From here you have a 'Primary' and an 'Alternative' method of verification:
    
    1. Verify By Meta Tag - Primary Method (WHICH I GUESS YOUR SOLUTION right?)
    In the window you can find the meta tag code snippet that our system will look for in order to verify your site. All you have to do is copy and paste this snippet into the head section of the index file at the URL you're verifying.
    
    2. Verify by HTML file - Alternative Method
    The second method simply requires you to create a html page with the file name provided for you in the verification window. This file needs to be added to the root directory of your website.
    
    NOTE: 
    This method is only suitable for publishers who have access to the root directory of their site. It will not work with subdirectories or sub-domains.
    Once you have done this, click the "Verify Site" button and your site will be verified.
    
    I hope you have found your answer, I elaborate both the methods for other can also get idea how to use this.. :)

    public by marksimon232 modified Dec 19, 2014  2414  1  5  3

    solution needed

    What will be the output of the following snippet of code? public class Test { public static void main(String[] args) { TreeMap map = new TreeMap(); map.put(1, "one"); map.put(2, "two"); map.put(3, "three"); map.put(4, "four"); System.out.print(map.higherKey(2)); System.out.print(map.ceilingKey(2)); System.out.print(map.floorKey(1));
    Please include headers, import java.util.TreeMap;
    
    //Returns: 321null
    
    Explaination;
    1) higherKey: returns the least key strictly greater than the given key, or null if there is no such key.
    2) ceilingKey: returns the least key greater than or equal to the given key, or null if there is no such key.
    3) floorKey: returns the greatest key less than or equal to the given key, or null if there is no such key.
    4) lowerKey: returns the greatest key strictly less than the given key, or null if there is no such key.

    public by marksimon232 modified Oct 21, 2014  2209  0  7  2

    Swift Collections: Classes vs. Structs - where to use which?

    A small distinction in behavior drives the architectural possibilities at play here: structs are value types and classes are reference types.
    Why you should consider using Structs instead of Classes when writing Swift?
    
    Instances of value types are copied whenever they’re assigned or used as a 
    function argument. Numbers, strings, arrays, dictionaries, enums, tuples, and 
    structs are value types. For example:
    
    var a = "Hello"
    var b = a
    b.extend(", world")
    println("a: \(a); b: \(b)") // a: Hello; b: Hello, world
    
    Instances of reference types (chiefly: classes, functions) can have multiple 
    owners. When assigning a reference to a new variable or passing it to a 
    function, those locations all point to the same instance. This is the behavior
    you’re used to with objects. For instance:
    
    var a = UIView()
    var b = a
    b.alpha = 0.5
    println("a: \(a.alpha); b: \(b.alpha)") // a: 0.5; b: 0.5
    
    The distinction between these two categories seems small, but the choice 
    between values and references can have huge ramifications for your system’s
    architecture.
    
    

    public by marksimon232 modified Oct 21, 2014  5871  1  7  0

    Swift Collections: Convert String to float in Apple's Swift?

    If you're trying to convert numbers taken from a UITextField, which I presume are actually strings, and convert them to a float, so I can multiply them.
    I believe the current best way to achieve this is to use:
    
    var WageConversion = Wage.text.bridgeToObjectiveC().floatValue
    This is a good implementation since it can handle actual floats (input with .) and will also help prevent the user from copying text into your input field (12p.34, or even 12.12.41).
    
    Also, variables and constants should start with a lower case (including IBOutlets)

    public by marksimon232 modified Aug 12, 2014  3330  2  6  0

    Swift Collections: Swift Array reference Snippets

    Swift makes creating and modifying arrays really easy. When you create your array, you don’t have to initialize it with a certain type, if all of your given values are the same type.
    Example: If you create an array and all of the initial values are Strings, Swift automatically infers that the array will be a string array.
      
    => Creating a mutable array:
    Notice that the beginning of the line begins with var, which means variable and allows the contents of the array to be changed in the future.
    var cityArray = ["Portland","San Francisco","Cupertino"]
    
    
    => Creating an immutable array:
    Notice that the beginning of the line begins with let, which means constant and means the contents can not be changed in the future.
    let cityArray = ["Portland","San Francisco","Cupertino"]
    
    
    => Creating an empty array:
    If you need to create an empty array, you must initialize it with the type of object that will be added later.
    var animalArray = String[]()
    //This array will only allow strings.
     
    var animalAgeArray = Int[]()
    //This array will only hold integers, nothing else.
    
    
    => Creating an array to hold a specific type:
    This variable array will only hold string objects, nothing else.
    var cityArray: String[] = ["Portland","San Francisco","Cupertino"]
    
    This variable array will only hold integers, nothing else.
    var numberArray:Int[] = [1,3,4]
    
    
    => Counting number of items inside an array:
    Use the read-only count property to count the number of items in an array.
    var cityArray: String[] = ["Portland","San Francisco","Cupertino"]
    let count = cityArray.count
    //count = 3
    
    
    => Check if array is empty:
    Use the Boolean isEmpty as a quick way to determine if an array is empty.
    var cityArray: String[] = ["Portland","San Francisco","Cupertino"]
    
    if cityArray.isEmpty {
        println("Empty") 
    }else{
        println("Not Empty")
    }
    //prints "Not Empty"
    
    
    => Add an item to the end of an array:
    var cityArray: String[] = ["Portland","San Francisco","Cupertino"]
    cityArray.append("Seattle")
    //The array now contains 4 items
    
    Alternately, you can use the addition assignment operator (+=) to quickly add an item.
    cityArray += "Seattle"
    
    
    => Add an array of items to an existing array:
    Use the addition assignment operator (+=) to quickly add an array of items.
    
    var cityArray: String[] = ["Portland","San Francisco","Cupertino","Seattle"]
    cityArray += ["Vancouver", "Los Angeles", "Eugene"]
    //The array now contains 7 items
    
    
    Alternately, if you have already created an array:
    
    var cityArrayA: String[] = ["Portland","San Francisco","Cupertino","Seattle"]
    var cityArrayB: String[] = ["Vancouver", "Los Angeles", "Eugene"]
    cityArrayA += cityArrayB;
    
    //cityArrayA now contains 7 items.
    
    
    => Change a value inside an array:
    Pass the index of the value you wish to change, along with the new value.
    
    var cityArray: String[] = ["Portland","San Francisco","Cupertino","Seattle"]
    cityArray[0] = "Portland, Oregon"
    //cityArray is now ["Portland, Oregon", "San Francisco", "Cupertino", "Seattle"]
    
    
    => Changing multiple values inside an array:
    Swift makes it easy to change multiple values inside an array at once. Using the subscript syntax, you provide the index of the items you wish to modify as well as the new additions.
    
    var cityArray = ["Portland, Oregon","San Francisco","Cupertino","Seattle"]
    cityArray[1...3] = ["San Francisco, California","Cupertino, California","Seattle, Washington"]
    
    //We replaced the values at indexes 1,2 & 3 and now cityArray contains:
     ["San Francisco, California", "Cupertino, California", "Seattle, Washington"]
    
    
    Note: The amount of replacement items does not have to equal the length of the items you are replacing
    Example:
    
    var cityArray: String[] = ["Portland, Oregon","San Francisco","Cupertino","Seattle"]
    cityArray[1...3] = ["San Francisco, California","Cupertino, California"]
    //cityArray contains: ["Portland, Oregon", "San Francisco, California", "Cupertino, California"]
    Even though we tell the cityArray to replace indexes 1 through 3, we only give 2 values back to the array.
    
    
    
    => Removing a value from a specific index:
    var animalArray: String[] = ["Dog", "Cat", "Fish", "Owl", "Beaver"]
    animalArray.removeAtIndex(4)
    //animalArray now contains: ["Dog", "Cat", "Fish", "Owl"]
    
    
    Alternately, if you wish to save the value before you remove it:
    let stringAnimal = animalArray.removeAtIndex(4)
    //Saves "Beaver" to the string constant stringAnimal and also removes it from the array.
    
    
    => Removing the last value of an array:
    To avoid having to call count on an array, Swift allows developers to simply call removeLast to remove the last item in an array.
    
    var animalArray: String[] = ["Dog", "Cat", "Fish", "Owl" ]
    animalArray.removeLast
    //animalArray now contains 3 items, "Owl" has been removed.
    
    
    Again, if you wish to save the value before you remove it:
    
    let stringAnimal = animalArray.removeLast
    //Saves "Owl" (which was the last item in the array) to the string constant stringAnimal and also removes it from the array.
    
    
    => Removing all items:
    To remove all items from an array, use the removeAll method.
    
    var animalArray: String[] = ["Dog", "Cat", "Fish", "Owl" ]
    animalArray.removeAll()
    //animalArray is now empty.
    
    
    => Keeping the capacity of the array:
    animalArray.removeAll(keepCapacity: true)
    //animalArray is now empty but the capacity is kept at 4.
    
    
    => Iterating over an array:
    Simple for in Loop
    
    for animal in animalArray {
    
        println(animal)
    
    }
    //Prints each animal name into the console.
    
    
    for in Loop + Enumeration
    If you want to have the index of the item as well, you must use the enumerate function with your loop. The enumerate function returns a Tuple for each value in the array.
    
    for(index,animal) in enumerate(animalArray) {
    
        println("The \(animal) is at index:\(index")
    }
    
    //Output: 
    //The Dog is at index:0
    //The Cat is at index:1
    //The Fish is at index:2
    //The Owl is at index:3
    
    
    => Reversing the values in an array:
    var animalArray: String[] = ["Dog", "Cat", "Fish", "Owl" ]
    animalArray.reverse()
    
    //The array values are now ["Owl", "Fish", "Cat", "Dog"]
    
    
    => Create a new array from the reversed values:
    var animalArray: String[] = ["Dog", "Cat", "Fish", "Owl" ]
    let newArray = animalArray.reverse()
    //The newly created array contains ["Owl", "Fish", "Cat", "Dog"]

    public by marksimon232 modified Aug 12, 2014  4529  7  6  2

    Swift Collections: Function with multiple return values

    I want my function to get the current time and the date formatted as Strings.
    => Objective-C:
    Objective-C doesn’t support a function returning multiple values. The closest you can get would be to create your values add them to a NSDictionary and return the dictionary. 
    
    
    => Swift:
    In Swift, we include the return arrow “->” which specifies that the function will return and a tuple with the types we wish to be returned. A tuple type is simply a comma-separated list of zero or more types, enclosed in parentheses.
        func getCurrentDateAndTime() -> (date: String, time: String) {
            
            let date = NSDate() //Get current date
            
            //Formatter for time
            let formatterTime = NSDateFormatter()
            formatterTime.timeStyle = .ShortStyle //Set style of time
            var timeString = formatterTime.stringFromDate(date) //Convert to String
    
    
            //Formatter for date
            let formatterDate = NSDateFormatter()
            formatterDate.dateStyle = .ShortStyle //Set style of date
            var dateString = formatterDate.stringFromDate(date) //Convert to String
    
            return (dateString, timeString) //Returns a Tuple type
            
        }
        
    To call this method within the same class:
            let time = getCurrentDateAndTime()
            println(time.date)
            println(time.time)
            
    //Results in the getCurrentDateAndTime function being called and the current date & time printed to the console. Notice how simply the values can be accessed from the returned Tuple;

    public by marksimon232 modified Aug 12, 2014  3059  0  6  1

    Swift Collections: Simple function with return value

    I want to our function to get the current time, formatted and returned as a String.
    => Objective-C:
    -(NSString *)getCurrentTime {
        
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
        NSString *currentTime = [dateFormatter stringFromDate:[NSDate date]];
    
        return currentTime;
        
    }
    
    To call this method within the same class:
    NSString *time = [self getCurrentTime];
    NSLog(@"%@",time);
    //Results in the getCurrentTime function being called and the current time printed to the console.
    
    
    => Swift 
    In Swift, we include the return arrow “->” which specifies that the function will return and the type of object that will be returned (String).
        func getCurrentTime() -> String {
            
            let date = NSDate()
            let formatter = NSDateFormatter()
            formatter.timeStyle = .ShortStyle
            var stringValue = formatter.stringFromDate(date)
            
            return stringValue
            
        }
        
    To call this method within the same class:
    let time = getCurrentTime()
    println(time)
    //Results in the getCurrentTime function being called and the current time printed to the console.

    public by marksimon232 modified Aug 12, 2014  2782  0  6  1

    Swift Collections: Simple function with parameter

    I want to pass a name (String) to a function and then print it out to the console.
    => Objective-C:
    -(void)outputName:(NSString *)nameString {
    
       NSLog(@"My name is %@",nameString);
    
    }
    
    To call this method within the same class:
    [self outputName:@"Mark"];
    //Results in the outputName function being called and "My name is Mark" printed to the console.
    
    
    => Swift:
    In Swift, we define the input value first (in our case, the string value), followed by the Type (String).
    func outputName(nameString:String){
    
        println("My name is: \(nameString)")
    
    }
    To call this method within the same class:
    outputName(@"Mark")
    //Results in the outputName function being called and "My name is Mark" printed to the console.

    public by marksimon232 modified Aug 12, 2014  1905  0  6  1

    Swift Collections: Simple function

    Objective-C:
    -(void)printText {
    
        NSLog(@"Printing this line to the console");
    
    }
    
    
    Swift:
    func printText(){
    
        println("Printing this line to the console")
    
    }
    • Public Snippets
    • Channels Snippets