>>> timeit.Timer("[x for x in [1,2,3,None] if x]").timeit()
0.7186648845672607
>>> timeit.Timer("filter(None, [1,2,3,None])").timeit()
0.5820250511169434
| <?php | |
| function safe_truncate_text($text, $lenght) | |
| { | |
| $trunc_text_parts = explode(' ', substr($text, 0,$length)); | |
| $parts = count($trunc_text_parts); | |
| $final_text_parts = array_slice( explode(' ', $text), 0, $parts ); | |
| $final_text = implode(' ', $final_text_parts).' ...'; | |
| return $final_text; |
| select * from categories_description where language_id=1 and ( categories_id in (select categories_id from products_to_categories) or categories_id in (select parent_id from categories) ) |
| SELECT * FROM orders o, `orders_total` ot | |
| WHERE o.orders_id=ot.orders_id AND | |
| o.orders_status=3 AND | |
| ot.title='total:' |
| SELECT AVG(o.order_total),COUNT(*) | |
| FROM orders o, `orders_total` ot | |
| WHERE o.orders_id=ot.orders_id AND | |
| o.orders_status=3 AND | |
| o.date_purchased BETWEEN '2010-4-01' AND '2010-4-31' |
| path = 'images/' | |
| imgDir = Dir.new(path) | |
| imgs = imgDir.entries | |
| imgs.each do |i| | |
| if i=='.' or i=='..' then next end | |
| newfile = i.gsub(/([^.]+\.[^.]+\.[^.]+)\.00.jpg/i, '\\1.jpg') | |
| File.rename(path+i, path+newfile) | |
| end |
| SELECT * | |
| FROM products_to_categories | |
| WHERE categories_id | |
| IN ( | |
| SELECT categories_id | |
| FROM categories | |
| WHERE parent_id | |
| IN ( |
| <?php | |
| /** | |
| * read the configuration settings from the db | |
| * | |
| * see {@link http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#InitSystem wikitutorials} for more details. | |
| * | |
| * @package initSystem | |
| * @copyright Copyright 2003-2005 Zen Cart Development Team | |
| * @copyright Portions Copyright 2003 osCommerce | |
| * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 |
| def truncate_str(mstr, length): | |
| if length > len(mstr) : return mstr | |
| return mstr[:length].rpartition(' ')[0] + ' ...' |
Configuring Nginx to serve SSL content is straight forward, once you have your certificate and key ready:
server {
listen 443 default ssl;
root /path/to/source;
server_name mydomain;
ssl_certificate /path/to/cert;
ssl_certificate_key /path/to/key;