working on it ...

Filters

Explore Public Snippets

Sort by

Found 16k snippets matching: api

    public by fabio.nosenzo @ Amazon_AWS_Python_API modified Aug 1, 2013  587970  4  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 sTiLL-iLL @ SniPitz-KND modified Dec 15, 2014  444394  3  8  24

    Signals.js... A fast and efficient event system in javascript.

    Signals.js... A fast and efficient event system in javascript.: Signals.js
    // Signalz.js
    
    var Signals = (function () {
    	'use strict';
    	var sigCache = {},
    	addReceiver = function(eventName, func) {
    		return wen(eventName, function(evnt){
    			return func(evnt);
    		});
    	},
    	signalReceived = function(eventName, func) {
    		return wen(eventName, function(evnt){
    			return func(evnt);
    		});
    	},
    	dropReceivers = function (eventName) {
    		if (!eventName) {
    			sigCache = {};
    			return this;
    		}
    		if (sigCache && sigCache[eventName]) {
    			sigCache[eventName] = null;
    		}
    		return this;
    	},    
    	signalOnce = function (eventName, func) {
    		var slf = this;
    		setSingleRV(true);
    		function onit () {
    			dropReceiver(eventName, wen);
    			func.apply(this, arguments);
    		};
    		wen.receiver = onit;	
    		return this;
    	},
    	dropReceiver = function (eventName, func) {
    		if (sigCache && sigCache[eventName]) {
    			var sigLst = sigCache[eventName];	
    			if (isAry(sigLst)) {
    				var idx = -1;
    				for (var i = 0, l = sigLst.length; i < l; i++) {
    					if (sigLst[i] === func || (sigLst[i].receiver && sigLst[i].receiver === func)) {
    						idx = i;
    						break;
    					}
    				}
    				if (idx < 0) {
    					return this;
    				}
    				sigLst.splice(idx, 1);
    				if (!sigLst.length) {
    					delete sigCache[eventName];
    				}
    			} 
    			else if (sigLst === func || (sigLst.receiver && sigLst.receiver === func)) {
    				delete sigCache[eventName];
    			}
    		}
    		return this;
    	},  
    	setSingleRV = function (val) {
    		singleRtnVal = val;
    		return this;
    	},  
    	getSingleRV = function() {
    		if (receivers.hasOwnProperty('singleRtnVal')) {
    			return singleRtnVal;
    		}
    		else {
    			return true;
    		}
    	},	 
    	castSignal = function(eventName, args) {
    		var recvrLst = receiverObjects(eventName),
    		k, recvr, i, rspns;
    		for (k in recvrLst ) {
    			if (recvrLst.hasOwnProperty(k)) {
    				i = recvrLst[k].length;		
    				while (i--) {
    					recvr = recvrLst[k][i];
    					if (recvr.signalOnce === true) {
    						dropReceiver(eventName, recvr);
    					}	
    					rspns = recvr.call(this, args || []);
    					if (rspns === getSingleRV()) {
    						dropReceiver(eventName, recvr);
    					}
    				}
    			}
    		}
    	 	return this;
      	};
    	function isAry(obj) {
    		return (obj.constructor === Array);
    	};
    	function receiverObjects(eventName) {
    		var recvrLst = receivers(eventName), rspns;	
    		if (isAry(recvrLst)) {
    			rspns = {};
    			rspns[eventName] = recvrLst;
    		}	
    		return rspns || recvrLst;
    	};
    	function receivers(eventName) {
    		if (!sigCache) {
    			sigCache = {};
    		}
    		if (!sigCache[eventName]) {
    			sigCache[eventName] = [];
    		}
    		if (!isAry(sigCache[eventName])) {
    			sigCache[eventName] = [sigCache[eventName]];
    		}
    		return sigCache[eventName];
    	};
    	function wen(eventName, func) {
    		if (!sigCache) {
    			sigCache = {};
    		}
    		if (!sigCache[eventName]) {
    			sigCache[eventName] = func;
    		} 
    		else if (isArry(sigCache[eventName])) {
    			sigCache[eventName].push(func);
    		} 
    		else {
    			sigCache[eventName] = [sigCache[eventName], func];
    		}	
    		return;
    	};
    	return {
    		signal: castSignal,
    		signaled: signalReceived,
    		receive: addReceiver,
    		receiveOnce: signalOnce,
    		signaledOnce: signalOnce,
    		dropReceiver: dropReceiver,
    		assignReceiver: addReceiver,
    		receivers: receivers,
    		dropReceivers: dropReceivers
    	};
    }());
    
    exports.Signals = Signals;
    
    
                

    public by clsw modified Nov 21, 2014  349959  0  6  1

    Image upload to API, return direct link. (IMGUR)

    Imgur, one of the best image hosts in the world, has a fantastic API, this is a VERY simple and usable implementation of it, just pass an image to the function and it will return the direct link to yout image, heavily commented and easy to use.
    public string UploadImage(Image img)
            {
                //get a dev key from api.imgur.com, anonymous usage (no user auth) only.
                string devkey = "YOUR_CLIENT_ID (e.g. abcde1f234567g8)";
    
                //define the WebClient we'll use to communicate with Imgur.
                WebClient w = new WebClient();
                
                //adds the Header to authorize this application with Imgur, must include a valid CLIENT_ID from 'devkey' above.
                w.Headers.Add("Authorization", "Client-ID " + devkey);
    
                System.Collections.Specialized.NameValueCollection Keys = new System.Collections.Specialized.NameValueCollection();
                try
                {
                    //Converts the image to a byte array so it can be turned into a string for upload.
                    using (MemoryStream stream = new MemoryStream())
                    {
                        img.Save(stream, ImageFormat.Png);
                        Keys.Add("image", Convert.ToBase64String(stream.ToArray()));
                    }
                    
                    //uploads the string-formatted-image and waits for the response.
                    byte[] responseArray = w.UploadValues("https://api.imgur.com/3/image", Keys);
                    dynamic result = Encoding.ASCII.GetString(responseArray);
    
                    //formats the (long and technical) result into just the direct image link.
                    Regex reg = new Regex("link\":\"(.*?)\""); Match match = reg.Match(result);
                    string url = match.ToString().Replace("link\":\"", "").Replace("\"", "").Replace("\\/", "/");
    
                    //returns the online address of the image.
                    return url;
                }
                catch (Exception s) { MessageBox.Show(s.Message); return "err"; }
            }

    public by jbaro modified Oct 25, 2016  332763  9  2  0

    Google maps customized

    Load a google map customized
    /*********
    lat: latitude
    lng:longitude
    elid: id of container
    iconpath: path to marker icon if necesary
    style: styles json
    ***********/
    
    
    function initMap(lat,lng,elid,iconpath,style) {
    
    	// Create an array of styles.
    	var styles = style;
    	// Create a new StyledMapType object, passing it the array of styles,
    	// as well as the name to be displayed on the map type control.
    	var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"});
    	// Create a map object, and include the MapTypeId to add
    	// to the map type control.
    	var myLatLng = new google.maps.LatLng(lat,lng);
    	var mapOptions = {
    		zoom: 11,
    		center: myLatLng,
    		mapTypeControlOptions: {
    			mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style']
    		}
    	};
    	var map = new google.maps.Map(document.getElementById(elid),mapOptions);
    	if(iconpath){
    		var marker = new google.maps.Marker({
    		  position: myLatLng,
    		  map: map,
    		  icon: iconpath
    		});
    	}
    	//Associate the styled map with the MapTypeId and set it to display.
    	map.mapTypes.set('map_style', styledMap);
    	map.setMapTypeId('map_style');
    }
    
    //silver styles example
    var mapsbw = [
    		{
    		  "elementType": "geometry",
    		  "stylers": [
    			{
    			  "color": "#f5f5f5"
    			}
    		  ]
    		},
    		{
    		  "elementType": "labels.icon",
    		  "stylers": [
    			{
    			  "visibility": "off"
    			}
    		  ]
    		},
    		{
    		  "elementType": "labels.text.fill",
    		  "stylers": [
    			{
    			  "color": "#616161"
    			}
    		  ]
    		},
    		{
    		  "elementType": "labels.text.stroke",
    		  "stylers": [
    			{
    			  "color": "#f5f5f5"
    			}
    		  ]
    		},
    		{
    		  "featureType": "administrative.land_parcel",
    		  "elementType": "labels.text.fill",
    		  "stylers": [
    			{
    			  "color": "#bdbdbd"
    			}
    		  ]
    		},
    		{
    		  "featureType": "poi",
    		  "elementType": "geometry",
    		  "stylers": [
    			{
    			  "color": "#eeeeee"
    			}
    		  ]
    		},
    		{
    		  "featureType": "poi",
    		  "elementType": "labels.text.fill",
    		  "stylers": [
    			{
    			  "color": "#757575"
    			}
    		  ]
    		},
    		{
    		  "featureType": "poi.park",
    		  "elementType": "geometry",
    		  "stylers": [
    			{
    			  "color": "#e5e5e5"
    			}
    		  ]
    		},
    		{
    		  "featureType": "poi.park",
    		  "elementType": "labels.text.fill",
    		  "stylers": [
    			{
    			  "color": "#9e9e9e"
    			}
    		  ]
    		},
    		{
    		  "featureType": "road",
    		  "elementType": "geometry",
    		  "stylers": [
    			{
    			  "color": "#ffffff"
    			}
    		  ]
    		},
    		{
    		  "featureType": "road.arterial",
    		  "elementType": "labels.text.fill",
    		  "stylers": [
    			{
    			  "color": "#757575"
    			}
    		  ]
    		},
    		{
    		  "featureType": "road.highway",
    		  "elementType": "geometry",
    		  "stylers": [
    			{
    			  "color": "#dadada"
    			}
    		  ]
    		},
    		{
    		  "featureType": "road.highway",
    		  "elementType": "labels.text.fill",
    		  "stylers": [
    			{
    			  "color": "#616161"
    			}
    		  ]
    		},
    		{
    		  "featureType": "road.local",
    		  "elementType": "labels.text.fill",
    		  "stylers": [
    			{
    			  "color": "#9e9e9e"
    			}
    		  ]
    		},
    		{
    		  "featureType": "transit.line",
    		  "elementType": "geometry",
    		  "stylers": [
    			{
    			  "color": "#e5e5e5"
    			}
    		  ]
    		},
    		{
    		  "featureType": "transit.station",
    		  "elementType": "geometry",
    		  "stylers": [
    			{
    			  "color": "#eeeeee"
    			}
    		  ]
    		},
    		{
    		  "featureType": "water",
    		  "elementType": "geometry",
    		  "stylers": [
    			{
    			  "color": "#c9c9c9"
    			}
    		  ]
    		},
    		{
    		  "featureType": "water",
    		  "elementType": "labels.text.fill",
    		  "stylers": [
    			{
    			  "color": "#9e9e9e"
    			}
    		  ]
    		}
    	  ];
    //init example
    initMap(42.8107705, -1.6616108,'map','./img/gm_marker.png',mapsbw);

    public by lbottaro @ Amazon_AWS_Python_API modified Aug 1, 2013  304260  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 MoonDevilzzz modified Feb 24, 2015  263768  1  6  0

    Bitrix Api CIBlockElement::GetList

    Bitrix Api CIBlockElement::GetList
    <?
    $arSelect = Array("ID", "IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM","PROPERTY_*");//IBLOCK_ID и ID обязательно должны быть указаны, см. описание arSelectFields выше
    $arFilter = Array("IBLOCK_ID"=>IntVal($yvalue), "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y");
    $res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>50), $arSelect);
    while($ob = $res->GetNextElement()){ 
     $arFields = $ob->GetFields();  
    print_r($arFields);
     $arProps = $ob->GetProperties();
    print_r($arProps);
    }
    ?>

    public by kanta modified Aug 30, 2014  246667  3  5  0

    API SMS KDEV invio da VB6

    Invio tramite POST HTTO al gateway SMS KDEV
    vb
    Function URLEncode(ByVal Text As String) As String
    
    	Dim i As Integer
    	Dim acode As Integer
    	Dim chr As String
    	Dim hexValue As String
    	Dim finalString As String
    
    	finalString = ""
    
    	For i = 1 To Len(Text) Step 1
    		acode = Asc(Mid$(Text, i, 1))
    		Select Case acode
    			Case 48 To 57, 65 To 90, 97 To 122
    				' don't touch alphanumeric chars
    				finalString = finalString & Mid$(Text, i, 1)
    			Case 32
    				' replace space with "+"
    				'Mid$(Text, i, 1) = "+"
    				finalString = finalString & "+"
    			Case Else
    				hexValue = Hex$(acode)
    				Select Case Len(hexValue)
    					Case 1
    						hexValue = "0" & hexValue
    					Case 2
    						'ok
    					Case Else
    						'carattere non valido
    						'skip
    						hexValue = ""
    				End Select
    				
    				' replace punctuation chars with "%hex"
    				finalString = finalString & "%" & hexValue
    
    
    		End Select
    	Next
    	Return finalString
    End Function
    
    
    Function SendSMS(username As String, password As String, recipients() As String, Text As String, Optional charset As String = "") As String
    	Dim sender_error, url, method, parameters, msg As String
    
    	Dim xmlhttp As Object
    	xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
    
    
    	url = "https://www.smskdev.it/send.php"
    
    
    	parameters = "username=" & URLEncode(username) & "&" _
    				 & "password=" & URLEncode(password) & "&" _
    				 & "text=" & URLEncode(Text) & "&" _
    				 & "to=" & Join(recipients, "&recipients[]=")
    
    
    
    	Select Case charset
    		Case "UTF-8"
    			parameters = parameters & "&charset=UTF-8"
    		Case Else
    	End Select
    
    
    
    	xmlhttp.open("POST", url, False)
    	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    	xmlhttp.setRequestHeader("Content-Length", Len(parameters))
    	xmlhttp.Send(parameters)
    
    	If xmlhttp.Status >= 400 And xmlhttp.Status <= 599 Then
    		SendSMS = "status=failed&message=" & xmlhttp.Status & " - " & xmlhttp.statusText
    		Exit Function
    	End If
    
    	
    	msg = xmlhttp.responseText
    	xmlhttp = Nothing
    
    	SendSMS = msg
    
    End Function
    
    Function GetCredit(username As String, password As String, Optional charset As String = "") As String
    	Dim url, method, parameters, msg As String
    	Dim xmlhttp As Object
    	xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
    
    	url = "https://www.smskdev.it/credit.php"
    
    
    	parameters = "username=" & URLEncode(username) & "&" _
    				 & "password=" & URLEncode(password)
    
    xmlhttp.open("POST", url, False)
    	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    	xmlhttp.setRequestHeader("Content-Length", Len(parameters))
    	xmlhttp.Send(parameters)
    
    	If xmlhttp.Status >= 400 And xmlhttp.Status <= 599 Then
    		GetCredit = "status=failed&message=" & xmlhttp.Status & " - " & xmlhttp.statusText
    		Exit Function
    	End If
    
    	msg = xmlhttp.responseText
    	xmlhttp = Nothing
    
    	GetCredit = msg
    
    End Function
    
    
    Private Sub Form_Load()
    
    	Dim recipients(0) As String
    	Dim i As Integer
    
    	' Invio singolo
    	recipients(0) = "39XXXXXXXXX"
    
    	' Per invio multiplo
    	' recipients(0) = "39XXXXXXXXX1"
    	' recipients(1) = "39XXXXXXXXX2"
    
    	' ------------ Invio SMS --------------
    
    	Dim result As String
    	result = SendSMS("username","password",recipients,"TESTO DEL MESSAGGIO","")
    
    	
    	' ------------ LETTURA DEL CREDITO UTENTE -------------
    	' result = GetCredit("username", "password")
    
    
    	Dim responses As String()
    	responses = Split(result, "&")
    	Dim Response As String = ""
    	For Each Item In responses
    		Response = Response & Item & vbCrLf
    	Next
    	MsgBox(Response, vbOKOnly + vbInformation, "Result")
    	
    End Sub					

    public by johansonkatherine modified May 8, 2014  219636  1  6  2

    C# Code Sample to Replace Multiple Texts inside PDF File Using Cloud API

    The following code sample shows how developers can replace multiple texts in a single API call in a PDF file using Aspose.Pdf for Cloud API in their applications. Developers can use Aspose REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.
    AsposeApp.AppSID  = "77***********************************";
    AsposeApp.AppKey = "9a*******************************";
    
    //build URI
    stringstrURI = "http://api.aspose.com/v1.1/pdf/test.pdf/replaceTextList";
    
    //sign URI
    stringsignedURI = Utils.Sign(strURI);
    
    //build JSON to post
    TextReplace textReplace1 = new TextReplace();
    textReplace1.OldValue = "[!firm!]";
    textReplace1.NewValue = "Aspose";
    textReplace1.Regex = "false";
    
    //build JSON to post
    TextReplace textReplace2 = new TextReplace();
    textReplace2.OldValue = "[!client!]";
    textReplace2.NewValue = "Mark";
    textReplace2.Regex = "false";
    
    MultipleTextReplacestextReplaces = new MultipleTextReplaces();
    textReplaces.TextReplaces = new TextReplace[] { textReplace1, textReplace2 };
    stringstrJSON = JsonConvert.SerializeObject(textReplaces);
    Console.Write(strJSON);
    Utils.ProcessCommand(signedURI, "POST", strJSON);
    
    //build URI
    strURI = "http://api.aspose.com/v1.1/storage/file/test.pdf";
    
    //sign URI
    signedURI = Utils.Sign(strURI);
    
    Stream responseStream = Utils.ProcessCommand(signedURI, "GET");
    using (Stream fileStream = System.IO.File.OpenWrite(@"test.pdf"))
    {
    Utils.CopyStream(responseStream, fileStream);
    }
    responseStream.Close();
    
    //Following are required classes
    public class MultipleTextReplaces
        {
    publicTextReplace[] TextReplaces { get; set; }
        }
    public class TextReplace
        {
    publicTextReplace() { }
    
    public string OldValue { get; set; }
    public string NewValue { get; set; }
    public string Regex { get; set; }
    
        }
    

    public by cghersi @ MailUp API DEV modified Jan 20, 2015  206772  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 christopher modified May 8, 2014  206413  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 Snippets
    • Channels Snippets