working on it ...

Filters

Explore Public Snippets

Sort by

Found 269 snippets matching: recreate

    public by cghersi  4960  3  6  0

    Recreate the index structure of an MS SQL Server DB in T-SQL

    This script prepares and executes several dynamic SQL statements to recreate indexes exactly as they are built on the original DB
    USE Snip
    GO
    
    DECLARE @indexName nvarchar(70), @tableName nvarchar(100), @sql nvarchar(4000) = '', @colName nvarchar(100), @desc bit, 
    	@inclCol bit, @prevInclCol bit,@unique bit, @typeDesc nvarchar(40), @previousIndexName nvarchar(70) = '',
    	@filegroup nvarchar(100) = '[PRIMARY]', @fgName nvarchar(100), @prevFGName nvarchar(100)
    
    DECLARE fk CURSOR FOR 
    SELECT 
         TableName = t.name,
         IndexName = ind.name,
         ColumnName = col.name, FGName = '[' + f.name + ']',
    	 ic.is_descending_key, ic.is_included_column, ind.is_unique, ind.type_desc
    FROM 
         sys.indexes ind 
    INNER JOIN 
         sys.index_columns ic ON  ind.object_id = ic.object_id and ind.index_id = ic.index_id 
    INNER JOIN 
         sys.columns col ON ic.object_id = col.object_id and ic.column_id = col.column_id 
    INNER JOIN 
         sys.tables t ON ind.object_id = t.object_id 
    INNER JOIN sys.[filegroups] f
        ON f.[data_space_id] = ind.data_space_id
    WHERE ind.is_unique_constraint = 0  AND t.is_ms_shipped = 0 
    ORDER BY 
         t.name, ind.name, ind.index_id, ic.index_column_id
    
    OPEN fk
    FETCH NEXT FROM fk INTO @tableName, @indexName, @colName, @fgName, @desc, @inclCol, @unique, @typeDesc
    WHILE @@fetch_status = 0
    BEGIN
    	IF (@prevFGName = '')
    		SET @prevFGName = @fgName;
    print 'prev=' + @previousIndexName + ';new=' + @indexName + ';tbl=' + @tableName + ';col=' + @colName + 
    	';desc=' + CAST(@desc as nvarchar(10)) + ';fgName=' + @fgName + ';filegroup=' + @filegroup +
    	';include=' + CAST(@inclCol as nvarchar(10)) + ';unique=' + CAST(@unique as nvarchar(10)) + ';type=' + @typeDesc
    	IF (@previousIndexName = @indexName)
    	BEGIN
    		--continue with the previous index:
    		if (@inclCol = 1 AND @prevInclCol = 0)
    			SET @sql += ') INCLUDE ( ' + @colName;
    		ELSE
    			SET @sql += ',' + @colName;
    
    		SET @prevInclCol = @inclCol;
    		print 'sql in equal=' + @sql
    	 END
    	 ELSE
    	 BEGIN
    		--complete and exec the last statement:
    		SET @prevInclCol = 0;
    		IF (LEN(@sql) != 0)
    		BEGIN
    			IF (@prevFGName != @filegroup)
    			BEGIN
    				SET @sql += ') ON ' + @filegroup + ';';
    				--SET @sql += ') WITH (DROP_EXISTING = ON) ON ' + @filegroup + ';';
    				print 'sql to exec=' + @sql
    				EXEC( @sql);
    			END
    		END
    
    		--create a new statement:
    		SET @sql = ' CREATE ';
    		IF (@unique = 1)
    			SET @sql += ' UNIQUE ';
    		SET @sql += @typeDesc + ' INDEX ' + @indexName + '_1 ON dbo.' + @tableName + ' (' + @colName;
    		print 'sql created=' + @sql
    	END
    
    	IF (@inclCol = 0)
    	BEGIN
    		IF (@desc = 1)
    			SET @sql += ' DESC ';
    		ELSE
    			SET @sql += ' ASC ';
    	END
    	SELECT @previousIndexName = @indexName, @prevFGName = @fgName 
    				
    	FETCH NEXT FROM fk INTO @tableName, @indexName, @colName, @fgName, @desc, @inclCol, @unique, @typeDesc
    END
    CLOSE fk
    DEALLOCATE fk
    
    --complete and exec the last statement:
    IF (LEN(@sql) != 0)
    BEGIN
    	IF (@prevFGName != @filegroup)
    	BEGIN
    		SET @sql += ') ON ' + @filegroup + ';';
    		--SET @sql += ') WITH (DROP_EXISTING = ON) ON ' + @filegroup + ';';
    		print 'sql to exec=' + @sql
    		EXEC( @sql);
    	END
    END
    

    public by msdn  1649  0  6  0

    ResetOverflowLayout: Invoked when the content or overflow template is changed to recreate the column layout.

    Invoked when the content or overflow template is changed to recreate the column layout. Instance of where the change occurred. Event data describing the specific change.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Windows.Foundation;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Documents;
    
    /// <summary>
    /// Invoked when the content or overflow template is changed to recreate the column layout.
    /// </summary>
    /// <param name="d">Instance of <see cref="RichTextColumns"/> where the change
    /// occurred.</param>
    /// <param name="e">Event data describing the specific change.</param>
    private static void ResetOverflowLayout(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        // When dramatic changes occur, rebuild the column layout from scratch
        var target = d as RichTextColumns;
        if (target != null)
        {
            target._overflowColumns = null;
            target.Children.Clear();
            target.InvalidateMeasure();
        }
    }

    public by msdn  1206  2  7  0

    CreateTable: If there's no table [dbo].[Products] in DbDataIsolationLevel, create the table; or recreate it.

    If there's no table [dbo].[Products] in DbDataIsolationLevel, create the table; or recreate it.
    using System;
    using System.Data.SqlClient;
    
    /// <summary>
    /// If there's no table [dbo].[Products] in DbDataIsolationLevel, create
    /// the table; or recreate it.
    /// </summary>
    public static Boolean CreateTable(String connString)
    {
        using (SqlConnection conn = new SqlConnection(connString))
        {
            String cmdText = @"Use DbDataIsolationLevel
    
                                if Object_ID('[dbo].[Products]') is not null
                                drop table [dbo].[Products]
    
                                Create Table [dbo].[Products]
                                (
                                [ProductId] int IDENTITY(1,1) primary key,
                                [ProductName] NVarchar(100) not null,
                                [Quantity] int null,
                                [Price] money null
                                )";
    
            using (SqlCommand command = new SqlCommand(cmdText, conn))
            {
                conn.Open();
    
                command.ExecuteNonQuery();
            }
        }
    
        return InsertRows(connString);
    }

    public by msdn  1328  0  6  0

    RecreateSampleNavTermSet

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Microsoft.SharePoint;
    using System.Diagnostics;
    using Microsoft.SharePoint.Taxonomy;
    using Microsoft.SharePoint.Publishing.Navigation;
    using System.Net;
    
    public static NavigationTermSet RecreateSampleNavTermSet(TestContext testContext,
        TaxonomySession taxonomySession, SPWeb web)
    {
        Console.WriteLine(testContext, "RecreateSampleNavTermSet(): START");
    
        // Use the first TermStore object in the list.
        if (taxonomySession.TermStores.Count == 0)
            throw new InvalidOperationException("The Taxonomy Service is offline or missing.");
    
        TermStore termStore = taxonomySession.TermStores[0];
    
        // Does the TermSet object already exist?
        TermSet existingTermSet = termStore.GetTermSet(TestConfig.NavTermSetId);
    
        if (existingTermSet != null)
        {
            Console.WriteLine(testContext, "RecreateSampleNavTermSet(): Deleting old TermSet");
            existingTermSet.Delete();
            termStore.CommitAll();
        }
    
        Console.WriteLine(testContext, "RecreateSampleNavTermSet(): Creating new TermSet");
    
        // Create a new TermSet object.
        Group siteCollectionGroup = termStore.GetSiteCollectionGroup(web.Site);
        TermSet termSet = siteCollectionGroup.CreateTermSet("Navigation Demo", TestConfig.NavTermSetId);
    
        NavigationTermSet navTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, web,
            StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);
    
        navTermSet.IsNavigationTermSet = true;
        navTermSet.TargetUrlForChildTerms.Value = "~site/Pages/Topics/Topic.aspx";
    
        NavigationTerm term1 = navTermSet.CreateTerm("Term 1", NavigationLinkType.SimpleLink);
        term1.SimpleLinkUrl = "http://www.bing.com/";
    
        NavigationTerm term2 = navTermSet.CreateTerm("Term 2", NavigationLinkType.FriendlyUrl);
        NavigationTerm term2a = term2.CreateTerm("Term 2 A", NavigationLinkType.FriendlyUrl);
        NavigationTerm term2b = term2.CreateTerm("Term 2 B", NavigationLinkType.FriendlyUrl);
    
        NavigationTerm term3 = navTermSet.CreateTerm("Term 3", NavigationLinkType.FriendlyUrl);
    
        termStore.CommitAll();
    
        Console.WriteLine(testContext, "RecreateSampleNavTermSet(): FINISH");
    
        return navTermSet;
    }

    public by msdn  1205  0  7  0

    IsValidState: Verifies whether the specified communication object is in a valid state. If a communication object is not in a valid state, it needs to be recreated.

    Verifies whether the specified communication object is in a valid state. If a communication object is not in a valid state, it needs to be recreated. The instance of the object implementing the interface. True if the specified communication object is in a valid state, otherwise false.
    /// <summary>
    /// Verifies whether the specified communication object is in a valid state. If a communication object is not in a valid state, it needs to be recreated.
    /// </summary>
    /// <param name="commObj">The instance of the object implementing the <see cref="System.ServiceModel.ICommunicationObject"/> interface.</param>
    /// <returns>True if the specified communication object is in a valid state, otherwise false.</returns>
    public static bool IsValidState(this ICommunicationObject commObj)
    {
        return commObj != null && commObj.State != CommunicationState.Closed && commObj.State != CommunicationState.Closing && commObj.State != CommunicationState.Faulted;
    }

    public by msdn  1149  0  6  0

    Main: Configures the ACS service namespace with the proper objects for this sample.

    Configures the ACS service namespace with the proper objects for this sample. Existing objects that are needed for this sample will be deleted and recreated.
    using System;
    using System.Linq;
    using System.Data.Services.Client;
    using System.Globalization;
    using ACS.Management;
    using Common.ACS.Management;
    
    /// <summary>
    /// Configures the ACS service namespace with the proper objects for this sample.
    /// </summary>
    /// <remarks>
    /// Existing objects that are needed for this sample will be deleted and recreated.
    /// </remarks>
    static void Main(string[] args)
    {
        const string rpName = "ASPNET MVC3 Custom Sign-In Page Sample";
        const string rpRealm = "http://localhost:64000/";
        const string rpReplyTo = "http://localhost:64000/Account/SignIn";
                
        const string facebookName = "Facebook";
        const string yahooName = "Yahoo!";
    
        const string defaultRuleGroupName = "Default rule group for ASPNET MVC3 Custom Sign-In Page Sample";
    
        // Please update these with your own Facebook application information
        const string applicationId = "applicationid";
        const string applicationSecret = "applicationsecret";
    
        string facebookIdpName = String.Format(CultureInfo.InvariantCulture, "Facebook-{0}", applicationId);
    
        ManagementService svc = ManagementServiceHelper.CreateManagementServiceClient();
                            
        //
        // Clean up pre-existing configuration
        //
        svc.DeleteRelyingPartyByRealmIfExists(rpRealm);
        svc.DeleteRuleGroupByNameIfExists(defaultRuleGroupName);
        svc.DeleteIdentityProviderIfExists(facebookIdpName);
        svc.DeleteIdentityProviderIfExists(yahooName);
        svc.SaveChangesBatch();
    
        //
        // Create Identity Providers
        //
        IdentityProvider live = svc.GetIdentityProviderByName("uri:WindowsLiveID");;
    
        IdentityProvider facebook = svc.CreateFacebookIdentityProvider(applicationId, applicationSecret, "email,user_events");
        SetSignInInformation(svc, facebook, facebookName);
    
        IdentityProvider yahoo = svc.CreateOpenIdIdentityProvider(yahooName, "https://open.login.yahooapis.com/openid/op/auth");
        SetSignInInformation(svc, yahoo, yahooName);
    
        IdentityProvider[] associatedProviders = new[] { live, facebook, yahoo };
    
        //
        // Create Relying Party
        //
        RelyingParty relyingParty = svc.CreateRelyingParty(rpName, rpRealm, rpReplyTo, RelyingPartyTokenType.SAML_2_0, false);
    
        svc.AssociateIdentityProvidersWithRelyingParties(associatedProviders, new[] { relyingParty });
    
        RuleGroup ruleGroup = svc.CreateRuleGroup(defaultRuleGroupName);
        svc.AssignRuleGroupToRelyingParty(ruleGroup, relyingParty);
    
        //
        // Create simple rules to pass through all claims from each issuer.
        //
        foreach (IdentityProvider identityProvider in associatedProviders)
        {
            string ruleDescription = string.Format(CultureInfo.InvariantCulture, "Pass through all claims from '{0}'", identityProvider.Issuer.Name);
            svc.CreateRule(identityProvider.Issuer, null, null, null, null, ruleGroup, ruleDescription);
        }
        svc.SaveChangesBatch();
    
        Console.WriteLine("Sample successfully configured. Press ENTER to continue ...");
        Console.ReadLine();
    
    }

    external by Github  114  0  2  0

    Languages http://www.arxonline.nl/index.php/write-an-essay-my-aim-in-life recreate write essay my pet cat urban wife "Solomon himself could not distribute this money in a fashion that everyone would find fair," he told the more than 50 gathered at a p...

    Languages http://www.arxonline.nl/index.php/write-an-essay-my-aim-in-life recreate write essay my pet cat urban wife "Solomon himself could not distribute this money in a fashion that everyone would find fair," he told the more than 50 gathered at a public meeting in Newtown on Thursday evening. "Money is a pretty poor substitute for loss of life.
    Languages http://www.arxonline.nl/index.php/write-an-essay-my-aim-in-life recreate write essay my pet cat urban wife  "Solomon himself could not distribute this money in a fashion that everyone would find fair," he told the more than 50 gathered at a public meeting in Newtown on Thursday evening. "Money is a pretty poor substitute for loss of life."
     http://www.guesthouselerwick.com/personal-statement-internal-medicine/ resistance 5 paragraph essay online rudely impulse  The Obama administration has defended its response to date in Syria. Since Obama declared last August that chemical weapons would constitute a "red line," the administration this past June did conclude that the government used chemical weapons. Following that, the president authorized military support for the Syrian opposition. 
     
    
    

    external by shoghicp  68  0  1  0

    This code will: Recreate lost signs, furnaces and chests, and remove invalid or corrupt tile entities from a world.

    This code will: Recreate lost signs, furnaces and chests, and remove invalid or corrupt tile entities from a world.: worldFixer.php
    PHP
    <?php
    $world = $this->getServer()->getDefaultLevel();
    $radius = 80;
    $total = (($radius * 2) + 1) ** 2;
    $count = 0;
    for($chunkX = -$radius; $chunkX <= $radius; ++$chunkX){
    	for($chunkZ = -$radius; $chunkZ <= $radius; ++$chunkZ){
    		$chunk = $world->getChunk($chunkX, $chunkZ, false);
    		if($chunk instanceof \pocketmine\level\format\FullChunk and $chunk->isPopulated()){
    			$tiles = [];
    			$save = false;
    			foreach($chunk->getTiles() as $tile){
    				$x = $tile->x & 0x0f;
    				$y = $tile->y;
    				$z = $tile->z & 0x0f;
    				$blockId = $chunk->getBlockId($x, $y, $z);
    				if(isset($tiles["$x:$y:$z"])){
    					echo "Found duplicated tile in chunk $chunkX, $chunkZ [$x:$y:$z]\n";
    					$tile->close();
    					$save = true;
    				}elseif($tile instanceof \pocketmine\tile\Chest){
    					if($blockId !== 54){
    						echo "Found corrupt chest in chunk $chunkX, $chunkZ [$x:$y:$z]\n";
    						$tile->close();
    						$save = true;
    					}
    				}elseif($tile instanceof \pocketmine\tile\Sign){
    					if($blockId !== 63 and $blockId !== 68){
    						echo "Found corrupt sign in chunk $chunkX, $chunkZ [$x:$y:$z]\n";
    						$tile->close();
    						$save = true;
    					}
    				}elseif($tile instanceof \pocketmine\tile\Furnace){
    					if($blockId !== 61 and $blockId !== 62){
    						echo "Found corrupt furnace in chunk $chunkX, $chunkZ [$x:$y:$z]\n";
    						$tile->close();
    						$save = true;
    					}
    				}
    				$tiles["$x:$y:$z"] = true;
    			}
    			for($x = 0; $x < 16; ++$x){
    				for($z = 0; $z < 16; ++$z){
    					for($y = 0; $y < 128; ++$y){
    						if(!isset($tiles["$x:$y:$z"])){
    							$blockId = $chunk->getBlockId($x, $y, $z);
    							if($blockId === 54){
    								echo "Found non-tile chest in chunk $chunkX, $chunkZ [$x:$y:$z]\n";
    								$nbt = new \pocketmine\nbt\tag\Compound(false, [
    									new \pocketmine\nbt\tag\Enum("Items", []),
    									new \pocketmine\nbt\tag\String("id", \pocketmine\tile\Tile::CHEST),
    									new \pocketmine\nbt\tag\Int("x", $chunkX * 16 + $x),
    									new \pocketmine\nbt\tag\Int("y", $y),
    									new \pocketmine\nbt\tag\Int("z", $chunkZ * 16 + $z)
    								]);
    								$nbt->Items->setTagType(\pocketmine\nbt\NBT::TAG_Compound);
    								new \pocketmine\tile\Chest($chunk, $nbt);
    								$save = true;
    							}elseif($blockId === 61 or $blockId === 62){
    								echo "Found non-tile furnace in chunk $chunkX, $chunkZ [$x:$y:$z]\n";
    								$nbt = new \pocketmine\nbt\tag\Compound(false, [
    									new \pocketmine\nbt\tag\Enum("Items", []),
    									new \pocketmine\nbt\tag\String("id", \pocketmine\tile\Tile::FURNACE),
    									new \pocketmine\nbt\tag\Int("x", $chunkX * 16 + $x),
    									new \pocketmine\nbt\tag\Int("y", $y),
    									new \pocketmine\nbt\tag\Int("z", $chunkZ * 16 + $z)
    								]);
    								$nbt->Items->setTagType(\pocketmine\nbt\NBT::TAG_Compound);
    								new \pocketmine\tile\Furnace($chunk, $nbt);
    								$save = true;
    							}elseif($blockId === 63 or $blockId === 68){
    								echo "Found non-tile sign in chunk $chunkX, $chunkZ [$x:$y:$z]\n";
    								$nbt = new \pocketmine\nbt\tag\Compound(false, [
    									new \pocketmine\nbt\tag\String("id", \pocketmine\tile\Tile::SIGN),
    									new \pocketmine\nbt\tag\Int("x", $chunkX * 16 + $x),
    									new \pocketmine\nbt\tag\Int("y", $y),
    									new \pocketmine\nbt\tag\Int("z", $chunkZ * 16 + $z)
    								]);
    								new \pocketmine\tile\Sign($chunk, $nbt);
    								$save = true;
    							}
    						}
    					}
    				}
    			}
    			if($save){
    				$world->setChunk($chunkX, $chunkZ, $chunk, false);
    				$world->saveChunks();
    			}
    		}
    		$world->unloadChunk($chunkX, $chunkZ, false);
    		++$count;
    	}
    	echo "[".round(($count/$total) * 100, 0)."%] $count/$total\n";
    }
    $world->save(true);
    
    

    external by markmcdonald51  68  0  1  0

    Recreate a sqlite3 dev db from current pg_dump from production.

    Recreate a sqlite3 dev db from current pg_dump from production.: gistfile1.txt
    namespace :database_utilities do
      desc "Recreate a sqlite3 dev db from current pg_dump from production."
      
      # This task should only ever be run in a development environment.
      task create_sqlite3_from_pg_dump: :environment do
        # by Mark on Wed May 13 06:15:09 EDT 2015
    
        # Based on the ideals from this webpage: 
        # http://manuel.manuelles.nl/blog/2012/01/18/convert-postgresql-to-sqlite/
    
        file_dir      = "/home/mark/backup/pg_dump/"    
        out_file_name = 'congo_mines_import_for_sqlite.sql'
        dev_app_dir   = '/home/mark/dev/congo-mines-app'    
            
        unless Rails.env.development?
          puts "Sorry, but you are running in #{Rails.env}."
          puts "This task should only ever be run in a development environment."
          puts "This task will now exit"  
          exit
        end
    
        # get the latest sqlite dump file
        sqlite_in_file = Dir.glob("#{file_dir}/*sqlite3.sql").max_by {|f| File.mtime(f)}
        
        # Open a file for re-writing.
        out_file = File.open(out_file_name, 'w') 
        out_file.puts 'BEGIN;'
        
        File.open(sqlite_in_file, "r:bom|utf-8").each_line do |l|
          # Remove line beginning with 'SET'  
          next if l =~ /^SET|setval/o
          
          # The pg_dump generate’s true and false as value’s for the INSERT INTO
          # statements. If we want to import these to SQLite we have to replace 
          # these to ‘t’ and ‘f’.
          #-- These:
          # INSERT INTO table_name VALUES (1, true, false);
          # -- Should be replace to:
          # INSERT INTO table_name VALUES (1, 't', 'f');
          
          l.gsub!('true', "'t'")
          l.gsub!('false', "'f'")   
          
          # remove utf characters
          l.gsub!("\xEF\xBB\xBF".force_encoding("UTF-8"), '')
    
          out_file.puts l
        end
        out_file.puts 'END;'
        
        # 3. Recreate the development database
        # So now we have fetched the production data from the PostgreSQL database, 
        # we need to recreate the development.sqlite3 database. 
        # For this task I am going to use a 'dev' version of the project. Essentially 
        # a complete checkout of the repo. 
        
        if File.exist?("#{dev_app_dir}/db/development.sqlite3")
          # First, Make a backup..
          File.rename("#{dev_app_dir}/db/development.sqlite3", 
                      "#{dev_app_dir}/db/development.backup.sqlite3")
    
        end
        # Now run the migration task.
        Rake::Task["db:migrate"].invoke
        
        ##  Import the dump
        # The final step is importing the dump file. To do this we have to 
        # execute the following command 
        #cat congo_mines_import_for_sqlite.sql | sqlite3 db/development.sqlite3
        
       # system("cat #{out_file_name} | sqlite3 #{dev_app_dir}/db/development.sqlite3")
        
        puts "sqlite3 #{dev_app_dir}/db/development.sqlite3 < #{out_file_name}"
        system("sqlite3 #{dev_app_dir}/db/development.sqlite3 < #{out_file_name}")
        
        puts '*' * 40
        puts "Done! The dev sqlite new file is: #{dev_app_dir}/db/development.sqlite3"
        
    
      end
    
    end
    
    

    external by H3xept  57  0  1  0

    I made this trying to recreate iOS assistive touch. It's pretty basic, i have added snap to borders and show/hide animation. You can find an implementation in my repository "Tweak".

    I made this trying to recreate iOS assistive touch. It's pretty basic, i have added snap to borders and show/hide animation. You can find an implementation in my repository "Tweak".: Draggable UIView
    @interface FloatingView : UIView
    
    -(void)dragged:(UIPanGestureRecognizer *)sender;
    -(void)snapToLeft;
    -(void)snapToRight;
    -(void)snapToBottom;
    -(void)snapToTop;
    -(void)collapse;
    -(void)show;
    
    @end
    
    @implementation FloatingView
    -(instancetype)init{
    	self = [super initWithFrame:CGRectMake(ScreenWidth,270,55,55)];
    	return self;
    	
      self.backgroundColor = [UIColor redColor];
    	self.userInteractionEnabled = YES;
      
      //DRAG
      UIPanGestureRecognizer* panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(dragged:)];
      [panRecognizer setMinimumNumberOfTouches:1];
      [panRecognizer setMaximumNumberOfTouches:1];
      [self addGestureRecognizer:panRecognizer];
      [panRecognizer release];
      
      /* // ------ UNUSED IN THIS FILE, CHECK IMPLEMENTATION IN REPOSITORY "TWEAK"
      //DOUBLE TAP 
      UITapGestureRecognizer* doubleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(switchSocial:)];
      [doubleTapRecognizer setNumberOfTapsRequired:2];
      [self addGestureRecognizer:doubleTapRecognizer];
      [doubleTapRecognizer release];
      
      //SINGLE TAP
      UITapGestureRecognizer* singleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showSocialModel:)];
      [singleTapRecognizer setNumberOfTapsRequired:1];
      [self addGestureRecognizer:singleTapRecognizer];
      [singleTapRecognizer release];
      [singleTapRecognizer requireGestureRecognizerToFail:doubleTapRecognizer];
    */ // ------ UNUSED IN THIS FILE, CHECK IMPLEMENTATION IN REPOSITORY "TWEAK"
      return self;
    
    }
    
    -(void)dragged:(UIPanGestureRecognizer *)sender{
    
        if (sender.state == UIGestureRecognizerStateEnded){
    
            if(sender.view.center.y > [[UIScreen mainScreen] bounds].size.height-100){
                [self snapToBottom];
            }
            else if(sender.view.center.y < 100){
                [self snapToTop];
            }
            else{
            if(sender.view.center.x < [[UIScreen mainScreen] bounds].size.width/2){
                [self snapToLeft];
            }
            else if(sender.view.center.x >= [[UIScreen mainScreen] bounds].size.width/2){
                [self snapToRight]; 
            }
        }}
        if (sender.state == UIGestureRecognizerStateChanged){
    
        CGPoint translation = [sender translationInView:sender.view];
        sender.view.center = CGPointMake(sender.view.center.x + translation.x, sender.view.center.y + translation.y);
        [sender setTranslation:CGPointMake(0, 0) inView:sender.view];
    
        }
    
    }
    
    -(void)snapToLeft{
        [UIView animateWithDuration:0.3 delay:0.0 options: UIViewAnimationCurveEaseIn animations:^{
                         assistantView.frame = CGRectMake(5,assistantView.frame.origin.y,[assistantView bounds].size.width,[assistantView bounds].size.height);
                     } completion:^(BOOL finished){}];
    }
    
    -(void)snapToRight{
        [UIView animateWithDuration:0.3 delay:0.0 options: UIViewAnimationCurveEaseIn animations:^{
                         assistantView.frame = CGRectMake([[UIScreen mainScreen] bounds].size.width-[assistantView bounds].size.width-5,assistantView.frame.origin.y,[assistantView bounds].size.width,[assistantView bounds].size.height);
                     } completion:^(BOOL finished){}];
    }
    
    -(void)snapToBottom{
        [UIView animateWithDuration:0.3 delay:0.0 options: UIViewAnimationCurveEaseIn animations:^{
                         assistantView.frame = CGRectMake(assistantView.frame.origin.x,[[UIScreen mainScreen] bounds].size.height-[assistantView bounds].size.height-5,[assistantView bounds].size.width,[assistantView bounds].size.height);
                     } completion:^(BOOL finished){}];
    }
    
    -(void)snapToTop{
        [UIView animateWithDuration:0.3 delay:0.0 options: UIViewAnimationCurveEaseIn animations:^{
                         assistantView.frame = CGRectMake(assistantView.frame.origin.x,5,[assistantView bounds].size.width,[assistantView bounds].size.height);
                     } completion:^(BOOL finished){}];
    }
    
    -(void)collapse{
        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
            self.transform = CGAffineTransformMakeScale(0.01, 0.01);
        } completion:^(BOOL finished){self.hidden = YES;}];
    }
    
    -(void)show{
    
        self.transform = CGAffineTransformMakeScale(0.01, 0.01);
        self.hidden = NO;
        [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
            self.transform = CGAffineTransformIdentity;
        } completion:^(BOOL finished){}];
    }
    
    
    @end
    
    
    
    • Public Snippets
    • Channels Snippets