working on it ...

Filters

Explore Public Snippets

Sort by

Found 13k snippets matching: design

    public by f8lrebel modified Apr 24, 2013  365600  3  4  0

    Original project here: http://designitcodeit.com/i/11

    Original project here: http://designitcodeit.com/i/11: index.html script.js style.css
    CSS
    <ul class="comments">
      <li class="comment">
        <a href="#" title="View this user profile" class="photo"><img src="http://designitcodeit.com/live/45S6P0fit0nM/img/photo1.png" alt="Kasper"></a>
        <div class="meta">Kasper | 2012.07.24 14:58 <a class="reply">Reply</a></div>
        <div class="body">Cupcake ipsum dolor sit amet. Icing donut cheesecake muffin marzipan chocolate biscuit. Sweet roll chocolate marzipan.</div>
      </li>
      <li class="comment level-2">
        <a href="#" title="View this user profile" class="photo"><img src="http://designitcodeit.com/live/45S6P0fit0nM/img/photo-default.png" alt="Photo"></a>
        <div class="meta">John | 2012.07.24 15:21 <a class="reply">Reply</a></div>
        <div class="body">Candy soufflé bear claw apple pie bear claw marshmallow. Jelly brownie wafer chocolate jelly.marzipan pastry sesame snaps apple pie.</div>
      </li>
      <li class="comment level-3">
        <a href="#" title="View this user profile" class="photo"><img src="http://designitcodeit.com/live/45S6P0fit0nM/img/photo-default.png" alt="Photo"></a>
        <div class="meta">Jane | 2012.07.24 15:32 <a class="reply">Reply</a></div>
        <div class="body">Tart apple pie bonbon applicake sesame snaps sugar plum.</div>
      </li>
      <li class="comment level-4">
        <a href="#" title="View this user profile" class="photo"><img src="http://designitcodeit.com/live/45S6P0fit0nM/img/photo-default.png" alt="Photo"></a>
        <div class="meta">Jane | 2012.07.24 15:32 <a class="reply">Reply</a></div>
        <div class="body">Tart apple pie bonbon applicake sesame snaps sugar plum.</div>
      </li>
      <li class="comment">
        <a href="#" title="View this user profile" class="photo"><img src="http://designitcodeit.com/live/45S6P0fit0nM/img/photo1.png" alt="Kasper"></a>
        <div class="meta">Kasper | 2012.07.24 14:58 <a class="reply">Reply</a></div>
        <div class="body">Cupcake ipsum dolor sit amet. Icing donut cheesecake muffin marzipan chocolate biscuit.</div>
      </li>
    </ul>
    
    /* 
     * Comments thread for Design it & Code it
     * http://designitcodeit.com/i/11
     */
    
    html {
      background: #fff url(http://designitcodeit.com/live/45S6P0fit0nM/img/bg.png);
      font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    }
    body {
      max-width: 480px;
      width: 100%;
      margin: 30px auto 0 auto;
    }
    a { cursor: pointer; }
    
    /**
     * Customs
     */
    .comments:after { border-color: #fff; }
    .comments:before { background-color: #fff; }
    .comments .comment {
      background: #fff;
      border-radius: 10px;
      font-size: 11px;
      padding: 10px 15px;
    }
    .comments [class*="level-"] .photo:before { background-color: #fff; }
    .comments .meta { color: #ccc; }
    .comments .meta a { color: inherit; }
    .comments .meta a:hover { color: #34b5d0; }
    .comments .body { color: #888; }
    
    /**
     * Comments Thread
     */
    .comments {
      list-style-type: none;
      padding: 5px 0 0 46px;
      position: relative;
      margin: 0 0 0 12px;
    }
    .comments:before,
    .comments .comment,
    .comments .comment:after,
    .comments .comment:before,
    .comments .photo img,
    .comments [class*="level-"] .photo:before {
      box-shadow: 0 1px 3px rgba(0,0,0,.4);
    }
    .comments:after,
    .comments:before {
      display: block;
      content: '';
      position: absolute;
    }
    .comments:before {
      border-radius: 0 0 5px 5px;
      height: 100%;
      width: 8px;
      left: 0;
      top: 0;
    }
    .comments:after {
      box-shadow: 0 1px 3px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.4) inset;
      border-width: 4px;
      border-style: solid;
      border-radius: 18px;
      height: 10px;
      width: 10px;
      left: -5px;
      top: -16px;
      z-index: -1;
    }
    .comments .comment {
      margin-bottom: 10px;
      position: relative;
    }
    .comments .comment:after,
    .comments .comment:before {
      border-radius: 10px;
      background-color: #fff;
      position: absolute;
      display: block;
      content: '';
    }
    .comments .comment:after {
      width: 12px;
      height: 12px;
      left: -14px;
      top: 7px;
    }
    .comments .comment:before {
      width: 5px;
      height: 5px;
      left: -22px;
      top: 16px;
    }
    .comments .photo {
      position: absolute;
      left: -60px;
      top: 2px;
    }
    .comments .photo img {
      border: 1px solid #fff;
      border-radius: 32px;
      overflow: hidden;
    }
    .comments .meta { margin-bottom: 5px; }
    .comments .meta .reply { display: none; float: right; }
    .comments .comment:hover .reply { display: block; }
    .comments [class*="level-"] .photo:before {
      display: block;
      content: '';
      position: absolute;
      margin-top: -2px;
      height: 4px;
      width: 20px;
      left: -10px;
      top: 50%;
      z-index: -1;
    }
    .comments .level-2 { margin-left: 30px; }
    .comments .level-3 { margin-left: 50px; }
    .comments .level-4 { margin-left: 70px; }
    .comments .level-5 { margin-left: 90px; }
    .comments .level-6 { margin-left: 110px; }
    .comments .level-3 .photo:before { width: 40px; left: -30px;}
    .comments .level-4 .photo:before { width: 60px; left: -50px;}
    .comments .level-5 .photo:before { width: 80px; left: -70px;}
    .comments .level-6 .photo:before { width: 100px; left: -90px;}
    
    

    public by JonahM modified May 19, 2014  275313  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 mprisznyak modified Apr 15, 2014  229259  0  6  3

    Observer

    a tongue-in-cheek example for the observer pattern
    # -*- coding: utf-8 -*-
    
    """
    a tongue-in-cheek example for the observer pattern
    
    Hungary elects today :)
    """
    
    # let's use a decorator
    def observe(f):
        def decorated(self, something):
            for obs in self.observers:
                obs.notify(self, f.func_name, something)
            return f(self, something)
        return decorated
    
    
    class Observer(object):
    
        def __init__(self, name):
            self.name = name
    
        def notify(self, observed, action, something):
            name = self.name
            observed_name = observed.name
            print "{name} reports that {observed_name} {action} {something}".format(**locals())
    
    
    class Voter(object):
    
        def __init__(self, name):
            self.name = name
            self.observers = []
    
        def add_observers(self, *observers):
            self.observers.extend(observers)
    
        @observe
        def votes(self, party):
            print "{name} votes for {party}".format(name=self.name, party=party)
    
        @observe
        def eats(self, food):
            print "{name} eats {food}".format(name=self.name, food=food)
    
        def digests(self, food):
            print "{name} digests {food}".format(name=self.name, food=food)
    
    
    if __name__ == "__main__":
        # observers
        OSCE = Observer("Organization for Security and Co-operation in Europe")
        UNO  = Observer("United Nations")
        God  = Observer("God")
        # poor voter
        jani = Voter("Kovács János")
        jani.add_observers(OSCE, UNO, God)
        jani.votes("Fidesz")
        print
        jani.eats("Sunday lunch")
        # luckily digestion is not observed
        print
        jani.digests("Sunday lunch")

    public by talaverars modified Dec 15, 2014  168265  0  4  0

    the imagestock the best way to design

    the imagestock the best way to design : gistfile1.txt
    enter www.imagestock.com.mx
    
    

    public by lbottaro modified Apr 7, 2014  2486  1  7  5

    Observer Listener Design Pattern implementation in java

    The code shows how to realize a simple listener in java, implementing the observer design pattern. The listener defines a callback method, which arguments has the Observes annotation. The observed event is the invocation of methods annotated with annotation IPersonMethodInvoke. In this way the observer will be notified every time the observed me
    package com.test.example.person.listener;
    
    import javax.enterprise.event.Observes;
    
    import com.test.example.interfaces.*;
    
    public class PersonListener {
    
    	public void OnEvent(@Observes @IPersonMethodInvoke String s)
    	{
    		System.out.println("Event callback: " + s);
    	}
    
    }
    

    public by lbottaro modified Apr 7, 2014  3361  2  7  3

    Java stateless EJB implementing Observer design pattern

    This java code shows how to implement a simple stateless EJB 3.0, which implements both a remote interface and the Observer design pattern. The annotation Stateless defines the bean as stateless. The annotation Remote defines which remote interface will be implemented. The EJB will handle request to manage a simple POJO class, named Person, acce
    package com.test.example.ejb;
    
    import java.util.Collection;
    import java.util.List;
    
    import javax.ejb.LocalBean;
    import javax.ejb.Remote;
    import javax.ejb.Stateless;
    import javax.enterprise.event.Event;
    import javax.inject.Inject;
    
    import com.test.example.interfaces.*;
    import com.test.example.person.Person;
    import com.test.example.person.manager.PersonManager;
    
    /**
     * Session Bean implementation class PersonEJB
     */
    @Stateless
    @LocalBean
    @Remote(IPerson.class)
    public class PersonEJB implements IPerson{
    
    	@Inject
    	private PersonManager pm;
    	
    	@Inject
    	@IPersonMethodInvoke
    	private Event<String> eventFire;
    
    	/**
    	 * Default constructor.
    	 */
    	public PersonEJB() {
    		// TODO Auto-generated constructor stub
    	}
    
    	@Override
    	public Person addPerson(Person p) {
    		p = pm.addPerson(p);
    		return p;
    	}
    
    	@Override
    	public Person updatePerson(Person p) {
    		p = pm.updatePerson(p);
    		return p;
    	}
    
    	@Override
    	public void deletePerson(int id) {
    		pm.deletePerson(id);
    	}
    
    	@Override
    	public List<Person> getPersonList() {
    		List<Person> personList = pm.getPersonList();
    		eventFire.fire(new String("pippo"));
    		return personList;
    	}
    
    	@Override
    	public Person getPerson(int id) {
    		return pm.getPerson(id);
    	}
    
    	@Override
    	public Collection<Person> searchPersons(String completeName) {
    		return pm.searchPersons(completeName);
    	}
    
    
    }
    

    public by lbottaro modified Apr 7, 2014  3515  1  6  1

    Java Qualifier - Implementing Observer Design Pattern using interface

    This code shows a simple java interface. The Qualifier annotation allows to specify this interface as used by other class. This will allow to implement the Observer / Listener Design pattern.
    package com.test.example.interfaces;
    
    import java.lang.annotation.ElementType;
    import java.lang.annotation.Retention;
    import java.lang.annotation.RetentionPolicy;
    import java.lang.annotation.Target;
    
    import javax.inject.Qualifier;
    
    @Qualifier
    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER})
    public @interface IPersonMethodInvoke {
    
    }
    

    public by terryc modified Feb 17, 2013  1977  1  5  0

    Design pattern in Java: singleton

    Implementation of singleton design pattern in Java
    public class Singleton {
    	static Singleton _singleton;
    	
    	static { 
    		_singleton = new Singleton();
    	}
    	
    	private Singleton() {
    	}
    
    	/**
    	 * Retrieve the only instance available in this JVM
    	 */
    	public static Singleton get() { 
    		return _singleton;
    	}
    }

    public by sTiLL-iLL modified Aug 28, 2014  2395  1  7  19

    Stalk yer object(s) and handle'em however you want

    "observer" type js class
    // Eazy Object Stalking....
    
    var events = (function(){
    	  var slotz = {};
    	  return {
    	    	monitor:
    	    	   function(slot, lsnr) {
            	      if(!slotz[slot]) slotz[slot] = {
            	 	        queue: []
            	 	    };
    		          
    		            var idx = slotz[slot].queue.push(lsnr) -1;
    		        },
    		    remove:
    			      function() {
    				        delete slotz[slot].queue[idx];
    			      },
    			  emit:
    	          function(slot, dta) {
    	              if(!slotz[slot] || !slotz[slotz].queue.length) {
    	      	          return;
    	              }
    	              var objLst = slotz[slot].queue;
    	              objLst.forEach(function(ob) {
    	      		         ob(dta || {});
    	       		    });
                }
          }
    })();

    public by mprisznyak modified Jun 14, 2014  3681  0  7  11

    Adapter

    a tongue-in-cheek example for the adapter pattern
    """
    demonstrate the adapter pattern
    looking up adapters in a registry is also demonstrated
    
    You really want a Lion because some roaring is needed however your Cat can meow only.
    For animal rights reasons, you cannot change your Cat directly but a Cat2Lion adapter will still do the job.
    """
    
    class SexError(Exception):
        def __str__(self):
            return "Sorry, try Eurovision instead. All our felines are either males or females."
    
    class Feline(object):
        """
        cats and lions are felines
        """
        def __init__(self, name, sex="male"):
            self.name = name
            if sex in ["male", "female"]:
                self.sex  = sex
            else:
                raise SexError()
    
        def groom(self):
            sex2pronoun = {"male": ["he", "him"], "female": ["she", "her"]}
            nominative, objective = sex2pronoun[self.sex]        
            print "{name} licks {objective_pronoun}self and {nominative_pronoun} is going to be very well-groomed!".format(
                    name = self.name,
                    objective_pronoun = objective,
                    nominative_pronoun = nominative,
                    )
    
    #  these are protected animals you cannot alter
    class Cat(Feline):
    
        def meow(self):
            return "Meow, meow!"
    
    class Lion(Feline):
    
        def roar(self):
            return "Roar, roar!"
    
    
    class Adapter(object):
        """
        a generic object adapter you should derive your own adapters from
        """
        def __init__(self, adaptee):
            self.adaptee = adaptee
    
        def __getattr__(self, item):
            # delegate attributes
            return getattr(self.adaptee, item)
    
    class AdapterRegistry(object):
        """
        a singleton which registers adapters and 
        provides an adapter factory method called 'adapt'
        """
    
        adapters = {}
    
        @classmethod
        def register(klass, from_, to_, adapter):
            klass.adapters[(from_, to_)] = adapter
    
        @classmethod
        def adapt(klass, from_object, to_class):
            try:
                from_class = from_object.__class__
                adapter = klass.adapters[(from_class, to_class)]
                return adapter(from_object)
            except KeyError:
                raise Exception("it's impossible to turn a {from_name} into a {to_name}".format(
                            from_name = from_class.__name__),
                            to_name   = to_class.__name__
                )
    
    
    # no cat is harmed during this alteration
    class Cat2Lion(Adapter):
        """
         make a kitty roar
        """
    
        def grooms(self):
            self.adaptee.grooms()
    
        def roar(self):
            print "{name}, the cat says:".format(name=self.adaptee.name),
            return self._convert_voice(self.adaptee.meow())
    
        def _convert_voice(self, voice):
            voice = voice.lower()
            voice = voice.replace("meow", "roar")
            voice = voice.capitalize()
            return voice
    
    
    if __name__ == "__main__":
    
        mici = Cat("Mici", "female")
    
        AdapterRegistry.register(Cat, Lion, Cat2Lion) # cats may be turned into lions
        pocket_lion = AdapterRegistry.adapt(mici, Lion)
        # in fact pocket_lion, an adapted 'mici' object, is a Cat2Lion but she does behave like a Lion
        print pocket_lion.name, "is a", pocket_lion.__class__.__name__
        pocket_lion.grooms()  # lions can groom themselves
        print pocket_lion.roar()  # and now Mici, the kitty can roar, too!
    
        print "*"*80
        mici.groom() # cats can groom themselves
        mici.roar()  # cats just cannot roar properly...
    • Public Snippets
    • Channels Snippets