It's like this:
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
Jump to
Showing posts with label website. Show all posts
Showing posts with label website. Show all posts
Some icons for webpages
A list:
- Glyphicons
- Fontawesome
- JQuery UI (how do you make them bigger? maybe use this?)
Mojolicious basics
How to do common stuff.
Run an app:
MOJO_USERAGENT_DEBUG=1 perl -I lib ~/path/to/morbo --verbose --watch lib --watch local bin/app.pl
View existing routes:
perl -I lib bin/app.pl routes
Find the code that defines the routes:
grep -r '$r->get' .
Install database:
perl -I lib bin/app.pl dbic_migration --action=install
Write a script that uses the app config, etc:
See Mojolicious::Command
Debug Test::Mojo:
print $t->tx->res->body; # See also guide to debugging
Catch unexpected exceptions:
Dump out 2nd-level routes:
my @routes = sort map { $_->to_string } map { @{ $_->children } }
grep { $_->name eq 'distro' || $_->name eq 'candidates' }
@{ $t->app->routes->children };
Run an app:
MOJO_USERAGENT_DEBUG=1 perl -I lib ~/path/to/morbo --verbose --watch lib --watch local bin/app.pl
View existing routes:
perl -I lib bin/app.pl routes
Find the code that defines the routes:
grep -r '$r->get' .
grep -r '$r->post' .
perl -I lib bin/app.pl dbic_migration --action=install
Write a script that uses the app config, etc:
See Mojolicious::Command
Debug Test::Mojo:
print $t->tx->res->body; # See also guide to debugging
Catch unexpected exceptions:
Dump out 2nd-level routes:
my @routes = sort map { $_->to_string } map { @{ $_->children } }
grep { $_->name eq 'distro' || $_->name eq 'candidates' }
@{ $t->app->routes->children };
Why not to use a pop-up window
If you're using a pop-up window on your website, you're doing it wrong.
It's akin to using nested tables for display, fer chrissakes!
Reasons why it's wrong:
It's akin to using nested tables for display, fer chrissakes!
Reasons why it's wrong:
- It's a poor user experience because the user doesn't get any of the usual browser functionality in the pop-up window, like the back button or the icon that tells you the page is loading.
- I'm sure I'll think of some more later
Client-side web design frameworks
A short list:
- Foundation - doesn't work in IE8, and doesn't even degrade gracefully
- Bootstrap - from Twitter. Works in IE8
- Alternatives are available
Moving a wordpress e-commerce site
- UPDATE wp_options SET option_value="http://newsite/new_dir" WHERE option_value="http://oldsite/old_dir"; -- this fixes most of the site
- UPDATE wp_options SET option_value="http://newsite/new_dir" WHERE option_value="http://oldsite/old_dir"; -- this fixes the pagination for the e-commerce plugin.
- In .htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC,OR]
RewriteCond %{REQUEST_URI} / [NC]
RewriteRule ^(.*)$ /new/$1 [L,QSA]
Debugging websites
CSS:
element {
outline: red solid thick;
background: green;
};
PHP:
<?php $debug = $_GET['debug'] ?>
element {
outline: red solid thick;
background: green;
};
PHP:
<?php $debug = $_GET['debug'] ?>
Developing over FTP
Using Eclipse and RSE plugin:
- Logs in okay
- But seems to always be closing directory sub-trees I've opened in 'Remote Systems' panel
- It wants to do an 'ls' on every parent directory in the hierarchy, every time I change files. Very slow.
Using CurlFtpFS:
- Install in Ubuntu from the software centre
- to mount: curlftpfs -v username:password@server.example.com local_dir/
- to unmount: fusermount -u local_dir/
- Performance is unusably slow... Eclipse wants to know about every single file on the remote server, not just the ones I'm editing.
- Saving the file through Eclipse using CurlFtpFS takes even longer than it would to upload it separately.
Using FileZilla and gedit:
- Browsing is fast
- Editing is fast
- But you have to navigate to every file manually each session, it doesn't remember what you had open
- The system of holding temp files locally is not ideal, but FileZilla detects changes in them very nicely
- You still can't grep over the files as they're all held remotely, and it's a bit fiddly to navigate to a specific file
Editing locally with Eclipse, and uploading after changes are made:
- Write an Ant script to upload any modified files?
- ...to investigate
Allow your customers to contact you easily
Live chat
olark is designed to let your customers chat to you. It works great on spoofcard.com.
It's also possible to use adium or pidgin in this manner.
Feedback
getsatisfaction is free, uservoice isn't. Maybe there are other services, too.
olark is designed to let your customers chat to you. It works great on spoofcard.com.
It's also possible to use adium or pidgin in this manner.
Feedback
getsatisfaction is free, uservoice isn't. Maybe there are other services, too.
Prevent spammers from harvesting your email address
When you write your email address on a web page, use @ instead of @, and . instead of the dot.
That way, most email harvesting programs won't recognise it.
Here's a method using Javascript that should stop 100% of email harvesting programs.
However, just using a web contact form would work best.
Log and email your Apache errors
In the .htaccess at the root of the site:
ErrorDocument 404 http://www.example.com/error_page.php?err=404
ErrorDocument 503 http://www.example.com/error_page.php?err=503
etc.
In error_page.php:
$myemail = "someone@example.com";
$subject = "example.com: $errorNum error";
$message = "$errorNum Error Report:\n";
$message .= "\nHTTP_REFERRER: ".$_SERVER['HTTP_REFERER'];
$message .= "\nREQUEST_URI: ".$_SERVER['REQUEST_URI'];
$message .= "\nHTTP_USER_AGENT: ".$_SERVER['HTTP_USER_AGENT'];
$message .= "\nQUERY_STRING: ".$_SERVER['QUERY_STRING'];
$message .= "\nREMOTE_ADDRESS: ".$_SERVER['REMOTE_ADDR'];
ob_start();
print "\n\nSERVER = "; print_r( $_SERVER );
print "\nGET = "; print_r( $_GET );
print "\nPOST = "; print_r( $_POST );
print "\nFILES = "; print_r( $_FILES );
print "\nREQUEST = "; print_r( $_REQUEST );
print "\nSESSION = "; print_r( $_SESSION );
print "\nENV = "; print_r( $_ENV );
print "\nCOOKIE = "; print_r( $_COOKIE );
print "\nprevious php_errormsg = "; print_r( $php_errormsg );
print "\nargv = "; print_r( $argv );
$output = ob_get_clean();
$message .= "\n\n$output\n";
# email the error
mail($myemail,$subject,$message,"From: support@example.com");
# log the error
$myFile = "logs/error.".date('Y_m_d-H.i.s').".log";
$fh = fopen($myFile, 'w');
$stringData = $message;
fwrite($fh, $stringData);
fclose($fh);
?>
ErrorDocument 404 http://www.example.com/error_page.php?err=404
ErrorDocument 503 http://www.example.com/error_page.php?err=503
etc.
In error_page.php:
$myemail = "someone@example.com";
$subject = "example.com: $errorNum error";
$message = "$errorNum Error Report:\n";
$message .= "\nHTTP_REFERRER: ".$_SERVER['HTTP_REFERER'];
$message .= "\nREQUEST_URI: ".$_SERVER['REQUEST_URI'];
$message .= "\nHTTP_USER_AGENT: ".$_SERVER['HTTP_USER_AGENT'];
$message .= "\nQUERY_STRING: ".$_SERVER['QUERY_STRING'];
$message .= "\nREMOTE_ADDRESS: ".$_SERVER['REMOTE_ADDR'];
ob_start();
print "\n\nSERVER = "; print_r( $_SERVER );
print "\nGET = "; print_r( $_GET );
print "\nPOST = "; print_r( $_POST );
print "\nFILES = "; print_r( $_FILES );
print "\nREQUEST = "; print_r( $_REQUEST );
print "\nSESSION = "; print_r( $_SESSION );
print "\nENV = "; print_r( $_ENV );
print "\nCOOKIE = "; print_r( $_COOKIE );
print "\nprevious php_errormsg = "; print_r( $php_errormsg );
print "\nargv = "; print_r( $argv );
$output = ob_get_clean();
$message .= "\n\n$output\n";
# email the error
mail($myemail,$subject,$message,"From: support@example.com");
# log the error
$myFile = "logs/error.".date('Y_m_d-H.i.s').".log";
$fh = fopen($myFile, 'w');
$stringData = $message;
fwrite($fh, $stringData);
fclose($fh);
?>
Ways to access Google Reader on Blackberry
- Blackberry browser - Google Reader site doesn't work, site says it's loading too slowly and fails.
- Blackberry browser - add all RSS feeds manually as bookmarks - too tedious.
- Opera Mini - Google Reader works. Opera settings:
- Mobile view: off
- Full screen: on
- View Google Reader in: Mobile view (link at bottom of web page)
- Apps on Blackberry Curve 8900, Platform 5.2.0.67, App Version 5.0.0.681
- BeReader 1.1.49 (BerryReader, free trial) - I logged in and selected 'choose feed', it crashed with "Uncaught exception: Application berryreader(421) is not responding; process terminated".
- Viigo 3.1.507 - Works great for its built-in feeds, but adding my Google Reader results in "no feeds" warning and "authentication error". Also can't change font size or wrap titles, so you only see the first 4-6 words of the title. Loading the article is fast though.
Subscribe to:
Posts (Atom)