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]

  • (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…

  • (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] =>…

  • (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…

  • (PHP) 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. [php] <?php if(isset($_POST[‘submit’])) { $temp_name = $_FILES["file"]["tmp_name"];…

  • Debug link shared on facebook

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

  • 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…

  • 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]

  • (PHP) Simple pagination

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

  • Generate dummy data

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