working on it ...

Filters

Explore Public Snippets

Sort by

Found 8,644 snippets matching: tag

    public by lbottaro modified Feb 17, 2014  340961  3  7  1

    How to checkout the latest tag of a Git repository

    This simple bash script allows to automatically checkout your local git repository on the latest tagged version available on the remote repository. The script assumes to be run from your local repo. The command 'git rev-list --tags' lists the tags IDs in reverse chronological order, getting the very last one on top. The command 'git describe
    # Get new tags from the remote
    git fetch --tags
     
    # Get the latest tag name
    latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
     
    # Checkout the latest tag
    git checkout $latestTag  

    public by cghersi modified Nov 4, 2014  283148  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 alaindresse modified Feb 22, 2013  370558  3  6  0

    Gist to demonstrate ajax request on checkbox

    Gist to demonstrate ajax request on checkbox: ajax-checkbox.tag ajaxCheckbox.java main.js view.jsp
    // Tagfile to be placed in WEB-INF/tags/ui
    
    <%@tag import="com.liferay.portal.kernel.util.HtmlUtil"%>
    <%@tag import="com.liferay.portal.kernel.language.LanguageUtil"%>
    <%@tag import="com.liferay.portal.kernel.util.StringPool"%>
    <%@tag import="com.liferay.portal.util.PortalUtil"%>
    <%@ attribute 
    	name="resourceUrl"
    	description="URL to process the ajax call. ServeResource parameter: newValue (0 or 1 for unchecked, checked). responseData is not used. An alert is open on failure."
    	type="String" 
    	required="true" %>
    <%@ attribute
    	name="name"
    	description="Checkbox name. A random name is set if this is not provided."
    	type="String"%>
    <%@ attribute
    	name="label"
    	description="Checkbox label"
    	type="String"
    	required="true" %>
    <%@ attribute
    	name="initialValue"
    	description="Initial value of checkbox"
    	type="Boolean"
    	required="true" %>
    <%@ attribute
    	name="successCallback"
    	description="ajax callback on success. Parameters are: checkbox node, response data."
    	type="String" %>
    <%@ attribute
    	name="failureCallback"
    	description="Callback on failure. Parameter is checkbox name."
    	type="String" %>
    	
    <%@ taglib uri="http://liferay.com/tld/theme" prefix="theme" %>
    <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
    <%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
    <portlet:defineObjects />
    <theme:defineObjects />
    
    <%
    if (name == null){
    	name = PortalUtil.generateRandomKey(request, "ajaxToggleKey");
    }
    String onclick = "bb_ajaxCheckbox('" + resourceUrl  + "', this, " + successCallback + "," + failureCallback + ")";
    %>
    <aui:input type="checkbox" onClick="<%=onclick%>" value="<%=initialValue%>" name="<%=name%>" label="<%=label%>" /> 
    
    
    	@Override
    	public void serveResource(ResourceRequest resourceRequest,
    			ResourceResponse resourceResponse) throws IOException,
    			PortletException {
    		
    		_log.info("processing resource");
    		Map<String, String[]> parameters = resourceRequest.getParameterMap();
    		for (String key : parameters.keySet()){
    			_log.info(key + ":[" + StringUtil.merge(parameters.get(key)) + "]");
    		}
    
    
    		String resourceId = resourceRequest.getResourceID();
    		if (Validator.isNotNull(resourceId)) {
    			String cmd = resourceRequest.getResourceID();
    			if (cmd.equals("testToggle")) {
    				try {
    					boolean newValue = ParamUtil.getBoolean(resourceRequest,"newValue");
    					_log.info(String.valueOf(newValue));
    					if (!newValue){
    						throw new IOException("simulate failure");
    					} else {
    						resourceResponse.setContentType("text/plain");
    						resourceResponse.getWriter().write("this is the response data");
    					}
    				} catch(Exception e){
    					throw new IOException(e);
    				}
    			}
    		}
    		super.serveResource(resourceRequest, resourceResponse);
    	}
    
    
    Liferay.provide(
    	window, 
    	"bb_ajaxCheckbox",
    	function(resourceUrl, checkbox, success, failure){
    		var A = AUI();
    		var checked = false;
    		var checkbox = A.one(checkbox);
    		var label = null;
    		if (checkbox) {
    			checked = checkbox.attr('checked');
    			var labelSelector = 'label[for="' + checkbox.attr("name") + '"]';
    			if (labelSelector) label = A.one(labelSelector);
    		}
    		var ajaxCallbacks = {
    			success: function(){
    				if (label) label.removeClass("ajax-loading");
    				if (success) success(checkbox, this.get('responseData'));
    			},
    			failure: function(){
    				if (failure) failure(checkbox);
    			}
    		};
    		if (label) label.addClass("ajax-loading");
    		A.io.request(resourceUrl, {
    			method: 'GET',
    			data: {newValue: checked,},
    			on : ajaxCallbacks,
    		});
    	}, [ 'aui-io-request' ]
    );
    
    <%@ taglib tagdir="/WEB-INF/tags/ui" prefix="bamboost-ui"%>
    <%@ include file="/html/init.jsp"%>
    
    <portlet:resourceURL id="testToggle" var="testToggleURl"/>
    <bamboost-ui:ajax-checkbox
    	name="myname" 
    	resourceUrl="<%=testToggleURl %>" 
    	initialValue="true"
    	label="no callback"/>
    <bamboost-ui:ajax-checkbox
    	resourceUrl="<%=testToggleURl %>" 
    	initialValue="true"
    	label="testSuccess"
    	successCallback="testSuccess"/>
    <bamboost-ui:ajax-checkbox
    	resourceUrl="<%=testToggleURl %>" 
    	initialValue="true"
    	label="testFailure"
    	failureCallback="testFailure"/>
    	
    	<script>
    	function testSuccess(checkbox, responseData) {
    		alert(checkbox.attr("name") + "\n" + responseData);
    	};
    	function testFailure() {alert("failure");};
    	</script>
    
    

    public by frank modified Apr 10, 2014  266230  0  4  0

    Tag Link

    <link rel=”stylesheet” type=”text/css” href=”estilo.css”>

    public by JonahM modified May 19, 2014  275340  3  7  4

    Fluid CSS Rows

    I've realised in my coding experience that I need to To allow for space in the div or row tags when using text. Because everything is responsive on a web page, it's a good idea to use these classes. They work really well. Example: http://j.mp/1oilINn
    
    
    .strip-md{
    	padding-top:80px;
    	padding-bottom:80px;
    	position:relative;
    	overflow:hidden;
    }
    
    .strip-sm{
    	padding-top:30px;
    	padding-bottom:30px;
    }
    
    

    public by marksimon232 modified Jun 10, 2014  252391  1  6  0

    translate messages with html tags - Code snippets for symfony 1.x

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xliff PUBLIC "-//XLIFF//DTD XLIFF//EN" "http://www.oasis-open.org/committees/xliff/documents/xliff.dtd">
    <xliff version="1.0">
        <file original="global" source-language="en" datatype="plaintext" date="2009-08-12T12:32:00Z">
            <header/>
            <body>
                ...
                <trans-unit>
                    <source>from %from_date%<br/>to %to_date%</source>
                    <target>de %from_date%<br/>até %to_date%</target>
                </trans-unit>
            </body>
        </file>
    </xliff>
    
    

    public by Geometry modified Jul 28, 2016  1205  0  4  0

    GetDevicesOfService: Retrieves a list of devices which offer the service specified with the Uuid. In case of a sensor tag service (e.g. temperature), this lists all Sensor Tags.

    Retrieves a list of devices which offer the service specified with the Uuid. In case of a sensor tag service (e.g. temperature), this lists all Sensor Tags. Uuid for the type of service u're looking for. List of DeviceInformation
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.Devices.Bluetooth.GenericAttributeProfile;
    using Windows.Devices.Enumeration;
    using Windows.Storage.Streams;
    using X2CodingLab.SensorTag.Exceptions;
    using X2CodingLab.Utils;
    
    /// <summary>
    /// Retrieves a list of devices which offer the service specified with the Uuid. In case of a sensor tag service (e.g. temperature),
    /// this lists all Sensor Tags.
    /// </summary>
    /// <param name="serviceUuid">Uuid for the type of service u're looking for.</param>
    /// <returns>List of DeviceInformation</returns>
    public static async Task<List<DeviceInformation>> GetDevicesOfService(string serviceUuid)
    {
        Validator.RequiresNotNullOrEmpty(serviceUuid);
    
        string selector = GattDeviceService.GetDeviceSelectorFromUuid(new Guid(serviceUuid));
        var devices = await DeviceInformation.FindAllAsync(selector);
        return devices.ToList<DeviceInformation>();
    }

    public by Geometry modified Aug 6, 2016  88540  0  6  0

    ToSampleFormat: Converts a <see cref="WaveFormatEncoding"/> and bits per sample information into an appropriate <see cref="SampleFormat"/>.

    Converts a and bits per sample information into an appropriate . The wave format tag. The bits per sample.
    /// <summary>
    ///   Converts a <see cref="WaveFormatEncoding"/> and bits per sample information
    ///   into an appropriate <see cref="SampleFormat"/>.
    /// </summary>
    /// 
    /// <param name="tag">The wave format tag.</param>
    /// <param name="bitsPerSample">The bits per sample.</param>
    /// 
    public static SampleFormat ToSampleFormat(this WaveFormatEncoding tag, int bitsPerSample)
    {
        if (tag == WaveFormatEncoding.Pcm)
        {
            if (bitsPerSample == 16)
                return SampleFormat.Format16Bit;
            else if (bitsPerSample == 32)
                return SampleFormat.Format32Bit;
        }
        else if (tag == WaveFormatEncoding.IeeeFloat)
        {
            if (bitsPerSample == 32)
                return SampleFormat.Format32BitIeeeFloat;
            else if (bitsPerSample == 64)
                return SampleFormat.Format64BitIeeeFloat;
        }
    
        throw new ArgumentOutOfRangeException("tag", "Unsupported format tag.");
    }

    public by qxshower modified Apr 27, 2015  87225  1  5  0

    CreateXmlCloseTag

    Creates the XML close tag string for an XElement.
    using EnvDTE;
    using SteveCadwallader.CodeMaid.Model.Comments;
    using System.Diagnostics;
    using System.Text.RegularExpressions;
    
    /// <summary>
    /// Creates the XML close tag string for an XElement.
    /// </summary>
    /// <param name="element">The element.</param>
    /// <param name="options">The comment options used to contruct the tag.</param>
    /// <returns>
    /// The XML close tag, or <c>null</c> if the element has no value and is a self-closing tag.
    /// </returns>
    internal static string CreateXmlCloseTag(System.Xml.Linq.XElement element, CodeCommentOptions options)
    {
        if (element.IsEmpty)
        {
            return null;
        }
    
        var name = element.Name.LocalName;
    
        var result = string.Format("</{0}>", options.XmlTagsToLowerCase ? name.ToLowerInvariant() : name);
    
        return options.XmlKeepTagsTogether ? SpaceToFake(result) : result;
    }                        

    public by cghersi modified Jan 31, 2014  4966  11  8  0

    C#: How to remove a given tag (and all its content) from an HTML page

    This method removes the content of all the occurrences of the given tag in the given page
    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 Snippets
    • Channels Snippets