Enom ∞ Infini

  • Art
  • Games
  • Code
  • Music
  • Archive
  • RSS
  • Query(?)

jQuery on() AJAX

As of jQuery 1.7, the .live() function has been deprecated. The documents tell you to use the .on() function instead. There’s are some differences in the way things are handled and I stumbled upon the issue of binding hover(mouseenter and mouseleave specifically) to AJAX loaded content. Skip the semantics and jump into the code:

<!-- HTML -->
<ul class="hoverable">
    <li class="item">Item 1</li>
    <li class="item">Item 2</li>
    <li class="item">Item 3</li>
</ul>

// pre jQuery 1.7
$(".hoverable .item").live("mouseenter", function(){ $(this).addClass("hover"); });
$(".hoverable .item").live("mouseleave", function(){ $(this).removeClass("hover"); });    

// jQuery 1.7+
$(document).on("mouseenter", ".hoverable .item", function() {
    $(this).addClass("hover");
}).on("mouseleave", ".hoverable .item", function() {
    $(this).removeClass("hover");
})

There you have it

    • #ajax
    • #javascript
    • #jquery
    • #web
    • #code
  • 6 months ago
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

Properly Code Comments

When you code it’s best to comment what you’re trying to achieve via DocBlocks and inline comments. This helps you remember when coming back to your project some time later and makes it easier for anyone else who looks at the code to understand what’s going on. Sometimes though, you just have to leave that one comment which describes exactly your feelings about a certain code block, which is usually a bit more… personal — shall I put it.

Overviewing some of the code that was originally written years back by another developer, I found the following commentary:

//  do you believe all the shit we have to do to turn that 
//  god damn syslog timestamp into a unix time??  fucking
//  CHRIST, you know??
$month = month_lookup($line_parts[0]);
$year = date('Y', time() - 84600);
$time_parts = explode(":", $line_parts[2]);
$timestamp = date('Y-m-d H:i:s', 
    mktime($time_parts[0], $time_parts[1], 
    $time_parts[2], $month, $line_parts[1], $year));

Yep.

    • #lol
    • #code
    • #programming
    • #comments
  • 7 months ago
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

My code works; I have no idea why…

That one de/motivational poster about programming made me laugh so much because I honestly know what it’s like. I wrote this several months ago revamping an internal system, long before I even stumbled upon this:

// I don't know how the hell I managed this function...
$restricted = array_values(array_filter(array_map(function($full,$name){
        $parts = explode("@", $full);
        return preg_match("/{$name}/", $parts[0]) ? $full : false;
}, $return, array_fill(0, sizeof($return), $mail))));

The best part of this ridiculous one line magic is I couldn’t break it down into individual pieces afterwards. I spent a good half hour on it to just say fuck it and move on.

    • #lol
    • #code
    • #programming
    • #I don't know why
  • 7 months ago
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+
The essence of programming - Imgur
View Separately

The essence of programming - Imgur

    • #code
    • #i have no idea why
    • #lol
    • #programming
    • #truth
  • 7 months ago
  • 9
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

Falling Back

So for the longest time, since I started designing the NABB website, I’ve been wanting to use Yii to power it. Now, I simply look at it and realize: “Why bother making an entire custom application? Why not just use WordPress?” And I’ve decided to do exactly that.

Why switch from a full custom framework built website? Because I don’t have to worry about creating a content management system. I don’t have to worry about properly building the application. I don’t have to worry about investing such energy. I don’t have to worry so much.

Sometimes you want to do something really cool and completely customized, but sometimes you should simply use what’s already there.

    • #WordPress
    • #Web
    • #Design
    • #NABB
    • #Yii
    • #Code
  • 1 year ago
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

https://www.destroyallsoftware.com/talks/wat

wat is code

    • #wat
    • #code
    • #lol
    • #programming
    • #wtf
  • 1 year ago
  • 3
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+
Warning! JSLint will hurt your feelings.

JSLint

Oh, cannot wait to try this!

    • #JSLint
    • #JavaScript
    • #Code
    • #Web
  • 1 year ago
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+
xkcd: Error Code

I need to acquire this book.
Pop-upView Separately

xkcd: Error Code

