Skip to content

Instantly share code, notes, and snippets.

View rafaeljesus's full-sized avatar

Rafael Jesus rafaeljesus

  • Berlin, Germany
View GitHub Profile
@rafaeljesus
rafaeljesus / backbone_sync.js
Created March 21, 2014 18:24
Backbone parse with Faye
this.BackboneSync = this.BackboneSync || {};
BackboneSync.RailsFayeSubscriber = (function() {
function RailsFayeSubscriber(collection, options) {
this.collection = collection;
this.client = new Faye.Client(’<%= BackboneSync::Rails::Faye.root_address %>/faye’);
this.channel = options.channel;
this.subscribe();
}
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path
Criar um episódio e gerar classes do commonsTypes:
C:\Tools\jaxb-ri-20070122\bin>xjc -episode shared.episode -p com.embraer.erepair
.integration.outbound.shared shared\commonsTypes.xsd
parsing a schema...
compiling a schema...
com\embraer\erepair\integration\outbound\shared\AddressType.java
com\embraer\erepair\integration\outbound\shared\AmmountType.java
com\embraer\erepair\integration\outbound\shared\DocumentReferenceType.java
@rafaeljesus
rafaeljesus / jaxb_episodes_ex
Last active August 29, 2015 14:04
Jaxb + episodes generation example
bin\xjc -episode shared.episode -p com.embraer.erepair.integration.outbound.shared.request shared\commonsTypes.xsd
bin\xjc -p com.embraer.erepair.integration.outbound.awb.request awbDetailsRequest.xsd -extension -b shared.episode
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@rafaeljesus
rafaeljesus / student.java
Created August 20, 2014 11:26
dynamic class using map
public class Student {
private Map<String, String> properties = new HashMap<String, String>();
private Map<String, Callable<Object>> callables = new HashMap<String, Callable<Object>>();
public String getProperty(String key) {
return properties.get(key);
}
public void setProperty(String key, String value) {

This is a proof-of-concept of a couple of concurrent data structures written in Ruby.

The implementations are heavily commented for those interested. There are benchmarks (with results) included below. The results are interesting, but, as always, take with a grain of salt.

Data structures

AtomicLinkedQueue is a lock-free queue, built on atomic CAS operations.

callLog = [];
/* set up an override for the Function call prototype
* @param func the new function wrapper
*/
function registerOverride(func) {
oldCall = Function.prototype.call;
Function.prototype.call = func;
}

If you haven't read Netflix's Node.js in Flames blog post you should. It is a great deep dive into debugging a node performance problem. The post includes useful tips that can help you solve similar problems.

That said...

My feedback from the perspective of a framework developer is quite different. I found the tone and attitude towards express.js to be concerning and somewhat offensive. Here was a developer blaming the framework he chose for poor architecture when they never bothered to actually learn how the framework works in the first place. Everything that followed originated from this basic lack of understanding.

Express uses a very simple router logic which is at the core of how express works, so let’s examine that first (my knowledge of express is somewhat dated but I think the principle is still the same). Express keeps a hash of the various HTTP methods (GET, POST, etc.) and for each method, an array of middlewares. Each middleware is ju

/*
* repair_notification has_many quotations
* -------------
* | quotation |
* _______________________
* | id | notification_id |
*/
select * from
(select priority, notification_id, row_number() over(partition by notification_id order by quotation_date desc, createddate desc) seq from erm_quotation ) q
where q.seq = 1; -- return the first result, q.seq = 2 return the second result