Free google code prettify flat theme css

Free google code prettify flat theme css

  • @Tsartsaris

    Posted on 2014-04-17

    Recently I changed the design and layout of my Graph Blog implementing the Free Flat UI from http://designmodo.com/flat-free/.Since most of the content of my posts is about coding I had to use a code prettifier. I came up with Google Code Prettify, a free losution that comes in handy. This way the reader's reading experience gets even better.

    To make the design of Google Code Prettify better fit with the Flat design I had to work with it a bit. The outcome is pretty nice and you can see some details below.
    • Works great with Bootstrap 3.0 and above.
    • It's Flat Design with colors used often on designs with a flat approach.
    • It scales great on major screen resolutions giving readers a better reading experience no matter the device they use to browse the site.
    • Made WITH LOVE.

    You can find the CSS file on GitHub. Suggestions and improvements are most welcome.

    Examples

    JAVA

      import java.util.zip.*;
    import java.io.*;
     
    public class ZipIt {
        public static void main(String args[]) throws IOException {
            if (args.length < 2) {
                System.err.println("usage: java ZipIt Zip.zip file1 file2 file3");
                System.exit(-1);
            }
            File zipFile = new File(args[0]);
            if (zipFile.exists()) {
                System.err.println("Zip file already exists, please try another");
                System.exit(-2);
            }
            FileOutputStream fos = new FileOutputStream(zipFile);
            ZipOutputStream zos = new ZipOutputStream(fos);
            int bytesRead;
            byte[] buffer = new byte[1024];
            CRC32 crc = new CRC32();
            for (int i=1, n=args.length; i < n; i++) {
                String name = args[i];
                File file = new File(name);
                if (!file.exists()) {
                    System.err.println("Skipping: " + name);
                    continue;
                }
                BufferedInputStream bis = new BufferedInputStream(
                    new FileInputStream(file));
                crc.reset();
                while ((bytesRead = bis.read(buffer)) != -1) {
                    crc.update(buffer, 0, bytesRead);
                }
                bis.close();
                // Reset to beginning of input stream
                bis = new BufferedInputStream(
                    new FileInputStream(file));
                ZipEntry entry = new ZipEntry(name);
                entry.setMethod(ZipEntry.STORED);
                entry.setCompressedSize(file.length());
                entry.setSize(file.length());
                entry.setCrc(crc.getValue());
                zos.putNextEntry(entry);
                while ((bytesRead = bis.read(buffer)) != -1) {
                    zos.write(buffer, 0, bytesRead);
                }
                bis.close();
            }
            zos.close();
        }
    }

    HTML

      <!DOCTYPE html>
    <html>
    <body>

    <script>
    document.write("Hello World!")
    </script>
    <noscript>Sorry, your browser does not support JavaScript!</noscript>

    <p>A browser without support for JavaScript will show the text in the noscript element.</p>
     
    </body>
    </html>

    Python

      from tkinter import *

    root = Tk()
    root.title('Google like faceted search results')
    T = Entry(root)
    T.focus_set()
    text = Text(root, height=10,width=40,background='white')
    text.pack(side = RIGHT)
    T.pack()

    dic = {'dictionary':'Για να ανακτήσετε πληροφορίες για τα λεξικά της Python πληκτρολογήστε dic. και ό,τι ψάχνετε πχ dic.clear()',
           'dict[key]':'Return the item of dic with key key. Raises a KeyError if key is not in the map.',
           'dic.clear()':'Remove all items from the dictionary.',
           'dic.copy()':'Return a shallow copy of the dictionary.',
           'dic.items()':'Return a new view of the dictionary’s items ((key, value) pairs). See below for documentation of view objects.',
           'string':'Για να ανακτήσετε πληροφορίες για τα strings της Python πληκτρολογήστε str. και ό,τι ψάχνετε πχ str.capitalize()',
           'str.capitalize()':'Return a copy of the string with its first character capitalized and the rest lowercased.',
           'str.center(width[, fillchar])':'Return centered in a string of length width. Padding is done using the specified fillchar (default is a space).',
           'str.count(sub[, start[, end]])':'Return the number of non-overlapping occurrences of substring sub in the range [start, end]. Optional arguments start and end are interpreted as in slice notation.',
           'str.encode(encoding="utf-8", errors="strict")':"Return an encoded version of the string as a bytes object. Default encoding is 'utf-8'. errors may be given to set a different error handling scheme. The default for errors is 'strict', meaning that encoding errors raise a UnicodeError. Other possible values are 'ignore', 'replace', 'xmlcharrefreplace', 'backslashreplace' and any other name registered via codecs.register_error(), see section Codec Base Classes. For a list of possible encodings, see section Standard Encodings.",
           'list':'Για να ανακτήσετε πληροφορίες για τις λίστες της Python πληκτρολογήστε lis. και ό,τι ψάχνετε πχ list.append(x)',
           'list.append(x)':'Add an item to the end of the list; equivalent to a[len(a):] = [x].',
           'list.extend(L)':'Extend the list by appending all the items in the given list; equivalent to a[len(a):] = L.'}
    scrollbar = Scrollbar(root)
    scrollbar.pack( side = RIGHT, fill=Y )
    lis = Listbox(root, yscrollcommand = scrollbar.set)
    lis.pack(side = LEFT, fill = BOTH)
    for vals in dic.keys():
        lis.insert(END, vals)#αρχικοποίηση τιμών του listbox με τα κλειδιά του dictionary
        
    def get_list(event):
        '''
        επιλέγουμε στοιχειο από το listbox
        και με βάση το στοιχειο εξάγουμε
        δεδομένα από το dictionary
        για να τα προβάλουμε σε textbox
        αυτό ειναι event που στο τέλος θα κάνουμε
        bind στο listbox σε single mouse click
        '''
        index = lis.curselection()[0]
        seltext = lis.get(index)
        #print(index)
        
        result = dic.get(seltext)
        #print(result)
        text.delete(1.0, END) #καθαρίζουμε το text από άλλα αποτελέσματα αν υπάρχουν
        text.insert(END, result) #προσθέτουμε αποτελέσματα στο text
        

    def key(event):
        lis1 = [] #λίστα για αποθήκευση κλειδιών από το dictionary
        lis2 = [] #λίστα για αφαίρεση διπλότυπων εγγραφών
        msg=event.keysym #msg για έλεγχο της εισαγωγής από το πληκτρολόγιο
        s=T.get()  #η εισαγωγή απο το entry
        
        if msg == 'BackSpace':
            for key in dic.keys():  #θέλουμε τα κλειδία για την ώρα και όχι τις τιμές τους
                x=key.startswith(s)  #ελεγχος αν το key του dictionary ξεκιναει με τα γραμματα που πληκτρολογησαμε
                if x==True:
                    del lis1[0:len(lis1)]
                    lis1.append (key)
                    for vals in lis1:
                        if vals not in lis2:
                            lis2.append(vals)
                
                            
            #print (lis2)
            lis.delete(0, END) #καθαρισμός του listbox για να γίνει εισαγωγή των νέων τιμών
            for items in sorted(lis2):
                lis.insert(END, items)

        elif msg == 'Down' or msg == 'Up' or msg == 'Left' or msg == 'Right':
            lis.focus_set()
            scrollbar.config( command = lis.yview )
            lis.bind('<Return>', get_list)
         
        else :
            for key in dic.keys(): #θέλουμε τα κλειδία για την ώρα και όχι τις τιμές τους
                x=key.startswith(s) #ελεγχος αν το key του dictionary ξεκιναει με τα γραμματα που πληκτρολογησαμε
                
                if x==True:
                    lis1 = []
                    lis1.append (key)
                    for vals in lis1:
                        if vals not in lis2:
                            lis2.append(vals)       
            #print (lis2)
            lis.delete(0, END) #καθαρισμός του listbox για να γίνει εισαγωγή των νέων τιμών
            for items in sorted(lis2):
                lis.insert(END, items)

    lis.bind('<ButtonRelease-1>', get_list) #κάνουμε bind την get_list σε single button click στο listbox  
    T.bind_all('<Key>', key) #κάνουμε bind το key event στο entry box
    root.mainloop( )

    The Python code example is written by me some years ago implementing a faceted live search result and can be found here.

Tag-cloud

webNeo4Jphpd3jsubuntuworkcypherinternetbootstrapdevelopmentflaskpython

Social Me!

Twitter Logo LinkedIn Logo Google+ Logo Tumblr Logo