working on it ...

Filters

Explore Public Snippets

Sort by

Found 25k snippets matching: custom

    public by fadzly modified Feb 11, 2015  444515  67  5  0

    Magento - custom table join product eav table in a grid

    protected function _prepareCollection()
        {
    		//to join normal attributes; but not sku, type_id and others (see catalog_product_entity database table)
    		$productAttributesArray = array('product_name' => 'name', 'product_seller' => 'seller', 'product_supplier' => 'supplier');
    		$poTempModel = Mage::getModel('mymodule/modelone')->load($this->getRequest()->getParam('id'),'actual_id');
    		$collection = Mage::getModel('mymodule/modeltwo')->getCollection()->addFieldToFilter('parent_id',$poTempModel->getId());
    		foreach ($productAttributesArray as $alias => $attributeCode)
    		{
        		$tableAlias = $attributeCode . '_table';
        		$attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode);
    			//Add eav attribute value
        		$collection->getSelect()
    							->joinLeft(
    								array($tableAlias => $attribute->getBackendTable()),
    								"main_table.product_id = $tableAlias.entity_id AND $tableAlias.attribute_id={$attribute->getId()}",
    								array($alias => 'value')
    							);
        	}
    		//to join entity attributes such sku, type_id
    		$collection->join(
                'catalog/product',
                'product_id = `catalog/product`.entity_id',//note the ` . DO NOT USE '
                array('sku' => 'sku')
            );
    		$this->setCollection($collection);
    		return parent::_prepareCollection();
        }
    	
    	protected function _prepareColumns()
    	{
    		$this->addColumn('position', array(
    			'header'=> 'Position',
    			'width' => '50px',
    			'type'  => 'number',
    			'index'=>'position',
    			'sortable' => false
    		));
    		$this->addColumn('product_name', array(
    			'header'=> 'Name',
    			'type'  => 'text',
    			'index'=>'product_name',
    			'sortable' => false
    		));
    		$this->addColumn('sku', array(
    			'header'=> 'SKU',
    			'type'  => 'text',
    			'index'=>'sku',
    			'sortable' => false
    		));
    		$this->addColumn('poitemtemp_id', array(
    			'header'=> 'Action',
    			'align'	=> 'center',
    			'type'  => 'number',
    			'index'=>'poitemtemp_id',
    			'renderer' 	=> 'mymodule/adminhtml_editpo_elements_edit_gridscontainer_currentitemsrender',
    			'sortable' => false
    		));
    		return parent::_prepareColumns();
    	}            

    public by PLAT.ONE @ PLAT.ONE modified Sep 18, 2015  324004  2  6  0

    How to save a custom property on PLAT.ONE, aka to enhance the data model of a device

    Custom properties are key-value pairs associated to an entity in PLAT.ONE. You can attach at runtime those new properties
    import java.util.ArrayList;
    import java.util.List;
    
    import com.abodata.plat1.nodeInfo.WSNNodeType;
    import com.abodata.plat1.system.ICredentialUtils;
    import com.abodata.plat1.utils.APIFilter;
    import com.abodata.plat1.velocity.client.IPlatoneAPI;
    import com.abodata.plat1.ws.velocity.IProxyCustomProperty;
    import com.abodata.plat1.ws.velocity.IProxyPhysicalNode;
    import com.abodata.plat1.ws.velocity.IProxyPlatUser;
    import com.abodata.plat1.ws.velocityInfo.ProxyObjType;
    import com.abodata.plat1.properties.CPAllowable;
    
    public class AddCustomPropertyExample {
    
    	public void addProperty() throws Exception {
    		
    		IPlatoneAPI apiMan = YourServiceActivator.getApiMan();
    		ICredentialUtils creds = YourServiceActivator.getCredentialUtils();
    		
    		//let's retrieve the first available camera:
    		List<APIFilter> filters = new ArrayList<APIFilter>();
    		filters.add(new APIFilter("type", new String[] { WSNNodeType.ENDPOINT.getType() + "", WSNNodeType.ROUTER.getType() + "" }));
    		List<IProxyPhysicalNode> cameras = apiMan.DB_GetVisiblePhysicalNode(null, filters, true, 0, 1);
    		IProxyPhysicalNode camera =	cameras.get(0);
    		
    		//get the current user:
    		IProxyPlatUser curUser = apiMan.DB_GetPlatUser(creds.getUserName(), creds.getPsw());
    		
    		//add a property to the camera:
    		IProxyCustomProperty p = apiMan.DB_AddCustomProperty(creds.getAppGardenId(), "resolution", false, "1280x768", 
    				ProxyObjType.customProperty, curUser.getId(), camera.getId(), ProxyObjType.physNode, CPAllowable.all, 
    				CPAllowable.all);
    		if (p != null)
    			System.out.println("Property added!");
    		else
    			System.out.println("Something wrong...");
    	}
    }
    

    public by marksimon232 modified Jul 6, 2015  282996  0  7  1

    Swift 2: Custom logger that mimics NSLog

    Using this initializer, you can easily build a custom logger that mimics NSLog:
    public func SWLog(format: String, _ args: CVarArgType...) {
        let dateFormatter = NSDateFormatter()
        dateFormatter.dateFormat = 
            NSDateFormatter.dateFormatFromTemplate(
                "mm:ss:SSS", options: 0, 
                locale: NSLocale.currentLocale())
        let timeString = 
            dateFormatter.stringFromDate(NSDate())
        print("\(timeString): " + 
            String(format: format, arguments: args))
    }

    public by jbaro modified Oct 25, 2016  332515  8  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 teslamint modified Jun 25, 2013  234633  0  4  0

    modified version of coova-chilli patch for OpenWrt. This patch re-add firewall rules when reload firewall. https://lists.openwrt.org/pipermail/openwrt-devel/2012-December/018075.html

    modified version of coova-chilli patch for OpenWrt. This patch re-add firewall rules when reload firewall. https://lists.openwrt.org/pipermail/openwrt-devel/2012-December/018075.html: coova-1.3.0-custom.patch
    Index: files/chilli.init
    ===================================================================
    --- files/chilli.init   (리비전 0)
    +++ files/chilli.init   (리비전 0)
    @@ -0,0 +1,61 @@
    +#!/bin/sh /etc/rc.common
    +
    +START=30
    +STOP=90
    +
    +config_cb() {
    +    chilli_inst=$2
    +    if [ "$chilli_inst" != "" ]
    +    then
    +       rm -f /var/run/chilli_${chilli_inst}*
    +       chilli_conf=/var/run/chilli_${chilli_inst}.conf
    +       eval "start_chilli_$chilli_inst=1"
    +    fi
    +}
    +
    +option_cb() {
    +    case "$1" in
    +        # UCI settings
    +       network)
    +           . /lib/functions/network.sh
    +           local ifname
    +           network_get_device ifname $2
    +           echo "dhcpif=\"$ifname\"" >> $chilli_conf
    +           ;;
    +       disabled)
    +           eval "start_chilli_$chilli_inst=0"
    +           ;;
    +        # boolean settings
    +       dhcpbroadcast|nodynip|vlanlocation|locationstopstart|locationcopycalled|locationimmediateupdate|locationopt82|coanoipcheck|noradallow|proxymacaccept|proxyonacct|dhcpmacset|dhcpradius|noc2c|eapolenable|uamanydns|uamanyip|uamnatanyip|nouamsuccess|nowispr1|nowispr2|domaindnslocal|radsec|macauth|macreauth|macauthdeny|macallowlocal|strictmacauth|strictdhcp|ieee8021q|only8021q|radiusoriginalurl|swapoctets|statusfilesave|wpaguests|openidauth|papalwaysok|mschapv2|chillixml|acctupdate|dnsparanoia|seskeepalive|usetap|noarpentries|framedservice|scalewin|redir|injectwispr|redirurl|routeonetone|nousergardendata|uamgardendata|uamotherdata|withunixipc|uamallowpost|redirssl|uamuissl|layer3|patricia|redirdnsreq|dhcpnotidle|ipv6|ipv6only)
    +           [ "$2" = "true" -o "$2" = "1" ] && echo "$1" >> $chilli_conf
    +           ;;
    +       *)
    +           echo "$1=\"$2\"" >> $chilli_conf
    +           ;;
    +    esac
    +}
    +
    +start_chilli() {
    +    local cfg="$1"
    +    local start_chilli=$(eval "echo \$start_chilli_$cfg")
    +    [ "$start_chilli" = "0" ] && return
    +    local base=/var/run/chilli_${cfg}
    +    chilli -c ${base}.conf \
    +       --pidfile ${base}.pid \
    +       --cmdsocket ${base}.sock \
    +       --unixipc ${base}.ipc &
    +}
    +
    +start() {
    +    config_load chilli
    +    config_foreach start_chilli chilli
    +}
    +
    +stop() {
    +    ls /var/run/chilli*.pid 2>/dev/null && {
    +       kill $(cat /var/run/chilli*.pid)
    +       sleep 1
    +       killall -9 chilli &
    +       rm -f /var/run/chilli*
    +    }
    +}
    Index: files/chilli.firewall
    ===================================================================
    --- files/chilli.firewall       (리비전 0)
    +++ files/chilli.firewall       (리비전 0)
    @@ -0,0 +1,33 @@
    +#!/bin/sh
    +
    +chilli_firewall() {
    +    local cfg="$1"
    +    local tun ipup addr mask net dhcpif uamport uamuiport
    +
    +    config_get tun "$cfg" tundev
    +    config_get ipup "$cfg" ipup
    +    config_get addr "$cfg" uamlisten
    +    config_get net "$cfg" net
    +    config_get dhcpif "$cfg" dhcpif
    +    config_get uamport "$cfg" uamport
    +    config_get uamuiport "$cfg" uamuiport
    +
    +    if [ -f /var/run/chilli.$tun.sh ]; then
    +        [ "$(iptables -t filter -vL | grep $tun)" != "" ] && . /var/run/chilli.$tun.sh
    +        DEV=$tun
    +        ADDR=$addr
    +        MASK=255.255.255.0
    +        NET=$net
    +        DHCPIF=$dhcpif
    +        UAMPORT=$uamport
    +        UAMUIPORT=$uamuiport
    +        . $ipup
    +    fi
    +
    +}
    +
    +chilli_post_core_cb() {
    +    config_load chilli
    +    config_foreach chilli_firewall chilli
    +}
    +
    Index: Makefile
    ===================================================================
    --- Makefile    (리비전 37020)
    +++ Makefile    (작업 사본)
    @@ -8,16 +8,13 @@
     include $(TOPDIR)/rules.mk
    
     PKG_NAME:=coova-chilli
    -PKG_VERSION:=1.2.9
    +PKG_VERSION:=1.3.0
     PKG_RELEASE:=1
    
     PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
    -PKG_SOURCE_URL:=http://ap.coova.org/chilli
    -PKG_MD5SUM:=a493d0562fc3b05fe86d8ad65f7f2dc0
    +PKG_SOURCE_URL:=http://coova-chilli.s3.amazonaws.com/
    +PKG_MD5SUM:=dc0037e3cdebcb60508081b4e42e984a
    
    -PKG_FIXUP:=autoreconf
    -PKG_INSTALL:=1
    -
     include $(INCLUDE_DIR)/package.mk
    
     define Package/coova-chilli
    @@ -25,33 +22,102 @@
       SECTION:=net
       CATEGORY:=Network
       DEPENDS:=+kmod-tun +librt
    -  TITLE:=Wireless LAN HotSpot controller (Coova Chilli Version)
    -  URL:=http://www.coova.org/CoovaChilli
    +  TITLE:=Wireless LAN HotSpot controller
    +  URL:=http://www.coova.org/
     endef
    
    +define Package/coova-chilli-miniportal
    +  SUBMENU:=Captive Portals
    +  SECTION:=net
    +  CATEGORY:=Network
    +  DEPENDS:=+coova-chilli
    +  TITLE:=CoovaChilli MiniPortal
    +  URL:=http://www.coova.org/
    +endef
    +
     define Package/coova-chilli/description
            CoovaChilli is an open source access controller for wireless LAN
            access points and is based on ChilliSpot. It is used for authenticating
            users of a wireless (or wired) LAN. It supports web based login (UAM)
    -       which is today's standard for public HotSpots and it supports Wireless
    -       Protected Access (WPA) which is the standard of the future.
    -       Authentication, authorization and accounting (AAA) is handled by your
    -       favorite radius server.
    +       which is today's standard for public HotSpots and it supports Wireless Protected
    +       Access (WPA) which is the standard of the future. Authentication,
    +       authorization and accounting (AAA) is handled by your favorite
    +       radius server.
     endef
    
    -define Package/coova-chilli/conffiles
    -/etc/chilli.conf
    +define Build/Configure
    +  (cd $(PKG_BUILD_DIR); rm -rf config.{cache,status} ; \
    +               $(TARGET_CONFIGURE_OPTS) \
    +                CFLAGS="$(strip $(TARGET_CFLAGS)) -DNEED_DN_SKIPNAME" \
    +                CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
    +                LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
    +               ac_cv_func_malloc_0_nonnull=yes \
    +               ac_cv_func_realloc_0_nonnull=yes \
    +               ac_cv_func_memcmp_working=yes \
    +               ac_cv_func_setvbuf_reversed=no \
    +                ./configure \
    +                       --target=$(GNU_TARGET_NAME) \
    +                       --host=$(GNU_TARGET_NAME) \
    +                       --build=$(GNU_HOST_NAME) \
    +                       --program-prefix="" \
    +                       --program-suffix="" \
    +                       --prefix=/usr \
    +                       --sysconfdir=/etc \
    +                       --exec-prefix=/usr \
    +                       --bindir=/usr/bin \
    +                       --datadir=/usr/share \
    +                       --includedir=/usr/include \
    +                       --infodir=/usr/share/info \
    +                       --libdir=/usr/lib \
    +                       --libexecdir=/usr/lib \
    +                       --localstatedir=/var \
    +                       --mandir=/usr/share/man \
    +                       --sbindir=/usr/sbin \
    +                       --enable-shared \
    +                       --disable-static \
    +                       --with-gnu-ld \
    +                       --enable-miniconfig \
    +                       --enable-miniportal \
    +                       --enable-chilliredir \
    +                       --enable-chilliproxy \
    +                       --enable-binstatusfile \
    +        );
     endef
    
    +define Build/Compile
    +       $(MAKE) -C $(PKG_BUILD_DIR) \
    +               DESTDIR="$(PKG_INSTALL_DIR)" \
    +               all install
    +endef
    +
    +define Build/InstallDev
    +       $(INSTALL_DIR) $(1)/usr/include
    +       $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
    +       $(INSTALL_DIR) $(1)/usr/lib
    +       $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib* $(1)/usr/lib/
    +endef
    +
    +
    +define Package/coova-chilli-miniportal/install
    +       $(INSTALL_DIR) $(1)/etc/chilli
    +       $(CP) $(PKG_INSTALL_DIR)/etc/chilli/www $(1)/etc/chilli/
    +endef
    +
     define Package/coova-chilli/install
    -       $(INSTALL_DIR) $(1)/etc
    -       $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/chilli.conf $(1)/etc/
    -       $(INSTALL_DIR) $(1)/etc/chilli
    -       $(CP) $(PKG_INSTALL_DIR)/etc/chilli/* $(1)/etc/chilli/
    +       $(INSTALL_DIR) $(1)/etc/chilli
    +       $(CP) $(PKG_INSTALL_DIR)/etc/chilli.conf $(1)/etc/
    +       $(CP) $(PKG_INSTALL_DIR)/etc/chilli/up.sh $(1)/etc/chilli/
    +       $(CP) $(PKG_INSTALL_DIR)/etc/chilli/down.sh $(1)/etc/chilli/
    +       $(CP) $(PKG_INSTALL_DIR)/etc/chilli/wwwsh $(1)/etc/chilli/
    +       $(INSTALL_DIR) $(1)/etc/init.d
    +       $(CP) files/chilli.init $(1)/etc/init.d/chilli
    +       $(INSTALL_DIR) $(1)/lib/firewall
    +       $(CP) files/chilli.firewall $(1)/lib/firewall/chilli.sh
            $(INSTALL_DIR) $(1)/usr/sbin
    -       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/chilli* $(1)/usr/sbin/
    +       $(CP) $(PKG_INSTALL_DIR)/usr/sbin/chilli* $(1)/usr/sbin/
            $(INSTALL_DIR) $(1)/usr/lib/
            $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so.* $(1)/usr/lib/
     endef
    
     $(eval $(call BuildPackage,coova-chilli))
    +$(eval $(call BuildPackage,coova-chilli-miniportal))
    
    

    public by Fresh-Dev modified Feb 10, 2016  161408  1  3  0

    Custom Text Selection

    Custom Text Selection: customTextSelection.css
    ::selection { background: #e2eae2; }
    ::-moz-selection { background: #e2eae2; }
    ::-webkit-selection { background: #e2eae2; }
    
    

    public by bojan.hrnkas modified Jan 22, 2013  224948  0  7  0

    Serializing a C# object to XML

    We use a simplified object WSCustomer, since we only want some members of Customer to get serialized.
    public string GetCustomerData(int customers_Id)
    {
        Customer customers = IoC.Resolve<ICustomerService>().GetCustomerById(customers_Id);
        WSCustomer wsCustomer = WSMapping(customers);
        StringBuilder sb = new StringBuilder();
        using (TextWriter tw = new StringWriter(sb))
        {
            XmlSerializer xmlS = new XmlSerializer(typeof(WSCustomer));
            xmlS.Serialize(tw, wsCustomer);
            string serialized = sb.ToString();
            return serialized;
        }
    }
    
    

    public by snip2code modified Oct 29, 2013  14890  61  8  1

    Custom SWT List Box

    This widget presents a ListBox, with vertical scroll-bars, whose items can be custom (instead of simple strings as in List widget). The items should be of the same height and all homogeneous.
    import java.util.HashMap;
    import java.util.Map;
    
    import org.apache.log4j.Logger;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.custom.ScrolledComposite;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.graphics.Color;
    import org.eclipse.swt.graphics.Cursor;
    import org.eclipse.swt.graphics.Font;
    import org.eclipse.swt.layout.FormData;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.swt.widgets.Control;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Link;
    import org.eclipse.swt.widgets.Listener;
    import org.eclipse.wb.swt.SWTResourceManager;
    
    public class CustomListBox extends Composite {
    
    	protected static Logger log = Logger.getLogger(CustomListBox.class);
    	
    	private ScrolledComposite scrolledResults;
    	private Composite listResults;
    	
    	private int width;
    	private int height;
    	private int itemRowHeight;
    	private int rowWidth;
    	private int maxResultsDisplayed;
    	
    	private Map<String, Composite> rows = new HashMap<String, Composite>();
    	
    	/**
    	 * 
    	 * @param parent container of the component
    	 * @param style style of the componen
    	 * @param marginLeft pixels from left border of the dialog
    	 * @param topHeight pixels from top border fo the dialog
    	 * @param width total width in pixel of the component
    	 * @param height total height in pixel of the component
    	 * @param scrolledCompoFormData FormData for the component
    	 * @param itemRowHeight height in pixel of a single item
    	 */
    	public CustomListBox(Composite parent, int style, int marginLeft, int topHeight, int width, int height,
    			FormData scrolledCompoFormData, int itemRowHeight) {
    		super(parent, style);
    
    		this.width = width;
    		rowWidth = width - 25;
    		this.height = height;
    		this.itemRowHeight = itemRowHeight;
    		maxResultsDisplayed = height / itemRowHeight;
    		
    		scrolledResults = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL);
    		scrolledResults.setLocation(marginLeft, topHeight);
    		scrolledResults.setSize(width, height);
    		scrolledResults.setExpandHorizontal(false);
    		scrolledResults.setExpandVertical(true);
    		scrolledResults.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    		scrolledResults.setMinSize(width, height);	
    		scrolledCompoFormData.height = height;	//force height of the component
    		scrolledResults.setLayoutData(scrolledCompoFormData);
    		scrolledResults.getVerticalBar().setIncrement(scrolledResults.getVerticalBar().getIncrement()*10);
    		scrolledResults.addListener(SWT.Activate, new Listener() {
    		    public void handleEvent(Event e) {
    		    	scrolledResults.setFocus();
    		    }
    		});
    		
    		listResults = new Composite(scrolledResults, SWT.NONE);
    		listResults.setSize(width, height);
    		listResults.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    		scrolledResults.setContent(listResults);
    		
    		parent.addListener(SWT.Resize, new Listener() { 
    			public void handleEvent(Event event) { 
    				resizeScrollableResults();
    			} 
    		}); 
    		parent.notifyListeners(SWT.Resize, new Event()); 
    	}
    	
    	
    	private void resizeScrollableResults() {
    		int actualHeight = rows.size() * itemRowHeight;
    		scrolledResults.setMinSize(width, Math.max(actualHeight, height));
    		scrolledResults.layout();
    	}
    	
    	@Override
    	public void layout() {
    		listResults.layout();
    		resizeScrollableResults();
    	}
    	
    	/**
    	 * Creates a new row in the list, identified by the given key.
    	 * @param key identifier to retrieve the newly created item
    	 * @return the just created and added composite item
    	 * @throws IllegalArgumentException if key already exists or is null/empty
    	 */
    	public Composite addRow(String key) throws IllegalArgumentException {
    		if (key == null || key.length() <= 0)
    			throw new IllegalArgumentException("Null or empty key");
    		if (rows.containsKey(key))
    			throw new IllegalArgumentException("Item with key " + key + " already exists");
    		
    		int rowCompoWidth = rowWidth;
    		if (!scrollbarIsShown()) 
    			rowCompoWidth += 20;
    		
    		final Composite rowCompo = new Composite(listResults, SWT.BORDER);
    		rowCompo.setLocation(0, (rows.size() * itemRowHeight));
    		rowCompo.setSize(rowCompoWidth, itemRowHeight - 2);
    		rowCompo.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    
    		rows.put(key, rowCompo);
    		
    		return rowCompo;
    	}
    	
    	/**
    	 * True if the number of items is greater than the total visible items 
    	 */
    	public boolean scrollbarIsShown() {
    		return (rows.size() >= maxResultsDisplayed);
    	}
    	
    	/**
    	 * Returns the number of visible items
    	 */
    	public int getMaxResultsDisplayed() {
    		return maxResultsDisplayed;
    	}
    	
    	/**
    	 * Empties the list of items in the list and shows a single item with the given text
    	 * @param textToShow text to display
    	 * @param font font of the text to display
    	 * @param backgroundColor background color of the item that shows the text to display
    	 * @param link link to follow (if not empty, a Link instead of a Label will be created)
    	 */
    	public void displayMessage(String textToShow, Font font, Color backgroundColor, final String link) {
    		final Composite rowCompo = new Composite(listResults, SWT.NONE);
    		rowCompo.setLocation(0, 0);
    		rowCompo.setSize(width, itemRowHeight - 2);
    		rowCompo.setBackground(backgroundColor);
    
    		Control lblNoResults = null;
    		if (link != null) {
    			lblNoResults = new Link(rowCompo, SWT.NONE);
    			((Link)lblNoResults).setText(textToShow);
    			((Link)lblNoResults).setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_HAND));
    			((Link)lblNoResults).addSelectionListener(new SelectionAdapter() {
    				@Override
    				public void widgetSelected(SelectionEvent e) {
    					//something to do with the link...
    				}
    			});
    		} else {		
    			lblNoResults = new Label(rowCompo, SWT.NONE);
    			((Label)lblNoResults).setAlignment(SWT.CENTER);
    			((Label)lblNoResults).setText(textToShow);
    		}
    		lblNoResults.setBounds(0, 0, width, itemRowHeight - 2); 
    		lblNoResults.setFont(font);
    		lblNoResults.setBackground(backgroundColor);
    	}
    	
    	/**
    	 * Removes all the items from the list and dispose all the children content
    	 */
    	public void cleanItems() {
    		//clean previous results:
    		Control[] children = listResults.getChildren();
    		if (children != null) {
    			for (Control child : children) {
    				child.dispose();
    			}
    		}
    		
    		rows = new HashMap<String, Composite>();
    	}
    }

    public by paulsimmons modified Mar 16, 2017  119  7  4  0

    Custom Registration Form Wordpress

    WooCommerce doesn't allow you to edit registration form? Try, Custom registration form WordPress addon which will enable you to add the fields and edit registration page. With this addon, you can get any type of information from your website users on registration. This addon will help you to understand the likeness of your users and you can make yo
    // Enter here the actual content of the snippet.                                    

    public by pleabargain modified Jan 19, 2017  55233  0  3  0

    Create a Custom Heading fails when there are comments in the code

    Create a Custom Heading fails when there are comments in the code: Create a Custom Heading fails when there are comments in the code
    <!--
    Nest your first image and your h2 element within a single <div class="row"> element. Nest your h2 element within a <div class="col-xs-8"> and your image in a <div class="col-xs-4"> so that they are on the same line. -->
    
    
    <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
    
    <style>
      h2 {
        font-family: Lobster, Monospace;
      }
    
      .thick-green-border {
        border-color: green;
        border-width: 10px;
        border-style: solid;
        border-radius: 50%;
      }
    </style>
    
    <div class="container-fluid">
      <div class="row">
        <div class="col-xs-8">
          <h2 class="text-primary text-center">CatPhotoApp</h2>
        </div>
    
        <div class="col-xs-4">
          <a href="#"><img class="img-responsive thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. ">
          </a>
        </div>
      </div>
    
      <img src="https://bit.ly/fcc-running-cats" class="img-responsive" alt="Three kittens running towards the camera. ">
      <div class="row">
        <div class="col-xs-4">
          <button class="btn btn-block btn-primary">Like</button>
        </div>
        <div class="col-xs-4">
          <button class="btn btn-block btn-info">Info</button>
        </div>
        <div class="col-xs-4">
          <button class="btn btn-block btn-danger">Delete</button>
        </div>
      </div>
      <p>Things cats <span class="text-danger">love:</span></p>
      <ul>
        <li>cat nip</li>
        <li>laser pointers</li>
        <li>lasagna</li>
      </ul>
      <p>Top 3 things cats hate:</p>
      <ol>
        <li>flea treatment</li>
        <li>thunder</li>
        <li>other cats</li>
      </ol>
      <form action="/submit-cat-photo">
        <label><input type="radio" name="indoor-outdoor"> Indoor</label>
        <label><input type="radio" name="indoor-outdoor"> Outdoor</label>
        <label><input type="checkbox" name="personality"> Loving</label>
        <label><input type="checkbox" name="personality"> Lazy</label>
        <label><input type="checkbox" name="personality"> Crazy</label>
        <input type="text" placeholder="cat photo URL" required>
        <button type="submit">Submit</button>
      </form>
    </div>
    
    
    
    • Public Snippets
    • Channels Snippets