working on it ...

Filters

Explore Public Snippets

Sort by

Found 190 snippets

    public by AlexS modified Apr 21, 2017  582  7  4  0

    esp

    public OperationResult UploadRelease(Release release, byte[] resourceBytes, string cookieid)
    {
        ESPUploadSites uploadsite = ESPUploadSites.USWest;
        ESPBatch batch = lastbatch;
        OperationError error = null;
        OperationResult opresult = null;
        int partno = 1;
        string csrftoken = "";
        string fname = GetESPReleaseFileName(release.Name);
        string time = Tools.GetJavaScriptTime(DateTime.Now).ToString();
        string date = "";
        string auth = "";
        string uploadid = "";
        string data = "";
        string rid = "";
        TimeSpan zero1 = TimeSpan.Zero;
        List<string> etags = new List<string>();
        HTTPRequest r = GetMainPageRequest(cookieid);
        opresult = AuthenticatedRequest(r, Authorize, CheckAuthNotLost, null);
        if (!opresult.Success)
            return opresult;
        if (!ParseMainPage(r, ref csrftoken, ref error))
            return new OperationResult(error);
        r = GetReleaseUploadInitRequest(batch.ID, time, fname, uploadsite, cookieid);
        HTTPRequestResult result = HTTP.ExecSync(r);
        if (result != HTTPRequestResult.Success)
            return new OperationResult(result, r, StockId);
        if (!ParseReleaseUploadInitResponse(r, ref date, ref auth, ref error))
            return new OperationResult(error);
        r = GetReleaseUploadStartOptionsRequest(batch.ID, time, fname, uploadsite, cookieid);
        result = HTTP.ExecSync(r);
        if (result != HTTPRequestResult.Success)
            return new OperationResult(result, r, StockId);
        if (!CheckReleaseUploadStartOptionsResponse(r, ref error))
            return new OperationResult(error);
        r = GetReleaseUploadStartRequest(batch.ID, time, fname, uploadsite, date, auth, cookieid);
        result = HTTP.ExecSync(r);
        if (result != HTTPRequestResult.Success)
            return new OperationResult(result, r, StockId);
        if (!ParseReleaseUploadStartRequest(r, ref uploadid, ref error))
            return new OperationResult(error);
    
        long length = resourceBytes.Length;
        string chunkhash = Tools.GetSHA256(resourceBytes);
        TimeSpan zero2 = TimeSpan.Zero;
        r = GetReleaseUploadChunkInitRequest(batch.ID, time, fname, chunkhash, partno, uploadid, uploadsite, cookieid);
        result = HTTP.ExecSync(r);
        if (result != HTTPRequestResult.Success)
            return new OperationResult(result, r, StockId);
        if (!ParseReleaseUploadChunkInitResponse(r, ref date, ref auth, ref error))
            return new OperationResult(error);
        r = GetReleaseUploadChunkOptionsRequest(batch.ID, time, fname, uploadid, partno, uploadsite, cookieid);
        result = HTTP.ExecSync(r);
        if (result != HTTPRequestResult.Success)
            return new OperationResult(result, r, StockId);
        if (!CheckReleaseUploadChunkOptionsResponse(r, ref error))
            return new OperationResult(error);
        r = GetReleaseUploadChunkRequest(batch.ID, time, fname, uploadid, partno, uploadsite, resourceBytes, chunkhash, date, auth, cookieid);
        //Is long
        result = HTTP.ExecSync(r);
        if (result != HTTPRequestResult.Success)
            return new OperationResult(result, r, StockId);
        if (!CheckReleaseUploadChunkResponse(r, ref error))
            return new OperationResult(error);
        r = GetReleaseUploadChunksListInitRequest(batch.ID, time, fname, uploadid, uploadsite, cookieid);
        result = HTTP.ExecSync(r);
        if (result != HTTPRequestResult.Success)
            return new OperationResult(result, r, StockId);
        if (!ParseReleaseUploadChunksListInitResponse(r, ref date, ref auth, ref error))
            return new OperationResult(error);
        r = GetReleaseUploadChunksListOptionsRequest(batch.ID, time, fname, uploadid, uploadsite, cookieid);
        result = HTTP.ExecSync(r);
        if (result != HTTPRequestResult.Success)
            return new OperationResult(result, r, StockId);
        if (!CheckUploadChunkOptionsResponse(r, ref error))
            return new OperationResult(error);
        r = GetReleaseUploadChunksListRequest(batch.ID, time, fname, uploadid, uploadsite, date, auth, cookieid);
        result = HTTP.ExecSync(r);
        if (result != HTTPRequestResult.Success)
            return new OperationResult(result, r, StockId);
        if (!ParseReleaseUploadChunksListResponse(r, etags, ref error))
            return new OperationResult(error);
        data = GetUploadCompleteData(etags.ToArray());
        chunkhash = Tools.GetSHA256(Encoding.ASCII.GetBytes(data));
        r = GetReleaseUploadCompleteInitRequest(batch.ID, time, fname, uploadid, uploadsite, chunkhash, cookieid);
        result = HTTP.ExecSync(r);
        if (result != HTTPRequestResult.Success)
            return new OperationResult(result, r, StockId);
        if (!ParseReleaseUploadCompleteInitResponse(r, ref date, ref auth, ref error))
            return new OperationResult(error);
        r = GetReleaseUploadCompleteRequest(batch.ID, time, fname, uploadid, uploadsite, date, auth, data, chunkhash, cookieid);
        result = HTTP.ExecSync(r);
        if (result != HTTPRequestResult.Success)
            return new OperationResult(result, r, StockId);
        if (!CheckReleaseUploadCompleteResponse(r, batch.ID, time, fname, ref error))
            return new OperationResult(error);
        r = GetReleaseCreateRequest(batch, release, time, fname, csrftoken, cookieid);
        result = HTTP.ExecSync(r);
        return result == HTTPRequestResult.Success ? (ParseReleaseCreateResponse(r, release, ref rid, ref error) ? new OperationResult(false) : new OperationResult(error)) : new OperationResult(result, r, StockId);
    }
    
    

    public by lauhin modified Mar 24, 2016  4592  1  5  0

    Interator to stream in Java 8

    makes a java 8 stream from an iterator
    //this method converts a iterator to a stream. This can only be used in Java 8
    public static <T> Stream<T> iteratorToStream(final Iterator<T> iterator, final boolean parallell) {
      Iterable<T> iterable = () -> iterator;
      return StreamSupport.stream(iterable.spliterator(), parallell);
    }
    
    //here I show you how to use this method. You need this try arround it so Java will close the stream automatically after using it.
    try (Stream<???> stream = Utils.<???>iteratorToStream(anIterator, true)) {
      
    }

    public by wtfsnottaken modified Feb 13, 2016  2572  0  4  0

    hoeyo

    // Enter here 
    ///  MY "SIGNALS" EVENT SYSTEM ////////////////
    
    //   this solution Uses my signals.js module
    
    ////////  styles  ///////////
    
    
    body {
    	font-family: Calibri;
    	width: 220px;
    }
    
    .container {
        border: 1px solid black;
        padding: 10px;
        width: 232px;
        margin: 50px auto 50px 350px;
    	border-radius: 7px;
    	background: lightgray;
    }
    
    fieldset {
    	width: 205px;
    	margin: 0 auto 3px 3px;
    	margin-right: auto;
    	margin-bottom: 6px;
    	padding: 10px;
    }
    
    h1 {
    	margin-left: 55px;
    	margin-right: auto;
    }
    
    span {
    	margin: 3px;
    }
    
    input {
    	margin-top: 2px;
    	margin-bottom: 8px;
    	width: 168px;
    	padding-left: 3px;
    }
    
    ul {
    	padding-left: 20px;
    	list-style: none;
    	color: navy;
    	overflow-x: hidden;
    }
    
    li {
    	max-width: 180px
    }
    
    
    
    /////////  Model(s)   ////////////////////////
    
    // this is the user model object
    
    var user1 = {
        name1: "Richard",
        name2: "Longwood",
        occupation: "Software Engineer",
        age: "40",
        title: 'Skillz Yo!',
        subTitle: "add a skill...",
        showSkills: true,
        skills: []
    };
    
    
    
    function UserModel (usr) {
        this.user = usr;
        this.get = function(k) {
            if (k) {
                var u = this.user;
                return u[k];
            } 
            else {
                var u = this.user;
                return u;
            }
        };
    };
    
    
    
    var User = new UserModel (user1);
    User.prototype = Signals;
    User.constructor = User;
    
    User.on = function(v, cbk) {
        this.prototype.receive(v, function(d) {
            cbk.call(this.user, d);
        });
    };
    User.emit = function(v) {
        this.prototype.signal("change", v);
    };
    User.off = function(v) {
        this.prototype.dropReceivers(v);
    };
    User.set = function(k, v) {
        if (v && v !== this.user[k]) {
            if (k == "skills") {
                this.user[k].push(v);
            } else {
                this.user[k] = v;
            }
            this.prototype.signal("change", this.user);
        }
    };
    
    
    
    // array for template strings, 
    // our template engine, and an array of target Ids.
    
    var kList = [], 
        TPE = new TPEngine(), 
        Nodz = ["t1", "t2", "t3", "t4", "t5", "t6"];
    
    
    
    // this template string is pretty bulky, 
    // so Ill keep it stashed as a string, 
    // then inject it into its target when its time.
    
    var template6 = '~>{ if(User.get("showSkills")) { :}' + 
            '~>{ for(var index in User.get("skills")) { :}' + 
            '<li><a href="#"> ~>{ User.get("skills")[index] :}' + 
            '</a></li> ~>{ } :}' + '~>{ } else { :}' + 
            '<li>none</li>' + '~>{ } :}';
    
    
    
    // this array holds the template strings.
    // the innerText is where I extract them from the mark-up
    // notice how #5 is already defined
    
    var Templates = [
        template1 = t1.innerText, 
        template2 = t2.innerText, 
        template3 = t3.innerText, 
        template4 = t4.innerText,
        template5 = t5.innerText, 
        template6
    ];
    
    
    // Now I iterate over the list of nodes and templates,
    // pull each one out per the array position and plug
    // them into the kompiler along with the property of the node that 
    // the content is assigned to, then komile into a "kPlate" template.
    // each one of these kPlates is then put into another array: "kList"
    
    Nodz.forEach(function(tmpltNd) {
        var seed = Templates.shift();
        kPlt = TPE.Template(tmpltNd, "innerHTML", seed);
        kList.push(kPlt);
    });
    
    
    
    // Here, we set up the 2-way bindings
    
    var bb = document.getElementById("btn"), 
        tgl = document.getElementById("tgl"),
        updateDom = function (d) {
            kList.forEach(function(itm) {
                TPE.BindSet(itm, d);
            });
        },
        updateModel = function (d) {
            User.set("skills", tgl.value);
            tgl.value = "";
        };
    
    
    // When the button is pressed, this handler
    // in the controller hears it, grabs the new value
    // and updates the model.
    
    bb.addEventListener("click", updateModel);
    
    
    // When the model's value is changed, it fires a change event.
    // The handler here in the controller hears it,
    // grabs the new value, and then updates the dom
     
    User.on("change", updateDom);
    
    
    // This part basicly is what runs on window ready.
    // Now that everything is all set up..
    // we iterate over the array of kPlates that we stored earlier,
    // calling BindSet on each one. This renders the mark-up
    // to the dom at lightening speed, and there ya go!
    
    kList.forEach(function(itm) {
        TPE.BindSet(itm, User);
    });
    
    
    
    
    
    
    //////////// Template kompiler (controller)  //////////////////////////////////////
    
    this.TPEngine = function() {
        var kompiler = function(templateString, model) {
            var rgx = /~>{([^:]+)?:}/g, 
            rgex = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g, 
            segment = 'var r=[];\n', position = 0, 
            kompile = function(chunk, ixjs) {
                ixjs ? (segment += chunk.match(rgex) ? chunk + '\n' : 'r.push(' + chunk + ');\n') : 
                (segment += chunk != '' ? 'r.push("' + chunk.replace(/"/g, '\\"') + '");\n' : '');
                return kompile;
            };
            while (match = rgx.exec(templateString)) {
                kompile(templateString.slice(position, match.index))(match[1], true);
                position = (match.index + match[0].length);
            }
            ;
            kompile(templateString.substr(position, templateString.length - position));
            segment += 'return r.join("");';
            return new Function(segment.replace(/[\r\t\n]/g, '')).apply(model);
        }, 
        template = function(elementID, prop, templateString) {
            var c = {
                tStr: templateString,
                tProp: prop,
                tVal: document.getElementById(elementID)
            };
            return c;
        }, 
        applyBind = function(temp, model) {
            if (temp.tVal.id && temp.tStr && model) {
                template = temp;
                var el = document.getElementById(template.tVal.id);
                el[template.tProp] = kompiler(template.tStr, model);
                template.tVal = el;
            }
        };
        return {
            Template: template,
            BindSet: applyBind
        };
    };
    
    
    ///////// VIEW  //////////////////////////
    
    <!DOCTYPE html>
    <html>
    <head>
    	<title>MY MVC</title>
    </head>
      	<meta charset="utf-8" />
    	<link rel="stylesheet" href="css/stylz.css" />
    	<script src="js/signals.js"></script>
    	<script src="js/myTPlates.js"></script>
    <body>
    	<div class="container">
    		<h1 id="t1">
    			~>{ User.get("title") :} 
    		</h1>
    		<fieldset>
    			<legend id="t2">
    				~>{ User.get("subTitle") :}
    			</legend>
    			<input id="tgl" type="text" placeholder="skills"></input>
            	<button id="btn">+</button>
    			<hr><b>
    			  Name:
    			  <span id="t3">
    					~>{ User.get("name1") +" "+ User.get("name2") :}
    			  </span>
    			  </br>
    			  Age: 
    			  <span id="t4">
    					~>{ User.get("age") :}
    			 </span>
    			 </br>
    			  Dept: 
    			  <span id="t5">
    					~>{ User.get("occupation") :}
    			 </span>
    			 <hr>
    			  Skills List: 
    			 <ul id="t6">
    					~>{ User.get("skills") :}
    			 </ul></b>	
    			<hr>
    		</fieldset>
    	</div>
    </body>
    <script src="js/script1.js"></script>
    </html>
    
    
                                                                                                                 actual content of the snippet.            

    public by sherazkhan modified Nov 18, 2015  1827  0  7  0

    How to Reads Outlook PST File & Displays Folder or Message Information in Android Apps

    This technical tip shows how to get the messages information from the Outlook PST file and display it inside .NET Applications. Previously we have discussed how to load an Outlook PST file and browse through its folders to get folder names and the number of messages in each folder. This topic explains how to read all the folders and subfolders in
    public void RetrievePSTFolderContents()
        {
            String strBaseFolder = Environment.getExternalStorageDirectory().getPath() + "/";                
            String pstFileName = strBaseFolder + "Outlook.pst";
    
            try
            {
                // Load the Outlook PST file
                PersonalStorage pst = PersonalStorage.fromFile(pstFileName);
    
                // Get the root folder
                FolderInfo folderInfo = pst.getRootFolder();
    
                // Call the recursive method to display the folder contents
                DisplayFolderContents(folderInfo, pst);
            }
            catch (Exception ex)
            {
                tx.setText(ex.getMessage());
            }
        }
    
        private static void DisplayFolderContents(FolderInfo folderInfo, PersonalStorage pst)
        {        // Display the folder name
            tx.setText(tx.getText() + "\n Folder: " + folderInfo.getDisplayName());
            // Display information about messages inside this folder
            MessageInfoCollection messageInfoCollection = folderInfo.getContents();
            for (int i = 0; i < messageInfoCollection.size(); i++)
            {
                MessageInfo messageInfo = (MessageInfo) messageInfoCollection.get(i);
                tx.setText(tx.getText() + "\n Subject: " + messageInfo.getSubject());
                tx.setText(tx.getText() + "\n Sender: " + messageInfo.getSenderRepresentativeName());
                tx.setText(tx.getText() + "\n To: " + messageInfo.getDisplayTo());
                tx.setText(tx.getText() + "\n CC: " + messageInfo.getDisplayCC());
                tx.setText(tx.getText() + "\n EntryID: " + messageInfo.getEntryIdString());
            }
    
            // Call this method recursively for each subfolder
            if (folderInfo.hasSubFolders() == true)
            {
                for (int i = 0; i < folderInfo.getSubFolders().size(); i++)
                {
                    FolderInfo subfolderInfo = (FolderInfo) folderInfo.getSubFolders().get(i);
                    DisplayFolderContents(subfolderInfo, pst);
                }
            }
        }
              

    public by christophh modified Sep 14, 2015  1365  1  5  1

    Content-Type

    print "Content-Type: text/html; charset=utf-8\n\n";          

    public by congruityservice modified Jun 21, 2015  1656  1  5  0

    Attach Revmedia for Editing

    This snippet is used for attaching a volume (directory) revmedia file for editing. Since the revmedia table can't be attached directly it must be edited using the alias_table command. The path to the table volume can be absolute, relative, or a UNC. The records in the revmedia volume are accessible through the table REVMEDIA_ALIAS. Commands must be
    //Run commands from System Monitor (F12) or Tools -> Advanced -> System Monitor
    run alias_table "C:\PathTo\TableVolume", "SYSPROG", "REVMEDIA", "REVMEDIA_ALIAS"
    
    //Show the contents of the table or use the System Editor
    run rlist "LIST REVMEDIA_ALIAS", 1

    public by DevilSharp modified Apr 7, 2015  1427  0  4  0

    Program No 1

    dll
    using System;
    public class Program
    {
            public static void Main(string[] args)
            {
                Class1 link = new Class1();
                int val1, val2, result,option;
    
                Console.Write("Enter the First Number : ");
                val1 = Convert.ToInt32(Console.ReadLine());
                Console.Write("Enter the Second Number : ");
                val2 = Convert.ToInt32(Console.ReadLine());
                
                Console.WriteLine("1.Addition");
                Console.WriteLine("2.Subtraction");
                Console.WriteLine("3.Multiplication");
                Console.WriteLine("4.Division");
                Console.Write("Enter your option:");
                option = Convert.ToInt32(Console.ReadLine());
    
                switch (option)
                {
    		case 1:
                        result = link.addition(val1, val2);
                        Console.WriteLine("The result of Addition is : {0}", result);
                        break;
    
                    case 2:
                        result = link.subtraction(val1, val2);
                        Console.WriteLine("The result of Subtraction is : {0}", result);
                        break;
    
                    case 3:
                        result = link.multiplication(val1, val2);
                        Console.WriteLine("The result of Multiplication is : {0}", result);
                        break;
    
                    case 4:
                        result = link.division(val1, val2);
                        Console.WriteLine("The result of Division is : {0}", result);
                        break;
    
                    default:
                        Console.WriteLine("Invalid Option");
                        break;
                }            
            }
    }
    
    //a1.cs //
    public class Class1
    {
    	public int addition(int val1, int val2)
            {
                return val1 + val2;
            }
            public int subtraction(int val1, int val2)
            {
                return val1 - val2;
            }
            public int multiplication(int val1, int val2)
            {
                return val1 * val2;
            }
            public int division(int val1, int val2)
            {
                return val1 / val2;
            }
    }
    // csc /t :library a1.cs    csc /r :a1.dll p1.cs
    //

    public by SpeedOfSpin modified Feb 3, 2015  2173  1  5  0

    Detect mobiles and tablets

    //http://detectmobilebrowsers.com/
    public bool isMobile(bool includeTablets = false)
            {
                string u = Request.ServerVariables["HTTP_USER_AGENT"];
                Regex b = new Regex(@"(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino" + (includeTablets ? "|android|ipad|playbook|silk" : ""), RegexOptions.IgnoreCase | RegexOptions.Multiline);
                Regex v = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                if ((b.IsMatch(u) || v.IsMatch(u.Substring(0, 4))))
                {
                    return true;
                }
    
                return false;
            }        

    public by cghersi @ MailUp API DEV modified Jan 20, 2015  1195  9  6  0

    MailUp REST API - How to subscribe a single contact 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 SubscribeContactWithCOI(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) Prepare the input:
      int idList = 1;
      ConsoleRecipientItem recipient = new ConsoleRecipientItem()
      {
        Email = "test1COI@mailup.com",
        Name = "First COI New Recipient" + DateTime.Now.ToFileTimeUtc(),
        Fields = new List<ConsoleRecipientDynamicFieldItem>()
        {
            new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name1COI_" + DateTime.Now.ToFileTimeUtc() },
            new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName1COI_" + DateTime.Now.ToFileTimeUtc() }
            //here you can add all the fields you want to add...
        }
      };
    
      // 3) Invoke the web method:
      int result = 0;
      try
      {
        result = client.AddRecipientToList(idList, recipient, true);
      }
      catch (Exception ex)
      {
        Console.WriteLine("Cannot perform the operation due to " + ex.Message);
        return;
      }
    
      // 4) Print results:
      if (result > 0)
        Console.WriteLine("Recipients Added with confirmed Opt-in! The ID of the recipient is " + result);
      else
        Console.WriteLine("An error occurred while adding the recipients with confirmed Opt-in.");
    }
                

    external by treeform modified Jan 18, 2017  21  0  1  0

    make atlas

    make atlas: atlas.nim
    import sdl2
    import sdl2.image
    import os
    import strutils
    
    if not sdl2.init(INIT_EVERYTHING):
      quit "Failed start SDL2"
    
    if image.init(IMG_INIT_PNG) == -1:
      quit "Failed start SDL2_Image"
    
    const size = 1024
    
    var rmask = uint32(0xff000000)
    var gmask = uint32(0x00ff0000)
    var bmask = uint32(0x0000ff00)
    var amask = uint32(0x000000ff)
    var atlasImage = createRGBSurface(
      0,
      cint(size),
      cint(size),
      32,
      rmask,
      gmask,
      bmask,
      amask
    )
    
    var r = Rect((x:cint(0), y:cint(0), w:cint(size), h:cint(size)))
    fillRect(
      atlasImage,
      addr r,
      uint32(0)
    )
    
    var heights : array[size, uint16]
    var margin = 8
    
    proc putImage(file: string): void = 
      echo file
      var image: SurfacePtr = load(file)
      if image == nil:
        echo "Failed to load ", file
    
      var imgWidth = image.w + margin * 2
      var imgHeight = image.h + margin * 2
    
      echo imgWidth, imgHeight
    
      var lowest = size
      var at = 0
      for i in 0..size - 1:
        var v = int(heights[i])
        if v < lowest:
          # found low point, is it consecutive?
          var fit = true
          for j in 0 .. imgWidth:
            if i + j >= size:
              fit = false
              break
            if int(heights[i + j]) > v:
              fit = false
              break
          if fit:
              # found!
              lowest = v
              at = i
        
      if lowest + imgHeight > size:
        echo "Atlas is full!!!"
    
      for j in at..at + imgWidth - 1:
        heights[j] = uint16(lowest + imgHeight + margin * 2)
    
      echo "lowest", lowest, at
      var srcRect = Rect((x:cint(0), y:cint(0), w:cint(image.w), h:cint(image.h)))
      var dstRect = Rect((x:cint(at + margin), y:cint(lowest + margin), w:cint(image.w), h:cint(image.h)))
    
      blitSurface(
        image, 
        addr srcRect,
        atlasImage,
        addr dstRect
      )
    
    for file in walkDirRec("data"):
      if file.endsWith(".png"):
        putImage(file)    
    
    # proc savePNG*(surface: SurfacePtr, file: cstring): cint {.importc: "IMG_SavePNG".}
    discard savePNG(atlasImage, "bin/atlas.png")
    
    
    
    • Public Snippets
    • Channels Snippets