Skip to content

Instantly share code, notes, and snippets.

@gabriel-dehan
gabriel-dehan / container.html
Created April 20, 2012 09:09
How to implement a router in Meteor-0.3.2
/* It calls the content helper, and then load the Template matching the route :
for exemple, /user/list will load the template "user_list"
It's not optimum but it works
*/
<template name="container">
<div class="container">
{{#content}}
{{/content}}
</div>
</template>
@gabriel-dehan
gabriel-dehan / flash_messenger.js
Created April 21, 2012 13:13
Flash messenger with meteor 0.3.3
Meteor.call('login', name, pass, function(error, user){
if ( error ) {
Session.set('message', error.error + ': ' + error.reason);
} else {
Session.set('message', 'You are now connected, ' + user.name + '.');
Session.set('user', user);
}
MyApp.navigate('/user/list');
});
@gabriel-dehan
gabriel-dehan / error.txt
Created April 22, 2012 00:25
Twitter streaming with node.js Meteor 0.3.3
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
ReferenceError: require is not defined
at app/node_modules/twitter-node/lib/twitter-node/index.js:1:20
at /Users/Diacred/Work/Meteor/penis/little-test-projet-meteor/.meteor/local/build/server/server.js:111:21
at Array.forEach (native)
at Function.<anonymous> (/Users/Diacred/Work/Meteor/penis/little-test-projet-meteor/.meteor/local/build/server/underscore.js:76:11)
at /Users/Diacred/Work/Meteor/penis/little-test-projet-meteor/.meteor/local/build/server/server.js:97:7
Exited with code: 1
@gabriel-dehan
gabriel-dehan / deletefunction.js
Created April 23, 2012 23:02
Recursively delete in an Object tree and retrieve deleted node
var Tree = Base.extend({
constructor: function(tree) {
this.tree = tree;
this.count = this.count_nodes(0);
},
delete: function(node_id, tree){
var that = this;
if ( tree === undefined ) tree = that.tree;
_.each(tree, function(node, i){
@gabriel-dehan
gabriel-dehan / edit.html
Created May 1, 2012 13:13
Meteor wysiwyg livedata
<template name="editor">
<div class="well {{#if editor_mode}}editor-show{{/if}}" id="editor">
<textarea id="editor-area" placeholder="Enter your text ...">{{get_file}}</textarea>
</div>
</template>
@gabriel-dehan
gabriel-dehan / User.rb
Created June 29, 2012 08:36
OwningRails#Question
# So we have something like this :
class User
class << self
def find_by_sql(sql)
rows = @@connector.execute(sql)
# => [[1, 'Marc']]
rows.map do |row|
attributes = match_columns_to_values(row)
@gabriel-dehan
gabriel-dehan / _application_helper.rb
Created July 4, 2012 09:52
Authentication integration test with rspec/devise
module ApplicationHelper
# Public: display an inline user authentication interaction
#
# Returns the generated html String.
def display_user_authentication
if user_signed_in?
render 'devise/menu/logout_button'
else
render 'devise/menu/login_form'
end
@gabriel-dehan
gabriel-dehan / ga.js
Created October 18, 2012 16:20
Basic Hello World Genetic Algorithm
var ga = new GA();
ga.processGeneration();
ga.mateNextGeneration();
function GA() {
this.generation = [
"Gekmo+ xosmd!",
"Gekln, worle'",
"Fello, wosld!",
"Gello, wprld!",
@gabriel-dehan
gabriel-dehan / application.handlebars
Created November 30, 2012 15:37
Ember.js Issue with double outlet rendering
<h1>Ember Comitters</h1>
{{outlet poney}}
{{outlet}}
@gabriel-dehan
gabriel-dehan / [Prog][General][Readings]
Created December 9, 2012 23:04
A Gist of Important Links, full of kitten, but not so much of lamas.
[Books]
The story of computing : http://www.amazon.com/Engineers-Scientists-Iconoclasts---Programmers-Revolution/dp/0465042260/ref=sr_1_1?s=books&ie=UTF8&qid=1324406043&sr=1-1