working on it ...

Filters

Explore Public Snippets

Sort by

Found 54k snippets matching: act

    public by lbottaro  529684  10  8  0

    How to get the list of all the activities comparing two UCM streams in python

    This script shows how to get the list of all the activities comparing two ucm streams. The command returns a list object you can easily loop and print.
    import os
    
    bl_old="myOldBaseline@/MyVobs"
    bl_new="myNewBaseline@/MyVobs"
    myView = "MyView"
    
    diff_act=os.popen("cleartool setview -exec \"cleartool diffbl -nmerge -activities "+bl_old+" "+ bl_new+" \" " +myView).readlines()
    
    for act in diff_act:
      print ("ACTIVITY: "+str(act))
    

    public by cghersi  468637  7  8  2

    Load a SOAP endpoint with Apache CXF using JMS transport provided by Apache ActiveMQ

    This is an example on how to load a SOAP web service in order to be able to invoke its methods via JMS transport
    private JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    public MyInterface loadEndPoint() {
    	//try to load from local, if available:
    	boolean loadOK = false;
    	MyInterface result = null;
    	try {
    		Class<?> c = Class.forName("MyImplClass");
    		Method fact = c.getMethod("get");
    		result = (MyInterface) fact.invoke(null);
    		loadOK = true;
    	} catch (ClassNotFoundException e) {
    		log.info("Cannot find MyImplClass, redirecting to  remote access...", e);		
    	} catch (Exception e) {
    		log.warn("Error searching MyImplClass, , redirecting to remote access. Exception is " + e, e);
    	}
    		
    	//load remote endpoint:
    	if (!loadOK) {
    		//detect transport protocol for web services:
    		String brokerAddr = "127.0.0.1"; //the right broker address
    		String queueName = "MyQueueName";
    		String address = "jms:jndi:dynamicQueues/" + queueName + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&jndiConnectionFactoryName=ConnectionFactory&jndiURL=" + brokerAddr;
    
    		log.info("Connecting to " + address);
    		String connString = "tcp://" + brokerAddr + ":61616";
    		ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory("Myusername", "Mypassword", connString);
    
    		SoapBindingConfiguration conf = new SoapBindingConfiguration();
    		//MTOM not supported! .net does not interoperate with cxf mtom impl.
    //		conf.setMtomEnabled(true);
    		conf.setVersion(Soap12.getInstance());
    		factory.setBindingConfig(conf);
    
    		factory.setServiceClass(MyInterface.class);
    		factory.setAddress(address);
    		factory.getFeatures().add(new WSAddressingFeature());
    		factory.getFeatures().add(getJMSConfigFeature(queueName, connFactory, 10000)));
    		Object resObj = factory.create();
    		if ((resObj != null) && (resObj instanceof MyInterface))
    			result = (MyInterface) resObj;
    		}
    
    		return result;
    	}
    }
    
    public static JMSConfigFeature getJMSConfigFeature(String queueName, ActiveMQConnectionFactory connectionFactory, Long receiveTimeout) {
    	JMSConfigFeature jmsConfigFeature = new JMSConfigFeature();
    	JMSConfiguration jmsConfig = new JMSConfiguration();
    	jmsConfig.setUseJms11(true);
    	jmsConfig.setTargetDestination(queueName);
    	jmsConfig.setConnectionFactory(connectionFactory);
    	if (receiveTimeout != null)
    		jmsConfig.setReceiveTimeout(receiveTimeout);
    	jmsConfigFeature.setJmsConfig(jmsConfig);
    	return jmsConfigFeature;
    }

    public by mporru @ Amazon_AWS_PHP_API  320871  0  5  0

    Amazon AWS - PHP: Generate signed expiring download URL

    This snippet demonstrates how to generate a download URL for a file stored in your S3 Bucket. This will work for all files, even ACL private files. Download URL will be active for the specified time. In order to use this service you must enable Amazon Simple Storage Service (Amazon S3) in your account.
    <?php
    require_once('sdk.class.php');
    $s3 = new AmazonS3();
    
    $fileName = 'test1.txt';
    $bucketName = 'myBucketName';
    
    $url = $s3->get_object_url($bucketName, $fileName, '1 hour');
    
    echo("Download url: <a href=\"$url\">$url</a>\n");
    ?>

    public by christopher  206467  20  3  0

    Draw things with the turtle api built into python. It can be slow due to fact its not an actual GUI system. However it is fun to toy with.

    Draw things with the turtle api built into python. It can be slow due to fact its not an actual GUI system. However it is fun to toy with.: drawUtils.py
    #import sys #Currently not needed
    import time
    from turtle import *
    
    #Draw a box
    def drawBox(x1, x2, y1, y2, penColor="Black", fillColor="Black"):
        turtle = Turtle()
        d = delay()
        delay(0)
        turtle.hideturtle()
        turtle.up()
        turtle.pencolor(penColor)
        turtle.fillcolor(fillColor)
        turtle.goto(x1, y1)
        turtle.down()
        turtle.begin_fill()
        turtle.goto(x1, y2)
        turtle.goto(x2, y2)
        turtle.goto(x2, y1)
        turtle.goto(x1, y1)
        turtle.end_fill()
        turtle.up()
        del turtle
        delay(d)
        del d
        
    def drawCircle(size,
                   x = None, y = None,
                   usePen = True,
                   useFill = True,
                   fillColor = "Black",
                   penColor = ["Black"],
                   penSize = 5,
                   pieces = 1):
        if (pieces < 1):
            pieces = 1
        if not(usePen) and not(useFill):
            raise Exception("No pen or fill makes this useless! Please specify at least one of them as True")
        turtle = Turtle()
    
        #Store previous delay
        d = delay()
    
        #Set to draw instantly.
        delay(0)
    
    
        turtle.up() #Pickup pen
        turtle.ht() #Hide the turtle
        if (x == None): #Set default value
            x = (0-(size/2))
        if (y == None): #Set default value
            y = (0-(size/2))
        
        turtle.goto(x, y) #Goto co ords
        icM = len(penColor) #Check size of array and limit it.
        if (icM < 1):
            raise Exception("penColor must have at least one entry in array!")
    
        b = 0 #Store the first color index
    
    
        incD =  (360/pieces)#Incrementation of degrees./
        if (useFill):
            turtle.begin_fill()
        if (usePen):
            turtle.down()
            turtle.pensize(penSize)
        for i in range(-1, pieces):
            ic = penColor[b]
            turtle.fillcolor(fillColor)
            turtle.pencolor(ic)
            turtle.circle(size, incD)
            b += 1
            if not(b < icM):
                b = 0
        turtle.end_fill()
        #Reset delay
        delay(d)
    
        del turtle
    
    
    
    
    def drawTriangle(h, w, x = None, y = None, useFill = True, usePen = True, penColor = "Black", fillColor = "Black", penSize = 1):
        if (x == None): #Set default values
            x = 0-(w/2)
        if (y == None): #Set default values
            y = 0-(h/2)
        else:
            y += (h/2)
        x1, x2 = x-(w/2), x+(w/2)
        y1, y2 = y-(h/2), y+(h/2)
        d = delay()
        delay(0)
        turtle = Turtle()
        turtle.ht()
        turtle.up()
        turtle.goto(x1, y1)
        if (useFill):
            turtle.begin_fill()
            turtle.fillcolor(fillColor)
        if (usePen):
            turtle.down()
            turtle.pencolor(penColor)
        print("x1=",x1,"x2=",x2,"y1=", y1,"y2=", y2,"y=", y,"x=", x) #Debug code
        turtle.goto(x2, y1)
        turtle.goto(x, y2)
        turtle.goto(x1, y1)
        turtle.up()
        turtle.end_fill()
        del turtle
        delay(d)
    
    def drawHouse(size, x = 0, y = 0):
        pass
    
    
    
    
    
    ########This is a test area for use Simply uncomment code
    setup()
    title("PLACE TITLE HERE")
    
    ##Use the api below here to create simple drawings on a window. Or do more complex stuff.
    ##This is not exactly a proper module so it can not be imported or atleast I do not think. I am still learning python.
    ##Enjoy!
    
    
    
    
    
    

    public by cghersi @ MailUp API DEV  206838  8  6  1

    MailUp REST API - How to subscribe to a particular list several contacts with the "Confirmed Optin" Procedure

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void SubcribeRecipientsWithDoubleOptin(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Subscribe recipients:
        int idList = 1;
        List<ConsoleRecipientItem> recipients = new List<ConsoleRecipientItem>();
        ConsoleRecipientItem recipient1 = new ConsoleRecipientItem()
        {
            Email = "test1@mailup.com",
            Name = "First New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3331234567",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name1_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName1_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        ConsoleRecipientItem recipient2 = new ConsoleRecipientItem()
        {
            Email = "test2@mailup.com",
            Name = "Second New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3337654321",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name2_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName2_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        recipients.Add(recipient1);
        recipients.Add(recipient2);
        int subscriptionResult = 0;
        try
        {
            subscriptionResult = client.AddRecipientsToList(idList, recipients, true);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
        // 2.1) wait for the end of import task:
        if (subscriptionResult > 0)
        {
            Console.WriteLine("Recipients Import started; import ID:" + subscriptionResult);
    
            //optionally we can check the import status:
            bool completed = false;
            do
            {
                ConsoleImportStatus importStatus = client.CheckImportStatus(subscriptionResult);
                if (importStatus == null)
                {
                    Console.WriteLine("Cannot check the import status for import task #" + subscriptionResult);
                    return;
                }
                completed = importStatus.Completed;
            } while (!completed);
            Console.WriteLine("Recipients Added!");
        }
        else
        {
            Console.WriteLine("An error occurred while adding the recipients.");
            return;
        }
    
        // 3) Retrieve the sendingID of the confirmation email related to the previous task:
        int sendingID = -1;
        try
        {
            sendingID = client.GetSendingIDForImport(subscriptionResult);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot retrieve sending ID due to " + ex.Message);
            return;
        }
        if (sendingID <= 0)
        {
            Console.WriteLine("Cannot retrieve sending ID.");
            return;
        }
    
        // 4) Send the confirmation email:
        EmailSendingItem sendingResult = null;
        try
        {
            sendingResult = client.SendEmailMessage(sendingID);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot send email due to " + ex.Message);
            return;
        }
        if (sendingResult == null)
            Console.WriteLine("Cannot send confirmation email.");
        else
            Console.WriteLine("Confirmation email sent!");
    }
                

    public by sherazam  184669  0  5  0

    How to Render an Image of 3D Model from the Camera inside .NET Application

    This Technical tip explains how .NET developers can render an image of 3D model from the camera inside their .NET applications. Using Aspose.3D for .NET, developers can render an image to view a realistic image of 3D model, with or without the enhanced background, textures, shadows and also adjust the image size. The Render method exposed by the Sc
    // Enter here the actual content of the snippet.            // this code example creates a camera in a 3D scene, sets its target and render an image.
    
    // [C# Code Sample]
    
    // For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET
    // The path to the documents directory.
    string MyDir = RunExamples.GetDataDir();
    
    // Load scene from file
    Scene scene = new Scene(MyDir + "camera.3ds");
    // Create a camera at (10,10,10) and look at the origin point for rendering,
    // it must be attached to the scene before render
    Camera camera = new Camera();
    scene.RootNode.CreateChildNode("camera", camera);
    camera.ParentNode.Transform.Translation = new Vector3(10, 10, 10);
    camera.LookAt = Vector3.Origin;
    
    // Specify the image render option
    ImageRenderOptions opt = new ImageRenderOptions();
    // Set the background color
    opt.BackgroundColor = Color.AliceBlue;
    // Tells renderer where the it can find textures
    opt.AssetDirectories.Add(MyDir + "textures");
    // Turn on shadow
    opt.EnableShadows = true;
    // Render the scene in given camera's perspective into specified png file with size 1024x1024
    scene.Render(camera, MyDir + "Render3DModelImageFromCamera_out_.png", new Size(1024, 1024), ImageFormat.Png, opt);
    
    //[VB.NET Code Sample]
    
    ' For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET
    ' The path to the documents directory.
    Dim MyDir As String = RunExamples.GetDataDir()
    
    ' Load scene from file
    Dim scene As New Scene(MyDir & Convert.ToString("camera.3ds"))
    ' Create a camera at (10,10,10) and look at the origin point for rendering,
    ' it must be attached to the scene before render
    Dim camera As New Camera()
    scene.RootNode.CreateChildNode("camera", camera)
    camera.ParentNode.Transform.Translation = New Vector3(10, 10, 10)
    camera.LookAt = Vector3.Origin
    
    ' Specify the image render option
    Dim opt As New ImageRenderOptions()
    ' Set the background color
    opt.BackgroundColor = Color.AliceBlue
    ' Tells renderer where the it can find textures
    opt.AssetDirectories.Add(MyDir & Convert.ToString("textures"))
    ' Turn on shadow
    opt.EnableShadows = True
    ' Render the scene in given camera's perspective into specified png file with size 1024x1024
    scene.Render(camera, MyDir & Convert.ToString("Render3DModelImageFromCamera_out_.png"), New Size(1024, 1024), ImageFormat.Png, opt)
    

    public by bobby  157351  2  4  0

    Returns Descriptions for all active Magento products

    Returns Descriptions for all active Magento products: Magento-active-product-descriptions.sql
    SELECT 
        e.entity_id,
        e.sku,
        eav.value AS 'description',
        IF(at_status.value_id > 0,
            at_status.value,
            at_status_default.value) AS `status`
    FROM
        catalog_product_entity e
            JOIN
        catalog_product_entity_text eav ON e.entity_id = eav.entity_id
            JOIN
        eav_attribute ea ON eav.attribute_id = ea.attribute_id
            INNER JOIN
        `catalog_product_entity_int` AS `at_status_default` ON (`at_status_default`.`entity_id` = `e`.`entity_id`)
            AND (`at_status_default`.`attribute_id` = '89')
            AND `at_status_default`.`store_id` = 0
            LEFT JOIN
        `catalog_product_entity_int` AS `at_status` ON (`at_status`.`entity_id` = `e`.`entity_id`)
            AND (`at_status`.`attribute_id` = '89')
            AND (`at_status`.`store_id` = 1)
    WHERE
        ea.attribute_code = 'description'
            AND IF(at_status.value_id > 0,
            at_status.value,
            at_status_default.value) = 1
    LIMIT 9999
    
                

    public by Pavel Shorokhov  23422  1036  4  0

    PHPStorm 10 Activation Key

    PHPStorm 10 Activation Key: PHPStorm 10 Activation Key
    PHPStorm 10
    For activation set license server to: http://idea.lanyus.com
    and press Ok. No key. Worked.
    
    Found there:
    https://бэкдор.рф/phpstorm-7-8-9-10-product-key/
    
    

    public by geeknam  120651  0  3  0

    Applescript to activate Internet Sharing

    Applescript to activate Internet Sharing: internet_sharing.scpt
    register_growl()
    growlnote("Copying process", "bootpd.plist copied")
    do shell script "sudo cp /tmp/bootpd.plist /etc" password "yourpassword" with administrator privileges
    tell application "System Preferences" to set current pane to pane "com.apple.preferences.sharing"
    tell application "System Events" to tell process "System Preferences"
    	click checkbox 1 of row 11 of table 1 of scroll area 1 of group 1 of window "Sharing"
    	delay 1
    	if (exists sheet 1 of window "Sharing") then
    		click button "Start" of sheet 1 of window "Sharing"
    	end if
    	try
    		set message to "Internet Connection Sharing Enabled"
    		my growlnote("General Notification", message)
    	on error
    		set message to "Internet Connection Sharing was Not Enabled"
    		my growlnote("error notification", message)
    	end try
    end tell
    ignoring application responses
    	tell application "System Preferences" to quit
    end ignoring
    
    on register_growl()
    	try
    		tell application "GrowlHelperApp"
    			set the allNotificationsList to {"General Notification", "Debug Notification", "Error Notification"}
    			set the enabledNotificationsList to {"General Notification", "Debug Notification", "Error Notification"}
    			register as application "Enable Internet Connection Sharing" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Sharing"
    		end tell
    	end try
    end register_growl
    
    on growlnote(growltype, str)
    	try
    		tell application "GrowlHelperApp"
    			notify with name growltype title growltype description str application name "Enable Internet Connection Sharing"
    		end tell
    	end try
    end growlnote
    
    

    public by Fresh-Dev  116046  0  3  0

    Threadsafe-GUI Interaction

    Threadsafe-GUI Interaction: threadsafe-gui-actions.cs
      // This method demonstrates a pattern for making thread-safe
    // calls on a Windows Forms control. 
    //
    // If the calling thread is different from the thread that
    // created the TextBox control, this method creates a
    // SetTextCallback and calls itself asynchronously using the
    // Invoke method.
    //
    // If the calling thread is the same as the thread that created
    // the TextBox control, the Text property is set directly. 
    
    private void SetText(string text)
    {
    	// InvokeRequired required compares the thread ID of the
    	// calling thread to the thread ID of the creating thread.
    	// If these threads are different, it returns true.
    	if (this.textBox1.InvokeRequired)
    	{	
    		SetTextCallback d = new SetTextCallback(SetText);
    		this.Invoke(d, new object[] { text });
    	}
    	else
    	{
    		this.textBox1.Text = text;
    	}
    }
    
    
    • Public Snippets
    • Channels Snippets