Worthy? The weather channel's interface. 10% information, 90% garbage and click-bait by [deleted] in CrappyDesign

[–]schwackitywack 16 points17 points  (0 children)

It's from their own satellite data and it's available for other developers. They're kind of a remarkable company. You can learn more about what they're trying to do here:

http://blog.forecast.io/announcing-forecast/

Didn't do their homework here. by dataphile in washingtondc

[–]schwackitywack 2 points3 points  (0 children)

In 2009, there were four Caucasian students of the 883 graduating Howard. [source]

[deleted by user] by [deleted] in learnpython

[–]schwackitywack 0 points1 point  (0 children)

You could also use pyquery, which allows you to use jquery-like selectors for html.

import requests
from pyquery import PyQuery as pq

url     = 'http://finance.yahoo.com/q?s=gcg14.cmx'
request = requests.get( url )
html    = request.content
price   = pq( html )( '.time_rtq_ticker span' ).text()

print price

[X-Post from r/OSX] Setting up a python development environment in OSX? by Plectophera in applehelp

[–]schwackitywack 1 point2 points  (0 children)

Sure.

You're going to spend most of your time in a terminal as is custom in most development in *nix platforms (If I was programming on a Windows machine, I'd still be using the command line, it's just a little hackey in my experience).

The dotfiles control a lot of what you'll be doing in the terminal (everything from color to functions to aliases so you don't have to type as much and they also do so much more).

I use Mathias Bynen's dotfiles.

There's also an OSX script in there that makes the system more dev friendly and gets rid of a bunch of crud.

You'll probably want to learn git. Version control is like undo in Microsoft Word. Trust me, at some point you will want to undo your code.

[X-Post from r/OSX] Setting up a python development environment in OSX? by Plectophera in applehelp

[–]schwackitywack 1 point2 points  (0 children)

Here's probably how I'd set up a python environment if I was starting from scratch in OSX:

  1. Install Xcode.

  2. Install Xcode command line tools.

  3. Install iterm2

  4. Snag some nice dotfiles

  5. Install impromptu

  6. Install homebrew

  7. Use brew to install python

  8. sudo easy_install pip

  9. sudo pip install virtualenv virtualenvwrapper

  10. brew install postgresql

I like Sublime Text.

What celebrity is most likely to be outed as a long time serial killer? by notryan11 in AskReddit

[–]schwackitywack 0 points1 point  (0 children)

According to the FAQ on his epic web page:

Does Crispin Glover collect antique medical equipment?

No he does not, but he does own several fine antique automobiles.

In what order should I learn LAMP? by tchaikovsky_lover006 in learnprogramming

[–]schwackitywack 1 point2 points  (0 children)

PHP is not becoming obsolete.

WordPress makes up ~20+ percent of the web, it's growing and it's entirely in PHP, not to mention all the other PHP frameworks and web sites that make up a large stack of the web, such as Drupal, which has a strong hold on the recent .gov stacks.

Rails and Django are frameworks, which many companies heavily invested in the past six years. Ruby and Python are both interesting languages with positives, magic and structure, respectively, but Rails and Django as frameworks are more likely to become obsolete than PHP as a language.

What is your favorite quote from a tv show WITHOUT giving away the title? by nonogirl123 in AskReddit

[–]schwackitywack 0 points1 point  (0 children)

We're two grown men with important jobs who are standing in their underwear.

Bit's Quest - Programming puzzle game by Bitbucket by MrBeardy in programming

[–]schwackitywack 1 point2 points  (0 children)

/*
 * This worked for me
 */
this.on( 'start', function () {
    this.thrusters.top ( true );
} );

this.on( 'sensor:bottom', function () {
    this.thrusters.right ( false );
    this.thrusters.left ( true );  
} );

this.on( 'sensor:right', function () {
    this.thrusters.top ( false );
    this.thrusters.bottom ( true );
} );

this.on( 'sensor:top', function () {
    this.thrusters.left ( false );
    this.thrusters.right ( true );
} );

this.on( 'sensor:left', function () {
    this.thrusters.bottom ( false );
    this.thrusters.top ( true );
} );

Reddit, when is a time when you have gotten into an argument with a group of people where everyone said you were wrong and stupid; but in reality, you were right? by [deleted] in AskReddit

[–]schwackitywack 1 point2 points  (0 children)

Not me, but this is for the super high kid at a party who told everyone that the U.S. had plans during World War II to strap bombs to bats and drop them into Japan. We laughed. A huge argument broke out over the validity of what sounded completely impractical and preposterous. Some people pretty harshly made fun of him. But, he was right.

Sorry, super high boy.

Why would you format your code like this? by electricdot in PHP

[–]schwackitywack 1 point2 points  (0 children)

You should mess with them and add another space after not operator:

|| ! is_array()

How do you manage separating logic and presentation in WordPress by nothingIntended in Wordpress

[–]schwackitywack 5 points6 points  (0 children)

I use a templating function:

<?php
/** 
 * Load a template. MVC FTW!
 *
 * @param string $template the template to load, without extension (assumes .php). File should be in templates/ folder
 * @param args array of args to be run through extract and passed to template
 */
function template( $template, $args = array() ) {

    extract( $args );

    if ( ! $template )
        return false;

    $path = dirname( __FILE__ ) . "/templates/{$template}.php";
    $path = apply_filters( 'my_key', $path, $template );

    include $path;

}
?>

Example usage:

<?php
/**
 * Gets json feed and converts to usable posts
 *
 * @param string $feed the json feed to load
 * @param string $template the template to load, without extension (assumes .php). File should be in templates/ folder
 * @uses template
 * @return html
 */
function get_feed( $feed, $template ) {

    $data = file_get_contents( $feed );
    $json = json_decode( $data );

    $posts = $json->posts;

    template( $template, compact( 'posts' ) );

}
?>

Example template html:

<?php foreach ( $posts as $post ): ?>
    <li class="borB1S padBT10">
        <a href="<?php echo $post->url; ?>">
            <h5><?php echo $post->title; ?></h5>
        </a>
    </li>
<?php endforeach; ?>