Skip to content

Instantly share code, notes, and snippets.

View kapouer's full-sized avatar
💭
finalizing pageboard, next gen website editor

Jérémy Lal kapouer

💭
finalizing pageboard, next gen website editor
View GitHub Profile
@kapouer
kapouer / gist:74ee29861971d99fd5dc
Created May 25, 2014 23:15
node-orm2 PostGIS custom type example
orm.db.defineType('GeoJSON', {
datastoreType: function GeoJSON_datastoreType(prop) {
return 'geometry(Geometry, 4326)';
},
datastoreGet: function GeoJSON_datastoreGet(prop, helper) {
return 'ST_AsGeoJSON(' + prop.mapsTo + ')::JSON';
},
valueToProperty: function GeoJSON_valueToProperty(value, prop) {
if (typeof value == "string") return JSON.parse(value);
else return value;
@kapouer
kapouer / gist:566615bbb9929e99d765
Created October 13, 2014 18:16
ogr2ogr no error but error
var ogr2ogr = require('../')
var sampleNogeom = __dirname+'/samples/sample-nogeom.csv'
// createdb|dropdb nogeomtest
ogr2ogr(sampleNogeom)
.format("PostgreSQL")
.project("EPSG:4326")
.destination('PG:dbname=nogeomtest')
function getXml(url, cb) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function (e) {
if (xhr.readyState == 4) {
var code = xhr.status;
if (code >= 200 && code < 400) {
cb(null, xhr.responseXML);
} else {
var err = new Error(xhr.responseText);
session rights /lefigaro.fr s4sfqJBi5_euHMCU3WBAS68g5Axx5kCW [ 'read' ] [ 'write lefigaro.fr', 'auth' ]
set sid:s4sfqJBi5_euHMCU3WBAS68g5Axx5kCW
GET 200 20.783 ms /lefigaro.fr?auth=01020304 - 49
set right=auth&type=json http://localhost:3000/lefigaro.fr?auth=01020304
set right=auth&type=json http://localhost:3000/lefigaro.fr?auth=01020304
set sid:zWqh4RmAw5HX9i3ShrUavG2JUf8oH6sZ
GET 302 55.039 ms /lefigaro.fr/test/write?_token=123456 - 102
vary for { right: 'read,write lefigaro.fr' }
vary for { right: 'read' }
vary for { right: 'write lefigaro.fr' }
Comment soumettre un formulaire ?
1. Validation en javascript
Quand valide, javascript envoie le formulaire en XHR - ou si on veut
gagner du temps, on peut soumettre le formulaire par HTML.
2. POST vers l'url du document
La route s'occupe de faire la requête correcte vers la ressource concernée,
et ce qui est renvoyé dépend du client:
- si HTML, on fait une redirection
Resource.relationMappings = {
27 + children: {
28 + relation: Model.ManyToManyRelation,
29 + modelClass: Resource,
30 + join: {
31 + from: 'raja_resources.id',
32 + through: {
33 + from: 'raja_relations.parent_id',
34 + to: 'raja_relations.child_id'
35 + },
From bffadf6a55e99291270b7c95c4787ff19ef63348 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= <kapouer@melix.org>
Date: Wed, 22 Dec 2010 14:31:03 +0100
Subject: [PATCH] mysql adapter should create table with default charset.
This fixes :
https://rails.lighthouseapp.com/projects/8994/tickets/5830-mysql-adapter-should-create-table-with-default-charset
---
.../connection_adapters/mysql2_adapter.rb | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
@kapouer
kapouer / man syntax node.1 v0.4.0
Created February 14, 2011 19:09
correct a small syntax error in manpage of node v0.4.0
--- a/doc/node.1
+++ b/doc/node.1
@@ -44,7 +44,7 @@
.SH ENVIRONMENT VARIABLES
.IP NODE_PATH
-':'-separated list of directories prefixed to the module search path,
+\':\'\-separated list of directories prefixed to the module search path,
require.paths.
@kapouer
kapouer / no_ssl_v2.patch
Created April 10, 2011 15:30
Add --no-ssl2 option to disable ssl2 methods
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -98,11 +98,23 @@
String::Utf8Value sslmethod(args[0]->ToString());
if (strcmp(*sslmethod, "SSLv2_method") == 0) {
+#ifndef OPENSSL_NO_SSL2
method = SSLv2_method();
+#else
+ return ThrowException(Exception::Error(String::New("SSLv2 methods disabled")));
@kapouer
kapouer / gist:1306112
Created October 22, 2011 15:28
GPIO imac 12,2
--- sound/pci/hda/patch_cirrus.c.orig 2011-09-02 10:07:32.013460479 +0200
+++ sound/pci/hda/patch_cirrus.c 2011-09-02 10:07:45.604995395 +0200
@@ -922,7 +922,7 @@
if (spec->board_config == CS420X_MBP53 ||
spec->board_config == CS420X_MBP55 ||
spec->board_config == CS420X_IMAC27) {
- unsigned int gpio = hp_present ? 0x02 : 0x08;
+ unsigned int gpio = hp_present ? 0x04 : 0x08;
snd_hda_codec_write(codec, 0x01, 0,
AC_VERB_SET_GPIO_DATA, gpio);