Skip to content

Instantly share code, notes, and snippets.

@aj-justo
aj-justo / gist:0d24c5623bed39cb14f5
Last active August 29, 2015 14:06
Cordova development notes (versions 2.8.x)
@aj-justo
aj-justo / gist:5faa35af700ddbd12971
Last active August 29, 2015 14:06
Bootstrap notes: from v2 to v3

Bootstrap notes: from v2 to v3

  • .verticallyCollapsed: removes vertical margins

  • @grid-float-breakpoint: override value to set the point at which the the navbars etc collapse for mobile

  • .container vs .container-fluid: .container sets a fixed width, .container-fluid uses full width that adapts to device width. Important: Bootstrap 3.0 does not have container-fluid, it is the default (but it does not work with row/cols because the container class is the one that sets the negative margin to compensate for the gutter of the last col). We have to use:

@aj-justo
aj-justo / gist:3228782
Created August 1, 2012 17:02
SSL setup with Nginx + Gunicorn + Django 1.3 or 1.4

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;

@aj-justo
aj-justo / gist:3226316
Created August 1, 2012 12:11
"timeits" with python 2.7.2 on OSX

Filter out None values from list

>>> 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

@aj-justo
aj-justo / safe string truncate in python
Created April 18, 2012 06:51
safe truncate in python
def truncate_str(mstr, length):
if length > len(mstr) : return mstr
return mstr[:length].rpartition(' ')[0] + ' ...'
@aj-justo
aj-justo / init_db_config_read.php
Created May 31, 2011 18:35
Zen cart: override init_db_config_read.php to allow use of MAX_DISPLAY_SEARCH_RESULTS value for search results listings
<?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
@aj-justo
aj-justo / Zencart_SQL_products_in_main_category
Created May 30, 2011 14:50
Zen Cart: Select all products in a main category AND its subcategories (with a level 2 nesting)
SELECT *
FROM products_to_categories
WHERE categories_id
IN (
SELECT categories_id
FROM categories
WHERE parent_id
IN (
@aj-justo
aj-justo / ruby_rename_images
Created May 27, 2011 11:23
Rename images with given pattern
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
@aj-justo
aj-justo / ZenCart_SQL_Get_Orders_Total_Average
Created May 27, 2011 10:31
Zen Cart SQL: Get average order total for given time period
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'
@aj-justo
aj-justo / ZenCart_SQL_Get_Completed_Orders
Created May 27, 2011 10:25
Zen Cart SQL: Get all completed orders (status=x)
SELECT * FROM orders o, `orders_total` ot
WHERE o.orders_id=ot.orders_id AND
o.orders_status=3 AND
ot.title='total:'