working on it ...

Filters

Explore Public Snippets

Sort by

Found 33k snippets matching: service

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

    public by cghersi  468659  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 JackLatanis  298005  7  6  -1

    Sending email via AuthMailer service using PHP

    //this code sends emails via AuthMailer service (www.authmailer.com)
    
    <?
    
    //install the Mail, Net_Socket and Net_SMTP with PEAR
    require_once "Mail.php";
     
    //mail headers and body
    $from = "Me";
    $to = "You";
    $subject = "Subject";
    $body = "Lorem Ipsum...";
    
    //server configuration, edit with your account details 
    $host = "authmailer.com";
    $port = "587";
    $user = "user";
    $pass = "pass";
     
    $headers = array('From' => $from,
    	'To' => $to,
    	'Subject' => $subject);
    
    $smtp = Mail::factory('smtp',
    	array('host' => $host,
    	'auth' => true,
    	'username' => $user,
    	'password' => $pass));
    
    //sending email
    $mail = $smtp->send($to, $headers, $body);
     
    if (PEAR::isError($mail)) 
    {
      //something went wrong
    	echo($mail->getMessage());
    } 
    else 
    {
      //OK
    	echo("Message was sent!");
    }
    
    ?>

    public by lbottaro @ Amazon_AWS_Python_API  304486  0  8  0

    Amazon S3 Aws - How to download a file from a bucket to a target directory

    This code shows how to download a file from an existing bucket invoking the boto python API, saving to a target directory. You need to specify the filename and path where to save the data. [How to create a bucket](http://www.snip2code.com/Snippet/4892/Amazon-Aws-S3---Creating-a-bucket-in-pyt) [How to upload a file to a bucket](http://www.sn
    # This downloads the object foobar.pdf and saves it in /home/luca/documents/
    
    key = bucket.get_key('foobar.pdf')
    key.get_contents_to_filename('/home/luca/documents/foobar.pdf')

    public by mporru @ Amazon_AWS_PHP_API  320917  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 fabiopagoti  194980  0  4  0

    Post: Object Services - Parte 3 - Query Service (Serviço de Consulta)

    Post: Object Services - Parte 3 - Query Service (Serviço de Consulta): Z_ABAP101_OS_QUERY
    **&---------------------------------------------------------------------*
    *& Report  Z_ABAP101_OS_PERSISTENCE
    *&
    *&---------------------------------------------------------------------*
    *& Este programa busca os horários de voos de uma dada compania area
    *& utilizando o serviço de consulta (query service)
    *& Classes Persistente:  ZCL_AIRLINE e ZCL_FLIGHT_SCHEDULE
    *& Classes Agente:       ZCA_AIRLINE e ZCA_FLIGHT_SCHEDULE
    *& Tabelas Base:         SCARR e SPFLI
    *&---------------------------------------------------------------------*
    
    REPORT  z_abap101_os_query MESSAGE-ID z_abap101_os.
    
    " Agentes
    DATA: o_airline_agent TYPE REF TO zca_airline,
          o_flight_schedule_agent TYPE REF TO zca_flight_schedule.
    
    " Objetos persistentes
    DATA: o_airline TYPE REF TO zcl_airline,
          o_flight_schedule TYPE REF TO zcl_flight_schedule.
    
    " Objects of Query Service
    DATA: o_query_manager TYPE REF TO cl_os_query_manager,
          o_query TYPE REF TO if_os_query,
          o_ref TYPE osref,
          i_o_ref TYPE osreftab.
    
    " Auxiliar for getters
    DATA: v_connid    TYPE spfli-connid,
          v_countryfr TYPE spfli-countryfr,
          v_countryto TYPE spfli-countryto.
    
    **********************************************************************
    * Selection Screen
    **********************************************************************
    SELECTION-SCREEN BEGIN OF BLOCK block_1 WITH FRAME TITLE text-001.
    
    SELECTION-SCREEN SKIP 1.
    
    SELECTION-SCREEN BEGIN OF LINE.
    
    SELECTION-SCREEN POSITION 1.
    SELECTION-SCREEN COMMENT 2(7) text-002.
    SELECTION-SCREEN POSITION 9.
    PARAMETERS: lb_airli TYPE s_carr_id AS LISTBOX VISIBLE LENGTH 25 USER-COMMAND listbox.
    SELECTION-SCREEN COMMENT 35(8) text-003. " Currency
    SELECTION-SCREEN COMMENT 44(30) v_currco.
    
    SELECTION-SCREEN END OF LINE.
    
    SELECTION-SCREEN BEGIN OF LINE.
    
    SELECTION-SCREEN COMMENT 35(8) text-004. " Website
    SELECTION-SCREEN COMMENT 44(30) v_url.
    
    SELECTION-SCREEN END OF LINE.
    
    SELECTION-SCREEN SKIP 1.
    
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 1.
    PARAMETERS: ch_inter AS CHECKBOX DEFAULT abap_true USER-COMMAND dest_internal.
    SELECTION-SCREEN COMMENT 3(8) text-005. " Internal Flights
    SELECTION-SCREEN POSITION 12.
    SELECTION-SCREEN COMMENT 13(4) v_inter. " Number of Internal Flights
    
    SELECTION-SCREEN END OF LINE.
    
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 1.
    PARAMETERS: ch_exter AS CHECKBOX DEFAULT abap_true USER-COMMAND dest_external.
    SELECTION-SCREEN COMMENT 3(8) text-006. " External Flights
    SELECTION-SCREEN POSITION 12.
    SELECTION-SCREEN COMMENT 13(4) v_exter. " Number of Internal Flights
    SELECTION-SCREEN END OF LINE.
    
    SELECTION-SCREEN END OF BLOCK block_1.
    
    
    INITIALIZATION.
      " Get Agent Instance (it uses a singleton)
      o_airline_agent = zca_airline=>agent.
    
    AT SELECTION-SCREEN.
    *  o_airline_agent = zca_airline=>agent. (Wow! Not needed!)
      TRY.
          CALL METHOD o_airline_agent->get_persistent
            EXPORTING
              i_carrid = lb_airli
            RECEIVING
              result   = o_airline.
    
          v_currco = o_airline->get_currcode( ).
          v_url = o_airline->get_url( ).
    
        CATCH cx_os_object_not_found .
    
      ENDTRY.
    
    START-OF-SELECTION.
    
      " Get Agent Instance (it uses a singleton)
      o_flight_schedule_agent = zca_flight_schedule=>agent.
      o_query_manager = cl_os_query_manager=>get_query_manager( ).
    
      TRY.
          CALL METHOD o_query_manager->if_os_query_manager~create_query
            EXPORTING
              i_filter     = `CARRID = PAR1`
    *      i_ordering   =
    *      i_parameters =
            RECEIVING
              result       = o_query
              .
        CATCH cx_os_class_not_found .
      ENDTRY.
    
      TRY.
          CALL METHOD o_flight_schedule_agent->if_os_ca_persistency~get_persistent_by_query
            EXPORTING
              i_query         = o_query
    *    i_parameter_tab =
        i_par1          = lb_airli
    *    i_par2          =
    *    i_par3          =
    *    i_subclasses    = OSCON_FALSE
    *    i_upto          = 0
            RECEIVING
              result          = i_o_ref
              .
        CATCH cx_os_object_not_found .
        CATCH cx_os_query_error .
      ENDTRY.
    
      IF i_o_ref IS INITIAL.
        MESSAGE s005. " No flights shedules match selection
      ENDIF.
    
    **********************************************************************
    * output
    **********************************************************************
    
        FORMAT COLOR 7.
        WRITE:
          AT 1 'Airline',
          AT 10 'I/E',
          AT 15 'Conn No',
          AT 25 'From',
          AT 30 'To'.
    
        NEW-LINE.
        FORMAT RESET.
    
    
      IF ch_inter = abap_true.
        WRITE: AT 1 lb_airli COLOR 1.
        WRITE: /.
    
        WRITE: AT 10 'I' COLOR 2.
        NEW-LINE.
    
        LOOP AT i_o_ref INTO o_ref.
          o_flight_schedule ?= o_ref.
    
          IF o_flight_schedule->get_countryfr( ) = o_flight_schedule->get_countryto( ).
            v_connid    = o_flight_schedule->get_connid( ).
            v_countryfr = o_flight_schedule->get_countryfr( ).
            v_countryto = o_flight_schedule->get_countryto( ).
    
            WRITE: AT 15 v_connid, AT 25 v_countryfr, AT 30 v_countryto.
            NEW-LINE.
          ENDIF.
    
        ENDLOOP.
    
    
        WRITE: AT 1(30) sy-uline, /.
    
      ENDIF.
    
      IF ch_exter = abap_true.
        WRITE: AT 1 lb_airli COLOR 1.
        WRITE: /.
    
        WRITE: AT 10 'E' COLOR 2.
        NEW-LINE.
    
        LOOP AT i_o_ref INTO o_ref.
    
          o_flight_schedule ?= o_ref.
    
          IF o_flight_schedule->get_countryfr( ) <> o_flight_schedule->get_countryto( ).
            v_connid    = o_flight_schedule->get_connid( ).
            v_countryfr = o_flight_schedule->get_countryfr( ).
            v_countryto = o_flight_schedule->get_countryto( ).
    
            WRITE: AT 15 v_connid, AT 25 v_countryfr, AT 30 v_countryto.
            NEW-LINE.
          ENDIF.
    
        ENDLOOP.
    
      ENDIF.
    
    

    public by fabiopagoti  151519  0  3  0

    Post: Object Services - Parte 2 - Persistence Service (Serviço de Persistência)

    Post: Object Services - Parte 2 - Persistence Service (Serviço de Persistência): Z_ABAP101_OS_PERSISTENCE
    **&---------------------------------------------------------------------*
    *& Report  Z_ABAP101_OS_PERSISTENCE
    *&
    *&---------------------------------------------------------------------*
    *& Este programa insere, modifica, deleta e mostra detalhes de objetos
    *& persistentes utilizando o serviço de persistencia.
    *& Classe Persistente:  ZCL_AIRLINE
    *& Classe Agente:       ZCA_AIRLINE
    *& Tabela Base:         SCARR
    *&---------------------------------------------------------------------*
    
    REPORT  z_abap101_os_persistence MESSAGE-ID z_abap101_os.
    
    DATA: o_airline_agent TYPE REF TO zca_airline,
          o_airline TYPE REF TO zcl_airline.
    
    " Used for get methods
    DATA:
      v_carrid TYPE s_carr_id,
      v_carrname TYPE s_carrname,
      v_currcode TYPE scurx-currkey,
      v_url   TYPE s_carrurl.
    
    
    SELECTION-SCREEN BEGIN OF BLOCK block_1 WITH FRAME TITLE text-001 NO INTERVALS.
    
    SELECTION-SCREEN SKIP 1.
    
    SELECTION-SCREEN BEGIN OF LINE.
    
    SELECTION-SCREEN POSITION 5.
    PARAMETERS: rb_ins RADIOBUTTON GROUP act USER-COMMAND option.
    SELECTION-SCREEN COMMENT 7(10) text-002.
    
    SELECTION-SCREEN POSITION 30.
    PARAMETERS: rb_mod RADIOBUTTON GROUP act.
    SELECTION-SCREEN COMMENT 32(10) text-003.
    
    SELECTION-SCREEN END OF LINE.
    
    SELECTION-SCREEN BEGIN OF LINE.
    
    SELECTION-SCREEN POSITION 5.
    PARAMETERS: rb_del RADIOBUTTON GROUP act.
    SELECTION-SCREEN COMMENT 7(10) text-004.
    
    SELECTION-SCREEN POSITION 30.
    PARAMETERS: rb_view RADIOBUTTON GROUP act.
    SELECTION-SCREEN COMMENT 32(10) text-005.
    
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN SKIP 1.
    
    PARAMETERS:
      p_carrid TYPE s_carr_id OBLIGATORY,
      p_carrna TYPE s_carrname,
      p_currco TYPE scurx-currkey,
      p_url   TYPE s_carrurl.
    
    SELECTION-SCREEN END OF BLOCK block_1.
    
    START-OF-SELECTION.
    
      " Get Agent Instance (it uses a singleton)
      o_airline_agent = zca_airline=>agent.
    
    **********************************************************************
    * Insert
      IF rb_ins = abap_true.
    
        TRY.
            CALL METHOD o_airline_agent->get_persistent
              EXPORTING
                i_carrid = p_carrid
              RECEIVING
                result   = o_airline.
    
            MESSAGE i000(z_abap101_os) WITH p_carrid. " Airline & already exists
    
          CATCH cx_os_object_not_found .
    
            TRY.
                CALL METHOD o_airline_agent->create_persistent
                  EXPORTING
                    i_carrid   = p_carrid
                    i_carrname = p_carrna
                    i_currcode = p_currco
                    i_url      = p_url
                  RECEIVING
                    result     = o_airline.
              CATCH cx_os_object_existing.
    
                MESSAGE i000(z_abap101_os) WITH p_carrid. " Airline & already exists
            ENDTRY.
    
            COMMIT WORK.
            MESSAGE s001(z_abap101_os) WITH p_carrid. " Airline & created successfully
    
        ENDTRY.
    
    **********************************************************************
      ELSEIF rb_mod  = abap_true. " Modify
    
        TRY.
            CALL METHOD o_airline_agent->get_persistent
              EXPORTING
                i_carrid = p_carrid
              RECEIVING
                result   = o_airline.
    
            CALL METHOD o_airline->set_carrname( i_carrname = p_carrna ).
            CALL METHOD o_airline->set_currcode( i_currcode = p_currco ).
            CALL METHOD o_airline->set_url( i_url = p_url ).
    
          CATCH cx_os_object_not_found .
            MESSAGE i002(z_abap101_os) WITH p_carrid. " Airline & created successfully
    
        ENDTRY.
    
        COMMIT WORK.
        MESSAGE s003(z_abap101_os) WITH p_carrid. " Airline & modified successfully
    
    **********************************************************************
      ELSEIF rb_del = abap_true. " Delete
    
        TRY.
            CALL METHOD o_airline_agent->delete_persistent
              EXPORTING
                i_carrid = p_carrid.
    
          CATCH cx_os_object_not_existing .
            MESSAGE i002(z_abap101_os) WITH p_carrid. " Airline & do not exists
        ENDTRY.
    
        COMMIT WORK.
        MESSAGE s004(z_abap101_os) WITH p_carrid. "  Airline & deleted successfully
    
    **********************************************************************
      ELSEIF rb_view = abap_true. " View
    
        TRY.
            CALL METHOD o_airline_agent->get_persistent
              EXPORTING
                i_carrid = p_carrid
              RECEIVING
                result   = o_airline.
    
            v_carrid = o_airline->get_carrid( ).
            v_carrname = o_airline->get_carrname( ).
            v_currcode = o_airline->get_currcode( ).
            v_url = o_airline->get_url( ).
    
            WRITE:
            AT 5 'CARRID', AT 15 v_carrid.
    
            NEW-LINE.
            WRITE:
            AT 5 'CARRNAME', AT 15 v_carrname.
            NEW-LINE.
    
            WRITE:
            AT 5 'CURRCODE', AT 15 v_currcode.
            NEW-LINE.
    
            WRITE:
            AT 5 'URL', AT 15 v_url.
            NEW-LINE.
    
          CATCH cx_os_object_not_found .
            MESSAGE i002(z_abap101_os) WITH p_carrid. " Airline & do not exists
        ENDTRY.
    
      ENDIF.
    
    

    public by merqlove  207905  2  4  2

    AngularJS / NodeWebkit logger service.

    AngularJS / NodeWebkit logger service.: logger.coffee
    'use strict';
    
    angular.module('vc.messages')
    .factory "logger", ['$log', 'NwService', ($log, NwService) ->
      log4js = require('log4js')
    
      log4js.configure {
        appenders: [
          {
            type: 'console'
            layout: {
              type: 'pattern'
              pattern: "%m%n"
            }
            category: 'console'
          },
          {
            type: 'file'
            absolute: true
            filename: NwService.dataPath() + '/app.log'
            category: 'file'
            maxLogSize: 1024*1024
            numBackups: 3
            layout: {
              type: 'pattern'
              pattern: "[%d %r] [%p] - %m%n"
            }
          },
        ]
        levels: {
          "[all]": "INFO",
          "console": NwService.isProduction() ? "OFF" : "DEBUG",
          "file": "ERROR"
        }
      }
    
      consoleLogger = log4js.getLogger('console')
    
      ['Trace','Debug','Info','Warn','Error','Fatal'].forEach (levelString) ->
        level = log4js.levels.toLevel(levelString)
    
        consoleLogger[levelString.toLowerCase()] = () ->
          return false unless consoleLogger.isLevelEnabled(level)
          args = Array.prototype.slice.call(arguments)
          switch levelString
            when 'Info', 'Warn'
              $log[levelString.toLowerCase()](args)
            else
              args.unshift(level)
              consoleLogger.log.apply(consoleLogger, args)
    
      return {
        file: log4js.getLogger('file')
        console: consoleLogger
      }
    ]
    
    

    public by mporru @ Amazon_AWS_PHP_API  210401  0  5  0

    Amazon AWS - PHP: Upload a File taking it from your server

    This snippet demonstrates how to upload a file to a S3 Bucket, taking it form a your server. In order to use this service you must enable Amazon Simple Storage Service (Amazon S3) in your account. Taken from: http://www.sitepoint.com/getting-started-with-the-aws-php-sdk/
    <?php
    require_once 'sdk.class.php';
    $s3 = new AmazonS3();
    // Create Object is pretty self explanatory:
    // Arg 1: The bucket where your file will be created.
    // Arg 2: The name of your file.
    // Arg 3: An array of Options.
    //        In this case we're specifying the &quot;fileUpload&quot; option (a file on your server)
    //        and the ACL setting to allow this file to be read by anyone.
    $response=$s3->create_object('myBucketName', 'LighthouseNew.jpg', 
    array('fileUpload'=>'./Lighthouse.jpg', 'acl'=>AmazonS3::ACL_PUBLIC));
    // Check if everything is okay.
    if ($response->isOK()) {
    	echo("File uploaded correctly");
    } else {
    	echo("There was an error uploading the file!");
    }
    ?>

    public by hardware  127568  0  3  0

    Prewikka.service file

    Prewikka.service file: prewikka.service
    [Unit]
    Description=Prewikka
    After=network.target
    
    [Service]
    Type=simple
    ExecStart=/usr/bin/prewikka-httpd
    
    Restart=always
    TimeoutStopSec=10s
    TimeoutStartSec=5s
    StartLimitInterval=120s
    StartLimitBurst=5
    
    [Install]
    WantedBy=multi-user.target
    
    
    • Public Snippets
    • Channels Snippets