working on it ...

Filters

Explore Public Snippets

Sort by

Found 13k snippets matching: content

    public by lbottaro modified Mar 12, 2014  428932  11  7  3

    HTML header - footer layout using CSS and DIV

    This code renders a HTML basic layout with header, main and footer contents. The main content has 2 columns and the right one contains two rows. Source: http://stackoverflow.com/questions/6778808
    <html>
        <head>
        <style type="text/css">
        #maincontent {
            width:950px;
            height:100%;
            margin:0 auto;
        }
        #header {
            width:946px;
            height:150px;
            border:#000 solid;
            border-width:2px 2px 1px 2px;
        }
        #leftcolumn {
            width:395px;
            height:703px;
            border:#000 solid;
            border-width:1px 1px 1px 2px;
            float:left;
        }
        #toprow {
            width:549px;
            height:351px;
            border:#000 solid;
            border-width:1px 2px 1px 1px;
            float:left;
        }
        #bottomrow {
            width:549px;
            height:350px;
            border:#000 solid;
            border-width:1px 2px 1px 1px;
            float:left;
        }
        #footer {
            width:946px;
            height:150px;
            border:#000 solid;
            border-width:1px 2px 2px 2px;
            clear:both;
        }
        </style>
        <body>
        <div id="maincontent">
            <div id="header">Header Content</div>
            <div id="leftcolumn">Leftcolumn Content</div>
            <div id="toprow">Toprow Content</div>
            <div id="bottomrow">Bottomrow Content</div>
            <div id="footer">Footer Content</div>
        </div>
        </body>
        </html>

    public by skaggej modified Jan 10, 2013  336018  3  6  0

    SharePoint 2010 - Disable the "New" icon for newly added content

    This is another easy and useful one; I find it helpful when I'm recording content and adding it as I'm going. I don't really want the word "New" next to some things and not next to others. The finalized recordings look better if that's never there. Here's the simple PowerShell script that you can run per web application to disable the "New" icon
    $webApp = Get-SPWebApplication http://sharepoint2010
    $webApp.DaysToShowNewIndicator = "0"
    $webApp.Update()

    public by cghersi modified Jan 10, 2017  289503  1  8  0

    How to read a file into a string in Java

    This simple snippet reads a file and put the content into a returned string
    private static String readFileAsString(String filePath) throws java.io.IOException{
    
    	StringBuffer fileData = new StringBuffer(1000);
    	BufferedReader reader = new BufferedReader(new FileReader(filePath));
    	char[] buf = new char[1024];
    	int numRead=0;
    	while((numRead=reader.read(buf)) != -1){
    		String readData = String.valueOf(buf, 0, numRead);
    		fileData.append(readData);
    		buf = new char[1024];
    	}
    
    	reader.close();
    	return fileData.toString();
    }            

    public by cghersi modified Nov 4, 2014  283131  2  6  1

    Remove HTML tags from text

    Removes the given tag (and all its content) from the specified text.
    static public string RemoveHtmlTag(string pageString, string tagName)
    {
      string output = pageString;
      int exprIni = 0;
      int firstChar = 0;
      int lastChar = 0;
    
      // find html element
      exprIni = output.IndexOf("<" + tagName, 0, output.Length,
                                      StringComparison.InvariantCultureIgnoreCase);
      while (exprIni >= 0)
      {
        // extract the html
        firstChar = exprIni;
    
        // find <tag ... />
        lastChar = output.IndexOf("/>", (firstChar + 1)) + 1;
        int nextCloseTag = output.IndexOf('>', (firstChar + 1));
    
        // closed with </tag> marker..
        if ((lastChar <= 0) || (nextCloseTag < lastChar))
        {
          // find </tag>
          lastChar = output.IndexOf("</" + tagName, (firstChar + 1), (output.Length - firstChar - 1),
                                                          StringComparison.InvariantCultureIgnoreCase);
          lastChar = output.IndexOf('>', (lastChar + 1));
        }
    
        if ((firstChar < 0) || (lastChar <= 0) || (firstChar == lastChar))
          return output.Substring(0, firstChar);
        else
        {
          output = String.Format("{0} {1}",
                      output.Substring(0, firstChar).Trim(),
                      output.Substring((lastChar + 1), (output.Length - lastChar - 1)).Trim());
        }
        exprIni = output.IndexOf("<" + tagName, 0, output.Length,
                                    StringComparison.InvariantCultureIgnoreCase);
      }
    
      return output;
    }
    

    public by cghersi modified Jun 2, 2014  184985  1  6  1

    Use the Raw HTML content in XSLT transformations

    Usage of copy-of element allows to get the exact content of an XML node and put it as raw HTML, so that e.g. are not stripped out as instead happens with
    <myXmlNode>
    	<question>
    	Some text <br/> separated < br/> by new lines
    	</question>
    </myXmlNode>
    
    <span>
    	<xsl:copy-of select="question"/>
    </span>

    public by cghersi @ MailUp API DEV modified Jan 20, 2015  206433  6  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 LongBeard modified Feb 10, 2016  143072  2  3  0

    Vertically Centered Content

    Vertically Centered Content: verticallyCenteredContent.css
    .container {
        min-height: 6.5em;
        display: table-cell;
        vertical-align: middle;
    }
    
    

    public by sherazam modified Jun 8, 2016  182061  1  5  0

    How to Delete Messages in Bulk or One by One from Outlook PST in .NET Apps

    This technical tip explains how .NET developers can Delete Messages from outlook PST. Add Messages to PST Files showed how to add messages to PST files. It is, of course, also possible to delete items (contents) from a PST file and it may also be desirable to delete messages in bulk. Items from a PST file can be deleted using the FolderInfo.DeleteC
    // Enter here the actual content of the snippet.            
    //Deleting Messages from PST Files
    
    //The code snippets below delete messages from a PST file's Sent subfolder.
    
    //[C# Code Sample]
    
    // Get the Sent items folder
    FolderInfo folderInfo = pst.GetPredefinedFolder(StandardIpmFolder.SentItems);
    MessageInfoCollection msgInfoColl = folderInfo.GetContents();
    foreach (MessageInfo msgInfo in msgInfoColl)
    {
        Console.WriteLine(msgInfo.Subject + ": " + msgInfo.EntryIdString);
        if (msgInfo.Subject.Equals("some delete condition") == true)
        {
            // Delete this item
            folderInfo.DeleteChildItem(msgInfo.EntryId);
            Console.WriteLine("Deleted this message");
        }
    }
     
    //[VB.NET Code Sample]
    
    ' Get the Sent items folder
    Dim folderInfo As FolderInfo = pst.GetPredefinedFolder(StandardIpmFolder.SentItems)
    Dim msgInfoColl As MessageInfoCollection = folderInfo.GetContents()
    For Each msgInfo As MessageInfo In msgInfoColl
    	Console.WriteLine(msgInfo.Subject & ": " & msgInfo.EntryIdString)
    	If msgInfo.Subject.Equals("some delete condition") = True Then
    		' Delete this item
    		folderInfo.DeleteChildItem(msgInfo.EntryId)
    		Console.WriteLine("Deleted this message")
    	End If
    Next msgInfo
    
    //Delete Items in Bulk from PST File
    
    //Aspose.Email API can be used to delete items in bulk from a PST file. This is achieved using the DeleteChildItems method which accepts a list of Entry ID items referring to the items to be deleted.
    
    //[C# Code Sample]
    
    using (PersonalStorage pst = PersonalStorage.FromFile(@"test.pst"))
    {
        FolderInfo inbox = pst.RootFolder.GetSubFolder("Inbox");
        
        // find messages having From = "someuser@domain.com" 
        PersonalStorageQueryBuilder queryBuilder = new PersonalStorageQueryBuilder();
        queryBuilder.From.Contains("someuser@domain.com");
        MessageInfoCollection messages = inbox.GetContents(queryBuilder.GetQuery());
        IList<string> deleteList = new List<string>();
        foreach (MessageInfo messageInfo in messages)
        {
            deleteList.Add(messageInfo.EntryIdString);
        }
        
        // delete messages having From = "someuser@domain.com"
        inbox.DeleteChildItems(deleteList);
    }
    
    //[VB.NET Code Sample]
    
    Using pst As PersonalStorage = PersonalStorage.FromFile("test.pst")
    	Dim inbox As FolderInfo = pst.RootFolder.GetSubFolder("Inbox")
    
    	' find messages having From = "someuser@domain.com" 
    	Dim queryBuilder As New PersonalStorageQueryBuilder()
    	queryBuilder.From.Contains("someuser@domain.com")
    	Dim messages As MessageInfoCollection = inbox.GetContents(queryBuilder.GetQuery())
    	Dim deleteList As IList(Of String) = New List(Of String)()
    	For Each messageInfo As MessageInfo In messages
    		deleteList.Add(messageInfo.EntryIdString)
    	Next
    
    	' delete messages having From = "someuser@domain.com"
    	inbox.DeleteChildItems(deleteList)
    End Using
    
    

    public by LDuraj modified Jul 4, 2014  141399  0  5  0

    extends base.twig

    extending template by base.twig template and replace content block
    {% extends 'base.twig' %}
    {% block content %}
    
    {% endblock %}

    public by cghersi @ MailUp API DEV modified Nov 19, 2014  112656  9  5  0

    How to Retrieve your personal information with MailUp .NET SDK

    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 GetPersonalDataFields(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:
        //nothing to do here...
    
        // 3) Invoke the web method:
        CollectionOf<ConsoleDynamicFieldItem> result = null;
        try
        {
            result = client.GetPersonalDataFields();
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
    
        if (result != null)
            Console.WriteLine("Personal Data Fields Retrieved: " + result.Count);
        else
            Console.WriteLine("Cannot retrieve Personal Data Fields.");
    }
    
    • Public Snippets
    • Channels Snippets