Skip to content

Instantly share code, notes, and snippets.

View ianjosephwilson's full-sized avatar

Ian Wilson ianjosephwilson

View GitHub Profile
@ianjosephwilson
ianjosephwilson / gist:848678
Created March 1, 2011 05:37
Fixed JsLint Hook
; A better solution, just ignore irregular case extensions completely.
(defun jslint-hook ()
(let* ((filename (buffer-file-name))
(suffix (file-name-extension filename)))
(if (and filename (string= suffix "js"))
(call-interactively 'compile))))
(add-hook 'after-save-hook 'jslint-hook)
def human_readable_datetime(dt):
right_now = datetime.now()
if right_now.year == dt.year:
if right_now.month == dt.month:
# Same day
if right_now.day == dt.day:
datetime_format = '%I:%M %p'
# Within 2 days.
elif right_now.day <= dt.day + 2 and right_now.day >= dt.day - 2:
datetime_format = '%a %I:%M %p'
def human_readable_datetime(dt):
right_now = datetime.now()
if right_now.year == dt.year:
if right_now.month == dt.month:
# Same day
if right_now.day == dt.day:
datetime_format = '%I:%M %p'
# Within 2 days.
elif right_now <= dt + timedelta(days=2) and \
right_now >= dt - timedelta(days=2):
@ianjosephwilson
ianjosephwilson / gist:2396292
Created April 16, 2012 04:03
Pyramid route factory for a blog post.
class Post(object):
#...
@classmethod
def factory(cls, request):
if 'post_id' in request.matchdict:
post = cls.from_identifier(request.matchdict['post_id'])
if not post or not post.is_published():
raise NotFound()
var Feed = {
highlightStory: function () {
var uri, urlQuery, storyId, queryObject, storyGroupEl;
uri = window.location.search.toString();
urlQuery = uri.substring(uri.indexOf("?") + 1, uri.length);
queryObject = ioQuery.queryToObject(urlQuery);
if (queryObject.story_id) {
storyId = queryObject.story_id;
window.location.hash = storyId;
} else {
<record model="ir.ui.view" id="inventory_view_form">
<field name="model">inventory.inventory</field>
<field name="type">form</field>
<field name="arch" type="xml">
<![CDATA[
<form string="Inventory" col="4">
<label name="warehouse"/>
<field name="warehouse"/>
<label name="lost_found"/>
<field name="lost_found"/>
@ianjosephwilson
ianjosephwilson / search_value
Created January 18, 2013 23:25
search domain for inventories
<record model="ir.action.act_window" id="act_inventory_form">
<field name="name">Inventories</field>
<field name="res_model">inventory.inventory</field>
<field name="search_value">[('create_date', '>=', DateTime(hour=0, minute=0, second=0, microsecond=0, delta_years=-1))]</field>
</record>
<%def name="layoutdata(somedata)">
<table>
% for item in somedata:
<tr>
% for col in item:
<td>${caller.body(col=col)}</td>
% endfor
</tr>
% endfor
</table>
<record model="ir.action.act_window" id="act_inventory_form">
<field name="name">Inventories</field>
<field name="res_model">inventory.inventory</field>
<field name="search_value">[('create_date', '>=', DateTime(hour=0, minute=0, second=0, microsecond=0, delta_years=-1))]</field>
</record>
File "/home/ian/workspace/tryton-project/stockmodules-tryton-2.6/tryton-instance/tryton/tryton/gui/window/view_form/view/list.py", line 732, in __sig_switch
if not self.screen.row_activate() and self.children_field:
diff -r 91e0c59c47aa tryton/common/domain_parser.py
--- a/tryton/common/domain_parser.py Thu Jan 03 16:29:35 2013 +0100
+++ b/tryton/common/domain_parser.py Sat Jan 19 13:33:42 2013 -0800
@@ -749,9 +749,9 @@
def string_(clause):
if not clause:
return ''
- if (isinstance(clause[0], basestring)
- and (clause[0] in self.fields
- or clause[0] == 'rec_name')):