Skip to content

Instantly share code, notes, and snippets.

PDFDocument = require 'pdfkit'
doc = new PDFDocument
# Embed a font, set the font size, and render some text
doc.font('fonts/PalatinoBold.ttf')
.fontSize(25)
.text('Some text with an embedded font!', 100, 100)
# Add another page
doc.addPage()
@hgarcia
hgarcia / server.js
Created October 12, 2011 00:25
Vanilla exec and response
var http = require('http');
var exec = require('child_process').exec;
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
exec('curl www.yahoo.com', function (error, stdout, stderr) {
//Parse stdout/stderr if/as needed
@hgarcia
hgarcia / complicate-callback.js
Created May 22, 2011 04:19
nodejs-post-3-weeks
app.put('/model', function(req,res){
service.doWork(req.body,function(result){
if(result){
db.setStatus(result, function(){
res.redirect('/ok');
});
}
});
});
<script>
function defineVarInside(){
x = 15;
}
defineVarInside();
document.write(x); //15;
</script>
<script>
/*
URL:
http://localhost/luca/site?movie=18&movie=22&movie=25
*/
var movies = request.query.movie; // ['18','22','25']
var firstMovie = request.query.movie[0]; // '18';
@hgarcia
hgarcia / main01.js
Created November 12, 2010 05:07
luca-structure.txt
/-
|_bin
|_Antlr3.Runtime.dll
|_Jint.dll
|_Luca.Core.dll
|_Luca.Jint.dll
|_Newtonsoft.Json.dll
|_controllers
|_main.js
|_views
this.request.query.id
//or
this.request.query['id']
public class PrototypeArrays : IExtension
{
private JsConstructor Target { get; set; }
public void ExtendTarget(JsConstructor target)
{
Target = target;
Target.Prototype.DefineOwnProperty("collect", Target.Global.FunctionClass.New<JsObject>(CollectImpl), PropertyAttributes.DontEnum);
Target.Prototype.DefineOwnProperty("clear", Target.Global.FunctionClass.New<JsArray>(ClearImpl), PropertyAttributes.DontEnum);
Target.Prototype.DefineOwnProperty("clone", Target.Global.FunctionClass.New<JsArray>(CloneImpl), PropertyAttributes.DontEnum);
Target.Prototype.DefineOwnProperty("toArray", Target.Global.FunctionClass.New<JsArray>(CloneImpl), PropertyAttributes.DontEnum);
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Model" namespace="Model">
<class name="Scene" table="Scene">
<composite-id>
<key-property column ="Code" name="Code"/>
<key-property column ="Scene" name="SceneID"/>
</composite-id>
<set name="Stars" lazy="false" table="Scene2Star">
<key>
<column name="Movie"/>
# this doesn't work
doesnt_work = {|v=0| puts v}
# while this does
it_works = -> (v=0) { puts v}