html


  • (Ruby) Ruby on Rails doodles

    Create new Ruby-on-Rails project. By default RoR comes with SQLite support, unless you state otherwise (-d mysql). [ruby] // Create project. With mysql support rails new my_project -d mysql [/ruby]

    read more…

  • (JS) Super simple slider/carousel/slideshow

    Here’s how you can make a super simple slideshow that changes slides on a timer interval. You could easily edit it so any other event, like a mouse click, will trigger the slide() function. You can see it in action HERE HTML [html] <div class="slider"> <div class="slide red"> <p>THIS IS SLIDE 1</p> </div> <div class="slide…

    read more…

  • (HTML) Form element arrays

    Sometimes you might want to group form elements in arrays. Here’s a way to do that: [html] <form> <input type="text" name="textboxes[]"> <input type="text" name="textboxes[]"> <input type="text" name="textboxes[]"> </form> [/html] The structure of the $_POST array will then be: [php] Array ( [textboxes] => Array ( [0] => value 1 [1] => value 2 [2] =>…

    read more…

  • (CSS) How to center a div without width

    I needed to center a div with dynamic content, so I couldn’t set a fixed width. Since margin: 0 auto; really won’t do anything if the element doesn’t have a fixed width you can solve it like this: HTML [html] <div id="container"> <div class="centered">My dynamic content, that will be centerd</div> </div> [/html] CSS [css] .centered…

    read more…

  • Simple picture/file upload script

    Simple picture/file upload script

    Here is a simple tutorial script that uploads a file to a folder on the server. In this example it is assumed that the file is an image and it will be outputted on screen in an img-tag. But the file uploading mechanics works for any file type.

    read more…

  • Debug link shared on facebook

    Sometimes when you share a link to you site on Facebook it uses old thumbnails or the link image. There’s a ton of useful info about your site here:https://developers.facebook.com/tools/debug

    read more…

  • CSS3 box shadow

    A nice feauture in CSS3 is the box-shadow. Instead of working with tedious PNG-images you can add shadows to any element with the CSS property box-shadow. The syntax works like this: box-shadow: <offset-x> <offset-y> <blur> <spread> <color> <inset> The offset settings will set the angle of the shadow. Where it will be cast in relation to…

    read more…

  • Super simple navigation menu

    Here is a super simple navigation bar. Customize it for your site, with colors and fonts. This is just a super simple base recipe: First the html: [code language=”html”] <ul class="menubar"> <li><a href="#">hem</a></li> <li><a href="#">info</a></li> <li><a href="#">tjänster</a></li> <li><a href="#">kontakt</a></li> </ul> [/code]

    read more…

  • (PHP) Simple pagination

    Here’s a simple way to paginate when getting large amounts of posts from the database.

    read more…

  • Generate dummy data

    Here’s a great tool for generating dummy data for your database etc. www.generatedata.com

    read more…

  • Open weblinks in external browser when using Phonegap

    To prevent a Phonegap-wrapped app from opening external links in the apps webview, use javascript to open the link in the external browser. This works on Android (probably other platforms as well)

    read more…

  • (PHP) Simple e-mail contact form.

    A simple contact form, just for reference. Will add more info later on… [php] <?php if (isset($_POST[‘submit’])) { $name = $_POST[‘name’]; //name of sender $email = $_POST[’email’]; //e-mail of sender $email = stripslashes($email); $subject = $_POST[‘subject’]; //e-mail subject $subject = str_replace(array("\r\n","\r","\n"), "", $subject); //remove any linebreaks to keep from code injections $message = $_POST[‘message’]; //…

    read more…