Skip to content

Instantly share code, notes, and snippets.

View k33g's full-sized avatar
💭
Read my code at https://gitlab.com/k33g

Philippe Charrière k33g

💭
Read my code at https://gitlab.com/k33g
View GitHub Profile
@k33g
k33g / redirect.js
Created January 19, 2012 17:49
node.js redirection
response.setHeader('Location', url);
response.setHeader('Content-Length', body.length);
response.setHeader('Content-Type', 'text/html');
response.statusCode = 302;
response.end(body);
@k33g
k33g / redirect.js
Created January 19, 2012 17:49
node.js redirection
response.setHeader('Location', url);
response.setHeader('Content-Length', body.length);
response.setHeader('Content-Type', 'text/html');
response.statusCode = 302;
response.end(body);
@k33g
k33g / ejs-template-01.html
Created February 26, 2012 07:58
ejs-template-01
<% if(!everyauth.loggedIn) { %>
<h2>Not Authenticated</h2>
<a href="/auth/twitter">Who am i with twitter</a>
<% } else {%>
<h3>Twitter User Data</h3>
<p>
<%= JSON.stringify(everyauth.twitter.user) %>
</p>
<% } %>
@k33g
k33g / ejs-template-02.html
Created February 26, 2012 08:02
ejs-template-02
<% if(!everyauth.loggedIn) { %>
<h2>Not Authenticated</h2>
<a href="/auth/twitter">Who am i with twitter</a>
<% } else {%>
<h3>Twitter User Data</h3>
<p>
<img src="<%= everyauth.twitter.user.profile_image_url %>"/>
<h2>Welcome <%= everyauth.twitter.user.name %></h2>
</p>
<% } %>
@k33g
k33g / ejs-template-03.html
Created February 26, 2012 08:03
ejs-template-03
<!-- mon formulaire de saisie -->
<div id="snippet-form">
<h2>Go ...</h2>
<form action="/" class="well">
<label>Title : </label>
<input id="title" type="text" class="span3" style="width:100%" placeholder="title"/>
<label>Code Snippet : (with markdown) </label>
<textarea id="code" placeholder="code" style="width:100%" rows="5"></textarea>
<!-- on ajoute un compteur -->
@k33g
k33g / lazy.coder.sh
Created February 27, 2012 22:34
Lazy.Coder Shell Script : create express.js app with dependencies
# /bin/sh
#chmod a+x lazy.coder.sh
#parameter : application name : ./lazy.coder.sh <application_name>
#Libs
#Gimme names
LIB1=jquery
LIB2=underscore.js
LIB3=backbone.js
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.k33g.bb.BBModel;
import java.util.ArrayList;
import java.util.Map;
import static org.k33g.bb.BBMap.$;
import static org.k33g.bb.BBMap.Attributes;
class Human extends BBModel {
@k33g
k33g / mystack.js
Created March 9, 2012 20:51
generate express app with gimme
module.exports = mystack_cmd;
var fs = require('fs')
, path = require('path')
, exec = require('child_process').exec;
mystack_cmd.usage = "gimme mystack <appname>";
mystack_cmd.description = ['my personnal express.js boilerplate', "@k33g_org"];
@k33g
k33g / kind.js
Created April 2, 2012 20:29
Re Use Object Model of BackBone
// Just do this : (and include backbone.js)
var Kind = function() {
this.initialize && this.initialize.apply(this, arguments);
};
Kind.extend = Backbone.Model.extend
//Simpler
var Thing = function() {};
Thing.extend = Backbone.Model.extend