I need to acquire this book.

    • #xkcd
    • #lol
    • #error
    • #code
    • #error code
    • #comic
  • 1 year ago
  • 1
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

jakesmumbles 

One of those “a-ha” moments, eh?

Less “a-ha” and more “kaboom!” I’ve been converting an old Clipper based application to PHP and it’s been a real pain in the ass. Today I finally — least I think I did, I still have to test it — completed all of the main functions.

I have the pieces to the puzzle, now to put it all together. :)

    • #Code
    • #Web
    • #PHP
    • #Yii
    • #Clipper
  • 1 year ago
  • 20
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

That moment when you make code your bitch

    • #Code
    • #PHP
    • #Yii
    • #Web
  • 1 year ago
  • 10
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

$ php_beautifier

I was able to install and properly configure Pear for my Mac. It’s messy, but I got it to work. From that I installed php_beautifier because I couldn’t read the code structure for this one client’s contact page.

I’ll be attempting to install it on our development server as soon as I get access to it. Once I get that working, I’ll install it on our live server. All in hopes of preventing yesterday’s mishap. My attempt at running a PHP script to beautify another PHP script ended up in an endless loop, thus bogging down our live server. Needed to restart the server and apache. Boss wasn’t all too thrilled.

Before & After PHP Beautifier
http://pastebin.com/u6z7LxPZ

I didn’t customize the filters a lot. I’m quite interested in see how I can format scripts using this. I know I won’t get exactly what I want, but it’s still worth a shot to see how close I get.

    • #PHP
    • #Code
    • #Web
    • #Code Structure
    • #PHP Beautifier
    • #Pear
  • 1 year ago
  • 3
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

JavaScript Bookmarklet Loading

Spent way too many hours coding this.

My OCD kicked into overdrive with this project. Since I can’t easily do OOP with JavaScript and wanted something compact, it took me ages to properly figure out how to create objects and extend them. My neat freakness wanted everything to be nested. So that’s what I did. I learned the complexities of object manipulation and extension thanks to jQuery.

I still have a couple things to add and fix, but for the most part, this works exactly as intended. Now to add all of the remaining functionality and potentially compact it even more.

Bookmarklet Loader / Lurker Preload
http://pastebin.com/MmdRzNDV

Lurker Boostrap / Instantiate
http://pastebin.com/BRbiM0vH

Feedback is always appreciated. 

    • #JavaScript
    • #Web
    • #Development
    • #Code
    • #Lurk
    • #Lurker
    • #OOP
  • 1 year ago
  • 6
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

Tonight, We Dine In…

Code. Immense amounts of code.

I’ll be working on releasing a beta of my lurker. I’ve already sketched out a simple UI for both the thumbnail view and full image view. UI and interaction shouldn’t be all that hard. Making it perfect though, that’s a whole other story.

I also need to create a smart loading system. The loading system is what’ll take the most time but is the most crucial aspect. It’ll prevent what happened with my script attempting to lurk nekomimichan.

JavaScript go!

    • #JavaScript
    • #Lurk
    • #Lurking
    • #UI
    • #User Interface
    • #Web
    • #Code
  • 1 year ago
  • 4
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

Fuck. My JavaScript lurker for that neko site crashes my browser. It’s late, I just want it to work… Fucking code optimization and debugging when you don’t want it sucks.

    • #Web
    • #Code
    • #JavaScript
    • #Lurking
    • #Nekos
  • 1 year ago
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

Jakes Mumbles...: Reply to enom

jakesmumbles:

“I attended a Flash programming seminar and one of the more important topics he discussed was simplifying things. It’s always “add more,” but sometimes you should do the opposite and remove all this extra to make a core product that’s refined. ” - enom

I couldn’t agree more with that. Focus on…

    • #Programming
    • #Development
    • #Web
    • #Applications
    • #Code
  • 2 years ago > jakesmumbles
  • 2
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+
Page 1 of 2
← Newer • Older →

Enom ∞ Infini

Portrait/Logo

About

Life, Art, Games, Code -- But an excerpt of who I am.
  • RSS
  • Random
  • Archive
  • Query(?)
  • Mobile
Effector Theme by Pixel Union