You are here: Blogsphere Longtail
Keep up to date with your favourite Rails bloggers in context.
Watwet from Apie [12/01/2010 23:48]
How do I learn programming to create web-based applications? | Ask MetaFilter
everyone says to use Python or PHP (posted by cardioid)
Somali Pirates Not All Bad | The Awl
(posted by arafatm)
I Have No Talent // RailsTips by John Nunemaker
(posted by cardioid)
Untitled
|
Untitled - http://www.flickr.com/photos...
|
RE: help! не получается пушить репо на Gitorius
VH1 Reality Show Bus Crashes In California Causing Major Slut Spill | The Onion - America's Finest News Source
use headphones at work, but the onion’s still got it (posted by brandonvalentine)
"Have a great day and, for the record, I am truly sorry about my hair; it’s always been that way."
Watwet from Fadia [12/01/2010 23:05]
help! не получается пушить репо на Gitorius
PHP is a templating language
For my last project, I had to use PHP and managed to make it fun by —among other stuff— rewriting a templating tool. Templates was one of the first thing we did with Batiste for doSimple. It was qregexp based, not very flexible, ugly and for sure, inefficient.
Let’s redo this, keeping in mind that PHP is already a templating language.
<!DOCTYPE html> <html lang=<?php echo $lang ?>> <?php echo $html ?> </html>
This is valid PHP, and can be seen as a template with two parameters: the language ($lang) and some html content ($html).
<?php
$lang = "en";
$html = "<h1>Hello World!</h1>";
// the file above
include("hello.php");
That was too easy. But it’s not very clean, imho because you cannot do anything with the result. Let’s do this a little bit better.
<?php
function template($template, $args) {
extract($args);
ob_start();
include($template);
$result = ob_get_contents();
ob_end_clean();
return $result;
}
echo template("hello.php",
array("lang" => "en",
"html" => "<h1>Hello, World!</h1>"));
This way, you don’t pollute the global scope with variables and are able to reuse templates. It’s still very, very basic but will enable you to understand the final class Template that is used by bluespirit.ch. I’ll show you how it works but let you dive into the PHP code to understand it.
<?php
// templates is a directory
$tpl = new Template("templates");
echo $tpl->index(array("title" => "Hello",
"links" => array(1,2,3));
Now the templates, let’s start with the index (the function call above is in fact using __call).
<?php
$this->inherits("layout");
$this->block("head")
?>
<title><?php echo $title ?></title>
<?php
$this->endblock();
$this->block("body")
?>
<h1><?php echo $title ?></h1>
<ul>
<?php
foreach($links as $link):
?>
<li><?php echo $this->link(array("link" => $link)) ?></li>
<?php
endforeach
?>
</ul>
<?php
$this->endblock();
The layout, from which this template inherits.
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<?php $this->block("head") ?>
<title>Untitled Document</title>
<?php $this->endblock() ?>
</head>
<body>
<?php
$this->block("body");
$this->endblock()
?>
</body>
</html>
and link, of course.
<?php echo $link
Which could have been more complex.
That’s the very basics, the final one includes more features like some block control meaning you can no only override a block but also append or prepend some content which is very useful for the usual end of the page scripts. Another one that I like very much is some cache (using APC (or apc_alt) enabling avoiding regenerating a piece of layout everytime.
Having this kind of cache also means that you might ending up doing bad things in the templates (views) like SQL requests. This is for example used on the homepage of bluespirit.ch where the news are coming from a RSS feed parsed by Yahoo! Pipes. It doesn’t cURL it all the time.
All this in on GitHub, get it, fork it, fix it. And I’ve got one question for the PHP masters in the room, how do you do monkeypatching in PHP? (I know how much evil it is, but I promise that I won’t break anything)
Un des premiers outils que nous avions réalisés avec Batiste dans le cadre de nos débuts dosimplesques (pardonnez ce néologisme) a été un système de template. Nous en avons fait quelques-uns même. Tous reposent sur une syntaxe proche d’HTML, donc à base de commentaires remplacés à l’exécution.
C’était sans bien réaliser que PHP est déjà un langage de templating, intrinséquement. Pourquoi serait-il indispensable de mettre ce
<?phpsinon ? Ceci étant dit, voici un système de templates reposant sur ce fait-là et offrant quelques fonctionnalités sympathiques, telles que : l’héritage, les blocs, l’inclusion d’autres templates, le cache et même l’envoi de headers HTTP pour les plus bidouilleurs d’entre vous.Le code ainsi que des exemples se trouvent sur GitHub, amusez-vous y.
Adult Games for Groups and Couples.
I sure am relieved the police have got their pot back.
SlickMap CSS — A Visual Sitemapping Tool for Web Developers
SlickPlan – Sitemap Design | Creating Flowcharts
Tirando uma screenshot do GDM
Para tirar uma screenshot da sua tela de login no Ubuntu, faa o seguinte. Primeiro instale o xnest, se j no estiver instalado:
sudo apt-get install xnest
Depois execute o seguinte comando, que vai mostrar a tela de login dentro de uma janela, que pode ser capturada atravs da tecla Print Screen:
gdmflexiserver --xnest
apelad: I cannot live on bread alone, so come with me. We'll live on bread together.
|
apelad: I cannot live on bread alone, so come with me. We'll live on bread together. - http://twitter.com/apelad...
|
I Have No Talent - John Nunemaker
A little background might help - John was named a “Ruby Hero” and given a decent-sized trophy for his contributions to the Ruby on Rails community last year at RailsConf. He is a bit too modest.
Upgrading app from Rails 2.3.2 to 2.3.5
RE: RE: Новый раздел - Исходники
RE: Как обновить ruby с 1.8.6 до 1.8.7 ?
Watwet from Apie [12/01/2010 22:47]
RE: RE: RE: Content-type text/javascript для каких цели
RE: RE: Thinking Sphinx и обновление индекса
RE: В поисках книжки
Autotesting PHP applications (and others)
Whilst procrastinating furiously instead of attacking my huge workload, I decided to get FubuMVC reboot working on Mono/OSX and then write a blog post about it. The result is that you can get it running, although I had to do some hacks that aren’t going to work in production.
Colts To Rest Starters For First Game Of Playoffs
Watwet from doublethink [12/01/2010 22:18]
Watwet from Apie [12/01/2010 22:18]
Watwet from Apie [12/01/2010 22:18]
Recently, I added some sparkline graphs to a Ruby on Rails application. A sparkline is a very small graphic that displays a large amount of information, typically shown over time, and usually embedded in some other text. Invented by the father of modern infographics Edward Tufte, the sparkline has become a fixture of many online applications that want to visually display some stats in a simple, integrated way.require "spark_pr"in your controller
include Sparkin your controller
smerl: for awesome!
Here's a quick hack with smerl to turn a fun() into a module function:
1> Fun = fun() -> ok end.
#Fun<erl_eval.20.67289768>
2> {env, [_,_,_,Forms]} = erlang:fun_info(Fun, env).
{env,[[],
{value,#Fun<shell.7.115410035>},
{eval,#Fun<shell.24.81953817>},
[{clause,1,[],[],[{atom,1,ok}]}]]}
3> smerl:new(foo).
{meta_mod,foo,undefined,[],[],false}
4> Mod = smerl:new(foo).
{meta_mod,foo,undefined,[],[],false}
5> {ok, Mod2} = smerl:add_func(Mod, {function,1,bar,0,Forms}, true).
{ok,{meta_mod,foo,undefined,
[{bar,0}],
[{function,1,bar,0,[{clause,1,[],[],[{atom,1,ok}]}]}],
false}}
6> smerl:compile(Mod2, [{outdir, "ebin"}]).
ok
7> l(foo).
{module,foo}
8> foo:bar().
ok
I could get used to this working from home thing.
Gerade die 1620. Fratze auf #dailyfratze hochgeladen: http://dailyfratze.de/michael/2010/1/12
|
Gerade die 1620. Fratze auf #dailyfratze hochgeladen: http://dailyfratze.de/michael...
|
michael am 12. Januar 2010
|
michael am 12. Januar 2010 - http://dailyfratze.de/michael...
|
![]()
이 글은 꽃띠앙님의 2010년 1월 12일의 미투데이 내용입니다.
"More startups fail from a lack of customers than from a failure of product development."
"Controllers aren’t horrible for a FPS. […] But a mouse is just on a different level...."
coterie: A small group of p...
Tell us what you think of the new BlogSphere feature. We are continually looking to improve and update the
functionality based on your feedback.

Find your next Ruby on Rails project or job.
Exclusive content,
regularly updated - onsite and tele-working positions listed.
Stefan is a very nice guy and i really enjoy to work with him :)
-
D.R, Germany