i just thought about iterating objects in php.
Since 5.3 supports lambda, i found this quite usefull:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| class Test {
public $vals = array();
function __construct(){
$this->vals = range(1,10);
}
// the hooray goes here!
function each($function){
foreach($this->vals as $element){
$function($element);
}
}
}
$t = new Test;
//the real hooray-part:
$t->each( function( $e ) {
echo "Hi, i am element $e\n";
}); |
Works! :)
[More]
Building Websites is fun!
Having IE6 Users sucks instead!
Get rid of them by pasting the following code into your document-head.
<!–[if IE 6]>
<script type=”text/javascript”>
alert(”No IE 6! Thanks!”);
document.write(’<style>*{position:relative}</style><table><input></table>’)
</script>
<![endif]–>
IE 6 will crash after asking the user not to use it!
Here is a small collection of Tips and Tricks for Ruby in association to Rails.
I will paste some irb-logs, displaying all results.
1. Format decimals or text quickly
[More]
Today i was bored by svn. Filenames containing “special characters” can cause an annoying Subversion error message:
1
| svn: Can't convert string from 'UTF-8' to native encoding: |
From the subversion book:
Errors like this typically occur when the Subversion client has received a UTF-8 string from the repository, but not all of the characters in that string can be represented using the encoding of the current locale. For example, if your locale is en_US but a collaborator has committed a Japanese filename, you’re likely to see this error when you receive the file during an svn update.
To fix this error message you have to set your current locale appropriately:
[More]
Just a rather small hint for rails users.
Today i was getting angry about rails, since it told me that a specific method would not exist.. but i knew that i did exists, and both of us were wrong.
How come: i moved a method vom controller to helper, but forgott to remove it from helper_methods.
So Rails claims, that the gived method does not exists. Strange, but true, it complains when you call it in code or template, silence when you just add it as helper_method.
So be warned, be smarter than i was ;)
Well,
this is not really a Rails or web-dev relate post, but i need to tell you about this.
Every iPhone (3G) user knows, that the iphone is the slowest piece of crap you can have in one hand after some days of usage!
Since i hated to wait for 30 Seconds seeing my SMS, i got angry after a while.
Solution: [More]
Ever had the terrible problem of not beeing able to operate your iTunes via iPhone, because it hast not started?
The solution seems to be simple: walk over and start that god damn app.
Sometimes its hard to accomplish. e.g. counting socks or throwing cat-food to people next to you and so on might prevent you from doing taht.
Here is the solution, send an eMail to your Computer…
[More]
Hi,
this is my new blog! its better than yours!
because you cannot write posts here! thanks for reading!