Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

jaime prado pelagodesign.com

« Newer Snippets
Older Snippets »
4 total  XML / RSS feed 

Export WordPress tables

// description
Export only WordPress tables from mysql database.

mysqldump -u dbname -p username --skip-opt -B --tables wp_categories wp_comments wp_link2cat wp_links wp_options wp_post2cat wp_postmeta wp_posts wp_usermeta wp_users > wordpress.sql


css hack to enable dashed borders + scrolling in win IE

// win IE renders dashed borders as you scroll the page, thus corrupting the dashed style,
// adding a null background forces IE to render the dashes correctly.

body { background : url(null) fixed no-repeat; }

toHex()

// covert a color to hex

function toHex(dec) {
        // create list of hex characters
        var hexCharacters = "0123456789ABCDEF"
        // if number is out of range return limit
        if (dec < 0)
                return "00"
        if (dec > 255)
                return "FF"
        // decimal equivalent of first hex character in converted number
        var i = Math.floor(dec / 16)
        // decimal equivalent of second hex character in converted number
        var j = dec % 16
        // return hexadecimal equivalent
        return hexCharacters.charAt(i) + hexCharacters.charAt(j)
}

generateColors()

//Generates an array of size howMany with colors from start RGB to end RGB
//toHex() function is on my profile.

function generateColors(sred, sgreen, sblue, ered, egreen, eblue, howMany) {
        // loop to create
        var arColors = new Array();
        for(var i = 0; i < howMany; ++i) {
                        // set current red descriptor
                        var red = Math.floor(sred * ((howMany - i) / howMany) + ered * (i / howMany));

                        // set current green descriptor
                        var green = Math.floor(sgreen * ((howMany - i) / howMany) +egreen * (i / howMany));

                        // set current green descriptor
                        var blue = Math.floor(sblue * ((howMany - i) / howMany) + eblue * (i / howMany));
                        
                        arColors[i] = [toHex(red), toHex(green), toHex(blue)];
        }
        return arColors;
}
« Newer Snippets
Older Snippets »
4 total  XML / RSS feed