working on it ...


Explore Public Snippets

Sort by

Found 14k snippets matching: design

    public by f8lrebel  366149  3  4  0

    Original project here:

    Original project here: index.html script.js style.css
    <ul class="comments">
      <li class="comment">
        <a href="#" title="View this user profile" class="photo"><img src="" 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 class="comment level-2">
        <a href="#" title="View this user profile" class="photo"><img src="" 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 class="comment level-3">
        <a href="#" title="View this user profile" class="photo"><img src="" 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 class="comment level-4">
        <a href="#" title="View this user profile" class="photo"><img src="" 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 class="comment">
        <a href="#" title="View this user profile" class="photo"><img src="" 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>
     * Comments thread for Design it & Code it
    html {
      background: #fff url(;
      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 .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: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  275611  4  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:

    public by mprisznyak  229542  0  6  3


    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):
   = name
        def notify(self, observed, action, something):
            name =
            observed_name =
            print "{name} reports that {observed_name} {action} {something}".format(**locals())
    class Voter(object):
        def __init__(self, name):
   = name
            self.observers = []
        def add_observers(self, *observers):
        def votes(self, party):
            print "{name} votes for {party}".format(, party=party)
        def eats(self, food):
            print "{name} eats {food}".format(, food=food)
        def digests(self, food):
            print "{name} digests {food}".format(, 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.eats("Sunday lunch")
        # luckily digestion is not observed
        jani.digests("Sunday lunch")

    public by talaverars  168592  0  4  0

    the imagestock the best way to design

    the imagestock the best way to design : gistfile1.txt

    public by lbottaro  2822  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  3714  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
    public class PersonEJB implements IPerson{
    	private PersonManager pm;
    	private Event<String> eventFire;
    	 * Default constructor.
    	public PersonEJB() {
    		// TODO Auto-generated constructor stub
    	public Person addPerson(Person p) {
    		p = pm.addPerson(p);
    		return p;
    	public Person updatePerson(Person p) {
    		p = pm.updatePerson(p);
    		return p;
    	public void deletePerson(int id) {
    	public List<Person> getPersonList() {
    		List<Person> personList = pm.getPersonList(); String("pippo"));
    		return personList;
    	public Person getPerson(int id) {
    		return pm.getPerson(id);
    	public Collection<Person> searchPersons(String completeName) {
    		return pm.searchPersons(completeName);

    public by lbottaro  3833  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;
    @Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER})
    public @interface IPersonMethodInvoke {

    public by terryc  2218  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  2660  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 {
    	    	   function(slot, lsnr) {
            	      if(!slotz[slot]) slotz[slot] = {
            	 	        queue: []
    		            var idx = slotz[slot].queue.push(lsnr) -1;
    			      function() {
    				        delete slotz[slot].queue[idx];
    	          function(slot, dta) {
    	              if(!slotz[slot] || !slotz[slotz].queue.length) {
    	              var objLst = slotz[slot].queue;
    	              objLst.forEach(function(ob) {
    	      		         ob(dta || {});

    public by mprisznyak  4038  0  6  12


    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"):
   = name
            if sex in ["male", "female"]:
        = sex
                raise SexError()
        def groom(self):
            sex2pronoun = {"male": ["he", "him"], "female": ["she", "her"]}
            nominative, objective = sex2pronoun[]        
            print "{name} licks {objective_pronoun}self and {nominative_pronoun} is going to be very well-groomed!".format(
                    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 = {}
        def register(klass, from_, to_, adapter):
            klass.adapters[(from_, to_)] = adapter
        def adapt(klass, from_object, to_class):
                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):
        def roar(self):
            print "{name}, the cat says:".format(,
            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, "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