Monday, December 7, 2009

Display arrays vertically instead of horizontally in HTML via PHP

This one doesn't use JQuery: Instead its just php.

After trying out some very complex possible solutions that just didn't work, I figured out the simplest  way to reorder my arrays to make them ready for the html page load.
So for example, if you have an array containing this order from say a SQL query:

1   2   3
4   5   6
7

And you want it to display like this:

1   4   6
2   5   7
3

Tuesday, October 13, 2009

Aion MMORPG - Symbols in chat

Copy paste the following symbols (the squares) in the chat lines in Aion
Just try to be less annoying than spammers!

 Kinah
 red up arrow
 blue down arrow
 red up arrow 2
 blue down arrow 2
 alert (red exclam point)
 green button 1
 green button 2
 red button 1
 red button 2
 abyss point coin
 checked guy
 equal sign
 dog face
 shield
 gray dog face
 tree
 roman 1
 roman 2
 roman 3
 roman 4
 1
 2
 3
 4
 MT1
 MT2
 Zzzz
 No Mudkips allowed (red barred circle)
 Blue arrow
 Smiley
 Star
 Heart
 Bomb
 Skull
 target 1
 target 2

Everything in 1 line:
                                    

Monday, September 21, 2009

Regex for a youtube video PHP

This post is about a regex for a youtube address as well as embedding it yourself, all in php.

First off, all youtube videos have the following address:
http://www.youtube.com/watch?v=XxXXxXXxXxX  <-- not a tested link

In each of those, you will find a v=11 character code. So what you need if a user gives you such a link for his video, you must extract the 11 char code of the string only. So the code to do that is

$link = $_POST["youtubelink"];

preg_match("/v\=([\-\w]+)/", $link, $matches);
$link = $matches[1];/*matches[0] includes the v= and you dont want that*/



Tuesday, September 8, 2009

Jquery: Checkbox and change

Jquery has a nice function called change ($(element).change(function(){});

Sadly (as usual) that piece of shit browser named Internet Explorer, wont trigger it.
Soon enough (on private sites) i'll have to start adding a browser check at the start of every page using the following pseudo code: 

if browser is IE
display "Sorry but your browser is broken, get firefox! (link: www.getfirefox.com)"
else
display page


For now, the quick workaround is to use the click method on the input, like so:

$("input._alerts").click(function(){alert("chk was clicked");});


Tuesday, September 1, 2009

Ajax Upload

Impossible! But it looks like it for the end user.

That's right, it is NOT possible to upload files via Ajax. However, it's possible to come pretty close, and with this site, you can get a good looking upload button that looks like web 2.0.
Take a look at Andrew Valum's ajax upload page

For JQuery users: View this demo
(use this JS file:  ajaxupload.3.6.js (at the time of this writing) found in the source of the jquery demo page)

 





Number Only in text fields

Using javascript you can set fields to accept certain characters only using Regex strings. In the following I put the "_decimalonly" class to my text inputs, and with JQuery, when the page is loaded, all the inputs with the "_decimalonly" have the validations implemented.


Here are a few I use for inputs:


Variables for on keypress validation
var decimal = new RegExp("[-|0-9|\.]+");//decimal
var monetary = new RegExp("[0-9|\.]+");//monetary

var integer = new RegExp("[0-9]+");//positive integer
var neginteger= new RegExp("[-|0-9]+");//negative integer

Variables for on blur (submit also) validation
var decimalb = new RegExp("^-?[0-9]*\.?[0-9]{1,}?$");//decimal
var monetaryb = new RegExp("^[0-9]*\.?[0-9]{1,}?$");//monetary
var integerb = new RegExp("^[0-9]*$");//integer
var negintegerb = new RegExp("^-?[0-9]*$");//negative integer

Examples:

Saturday, August 1, 2009

Changing Autocomplete BG Eclipse 3.1

To change the background color for the autocomplete feature in eclipse 3.1, note that it's actually called "Content Assist"

You can change it in General ->Appearance ->Colors and Fonts -- Basic - Content Assist background color