Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string></string>
<key>IDECodeSnippetContents</key>
<string>class &lt;#MyClass#&gt;(osv.osv):
" &lt;#DOCString#&gt;"
#_name="My name"
Xcode 4 custom snippet
If you want to make your own custom snippets with in preview version of Xcode 4 and do not want to wait for the function to be implemented here is the way :
Open the folder ~/Library/Developer/Xcode/UserData/CodeSnippets
Create a file named my_nice_file.codesnippet (one file per snippet)
It should look like this : http://gist.github.com/521183
There is only one rule to respect :
@nbessi
nbessi / gist:993356
Created May 26, 2011 15:26
Nice Logger helper from Florent really useful
import netsvc
logger = netsvc.Logger()
class Logger(object):
"""Provide an API similar to the standard 'logging' module."""
__slots__ = ('name',)
def __init__(self, name):
@nbessi
nbessi / gist:1200785
Created September 7, 2011 14:54
GeoEngine CRUD support phase 1
from shapely.wkt import dumps as wktdumps, loads as wktloads
from shapely.geometry import Polygon, MultiPolygon
import geojson
from base_geoengine import geo_model
class NPA(geo_model.GeoModel):
_inherit = "res.better.zip"
_columns = {
'the_geom' : fields.geo_multi_polygon('NPA Shape', required=False),
@nbessi
nbessi / gist:1270572
Created October 7, 2011 15:42
GeoEngine Relational ORM support
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_greater', Polygon([(3, 0), (4, 1), (4, 0)]))])
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_greater', 0)])
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_intersect', {'geoengine.demo.automatic.retailing.machine.the_point': []})])
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_intersect', {'geoengine.demo.automatic.retailing.machine.the_point': [('name','!=','Vallorbe')]})])
#will generate
"""
SELECT "res_better_zip".id FROM "res_better_zip" WHERE (res_better_zip."name" ilike E'%Lausanne%') AND ST_Area(res_better_zip.the_geom) > ST_Area(ST_GeomFromText('POLYGON ((3.0000000000000000 0.0000000000000000, 4.0000000000000000 1.0000000000000000, 4.0000000000000000 0.0000000000000000, 3.0000000000000000 0.0000000000000000))')) ORDER BY pr
MYCONST = ('new_val', 'New Label')
class Partner(osv.osv):
"""My Stuff"""
_inherit = 'res.partner'
def __init__(self, pool, cursor):
"""Hack due to the lack of selection fields inheritance mechanism."""
super(Partner, self).__init__(pool, cursor)
@nbessi
nbessi / gist:1351717
Created November 9, 2011 15:11
Decorator with boilerplate for OSV methods.
#Thanks to Florent for the function.
#Really useful.
def osv_method(f):
"""Decorator with boilerplate for OSV methods."""
args, varargs, kwargs, defaults = getargspec(f)
len_argspec = len(args) - 4
# Sanity check: no *args or **kwargs parameters
@nbessi
nbessi / gist:1931739
Created February 28, 2012 10:17
PGSQL OpenERP traceback 6.1
#Removed some output related to extra-addons
STATEMENT: ALTER TABLE "res_partner_address" ALTER COLUMN "country_id" SET NOT NULL
ERROR: column "smtp_host" contains null values
STATEMENT: ALTER TABLE "ir_mail_server" ALTER COLUMN "smtp_host" SET NOT NULL
@nbessi
nbessi / gist:1944505
Created February 29, 2012 21:23
Tough on OERPScenario DSL
using https://github.com/rvalyi/ooor/pull/81 in background
Given I find or create by login a ResUsers "admin" with
| key | val |
| partner_id | find by xml_id blabla |
#or
| partner_id | find by name and login! Pinky, daBoss |
and why not
(ns repl.xml_to_csv
(:use [hiccup.core]
[clojure-csv.core :as csv]))
(defn csv-data [] (csv/parse-csv (slurp "/Users/nbessi/Downloads/doc/zip.csv")))
(defn render-line [line]
(html [:record {:id (line 0), :model "res.better.zip"}
[:field {:name "name"} (line 1)]
[:field {:name "city"} (line 2)]
[:field {:name "state_id", :ref (str "state_" (line 3))}]