Contact Visual Idiot

x Cancel
posted 1 year ago

My Blog — Now with a mobile design!

http://visualidiot.com

image

So I recently was working on the redesign of my site, and one of the things that always bugged me was that it didn't look great on my iPhone, so I sat down and came up with a simple layout for the iPhone. It works fine on mine, but apart from that, it's untested, so I'd be eternally grateful if anyone could point out any bugs for me.

Cheers!

posted 1 year ago

Swap.li concept

As a project to help myself learn to code better, I've been working with @bertdasquirt on a project called Swap.li for a while now, which is great fun. Only recently, I realised I hadn't shared the full design with anyone else, and who better to share it to?

I'm looking for anything that doesn't seem right, could be improved, or things you generally are fond of; anything at all is great for me.

So, thanks in advance!

As a project to help myself learn to code better, I've been working with @bertdasquirt on a project called Swap.li for a while now, which is great fun. Only recently, I realised I hadn't shared the full design with anyone else, and who better to share it to?

I'm looking for anything that doesn't seem right, could be improved, or things you generally are fond of; anything at all is great for me.

So, thanks in advance!

posted 1 year ago

Count the amount of lines an element has (jQuery)

http://jsfiddle.net/visualidiot/aF57A/

If you've ever needed to get a line count for something, here's a pretty simple tip. All you need to do is get the height of one line, and divide the height of your target element by the height of one line. Easy!

If there's a better way to do this, I'd love to know. Cheers! :)

posted 1 year ago

Blog redesign

http://visualidiot.com

image

Anyone who knows me knows that, for too long, my site has been a desolate "coming soon" page. Well, I made it my mission to get a site up today, and I'm pleased to say it's up! It's chock-full of CSS3 goodness (mostly inspired by @de's crazy animate.css), and it's the first project in a long while where I didn't use jQuery (or any library for that matter).

Feel free to pick through the site, and let me know any suggestions or bugs. Thanks!

posted 1 year ago

Transparent "notch" in CSS — how'd you do it?

Basically, in a new version of my site, I want to use some flashy Javascript to play with backgrounds, and I've designed up a lovely navigation bar that has a transparent notch in it that shows the background, like so:

image

Now, I'm sure I've seen someone post this question before on Forrst (or something similar), but I couldn't find it after searching for about 20 minutes, so I posted a question here.

Any help, techniques, or advice would be greatly appreciated!

posted 1 year ago

Keeping $_SESSION variables persistent

Me and @bertdasquirt have been working on a neat little project together, and it's partially an exercise to learn OOP as I go, and for the most part, it's been great; until now, that is. I can't seem to create sessions in my aptly-named session class:

<?php

session_start();

class Session {

    public function set($name, $value = '', $use_post = false) {
        $this->value = $use_post !== false ? $_POST[$value] : $value;
                
        if(is_array($this->value) || is_object($this->value)) {
            $this->value = '';
            
            foreach($value as $key => $value) {
                $this->value .= $key . ':' . $value . ';';
            }
        }

        if(isset($value) && $value !== '') {
             $_SESSION[$name] = $value;
        }
        
        return $this;
    }

    public function get($name) {
        return (isset($_SESSION[$name]) ? $_SESSION[$name] : false);
    }
    
    public function destroy($what) {        
        session_destroy($what);
    }
}
Which I call like this (in my test case):
<?php
    $session = new Session($_POST);
    
    $value = (isset($_POST['val']) ? $_POST['val'] : '');
    
    if($value !== '') {
        $session->set('test', $value);
    }
    
    var_dump($session);
?>

<form action="" method="post">
    <label for="val">Set a session</label>
    <input id="val" name="val" value="<?php if(isset($_POST['val'])) echo $_POST['val']; ?>">
    <button type="submit" name="submit">Set cookie</button>
</form>

This works great, as long as there's post data. As soon as I dismiss Chrome's "Confirm Form Resubmission" dialog, or force a clean refresh, my session is gone.

I'm genuinely stumped here. Any thoughts or help would be greatly appreciated! :)

posted 2 years ago

Recommended file permissions for upload folders

So, I'm working on something neat in PHP which involves allowing users to, once installing the software, upload images to their website.

My question is this: what permissions octal should the uploads folder have? I know that 777 is like leaving a door open for thieves and ne'er-do-wells, but I'm not sure what to use instead. Any ideas?

Cheers!

posted 2 years ago

Vertically align a box using no extra elements

                .element {
    display: -moz-box;
    display: -webkit-box;
    display: box;

    -moz-box-pack: center;
    -moz-box-align: center;

    -webkit-box-pack: center;
    -webkit-box-align: center;

    box-pack: center;
    box-align: center;
}                
Raw

Using CSS3's new flexible box model, you can set an element to have vertical and horizontal centering, without having to use extraneous elements on the page. Works in Firefox/Safari/Chrome (that's all I've tested so far).

DEMO: jsfiddle.net/visualidiot/T7QAc/

Feedback, comments, queries, questions; all welcome. Try me.

posted 2 years ago

Using a standalone function inside a method (PHP)

Hi guys,

I'm working on my designer's CMS, Anchor, again, and I was a bit stuck on something. Basically, when I try and call a function:

function dump($str) {
    echo '';
    var_dump($str);
    echo '
'; }

Inside my class:

class Hello { …
public function test($str) {
    return dump($str);
}

I get a "Fatal error: Call to undefined function dump()". So, my question is this: how do I use my dump() function inside a method? (They're both included on the same page).

posted 2 years ago

Javascript: More concise way of doing this?

opacity = (opacity == 1 ? 0 : 1);

Quick question today, guys: Is there a better way of writing this (specifically, the 0's and 1's bit)? It's using jQuery's .css('opacity'), so it's got to be a number, but there must be a nicer way. I'm sure of it.

Thanks, guys!