Skip to content

Instantly share code, notes, and snippets.

View majimenezp's full-sized avatar

Miguel Jimenez majimenezp

  • Taan
  • Merida, Yucatan. Mexico
  • 05:21 (UTC -06:00)
View GitHub Profile
[[[NSNotificationCenter defaultCenter] rac_addObserverForName:NSWindowDidResizeNotification object:nil]
subscribeNext:^(id x) {
NSLog(@"cambio de tamaño de la ventana");
}];
@majimenezp
majimenezp / nydus.erl
Created October 30, 2013 00:03
Un proxy sencillo en Erlang en un solo archivo,no mas pa practicar este lenguaje
-module(nydus).
-export([test/0]).
-export([listener/1]).
-compile(debug_info).
test()->
listener(3333).
listener(Port) ->
spawn(fun () -> {ok, Sock} = gen_tcp:listen(Port, [inet,binary,{active, false}]),
mainLoop(Sock) end).
@majimenezp
majimenezp / dominio.cs
Created October 17, 2013 15:43
Configuracion de dominio para usar redis como un 2nd level cache para fluent nhibernate
this.cadConexion = System.Configuration.ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString;
this.currentSession = Fluently
.Configure()
//.Database(SQLiteConfiguration.Standard.UsingFile("c:\\rfid.sqlite"))
.Database(PostgreSQLConfiguration.PostgreSQL82.ConnectionString(this.cadConexion))
//.Database(MsSqlConfiguration.MsSql2005.ConnectionString(this.cadConexion))
// aca podemos usar el provider de nuestra preferencia
.Cache(cache => cache.ProviderClass(typeof(NHibernate.Caches.Redis.RedisProvider).AssemblyQualifiedName).UseSecondLevelCache().UseQueryCache())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<DominioApp>())
@majimenezp
majimenezp / backboneEach.js
Created September 5, 2013 16:48
Como handlebars en el each no soporta el tipo Backbone.Collection, con este helper uno puede recorrer la coleccion pasándola a un objeto json para que handlebars la pueda renderear.
Handlebars.registerHelper('eachBackbone', function (context, options) {
var context1 = context.toJSON();
var fn = options.fn, inverse = options.inverse;
var i = 0, ret = "", data;
var current;
if (options.data) {
data = Handlebars.createFrame(options.data);
}
if (context1 && typeof context1 === 'object') {
@majimenezp
majimenezp / aplicacionModel.js
Created June 18, 2013 22:28
Modelo de entidad aplicacion para emberjs
S.RESTAdapter.map('App.Aplicacion', {
nombre: { key: 'Nombre' },
instancias: { key: 'Instancias', embedded: 'always' },
uid: { key: 'UId' }
});
DS.RESTAdapter.map('App.Instancia', {
primaryKey:"id",
id_ubicacion: { key: 'IdUbicacion' },
base_de_datos: { key: 'BasesDeDatos', embedded: 'always' }
@majimenezp
majimenezp / AppDomainAssemblyTypeScanner.cs
Created March 21, 2013 20:25
With the new Assembly type scanner, when nancy search for the dll containing references to Nancy, where tries to load a dll that not are managed code(for example SQLite.Interop.dll or libzmq.dll) the method LoadAssembliesWithNancyReferences fromthe class AppDomainAssemblyTypeScanner throw a BadImageException. It's only need a try catch to not sh…
public static void LoadAssembliesWithNancyReferences()
{
if (nancyReferencingAssembliesLoaded)
{
return;
}
UpdateAssemblies();
foreach (var directory in GetAssemblyDirectories())
@majimenezp
majimenezp / dsl.g
Created December 13, 2011 20:19
Paser para DSL de reglas en ANTLR
grammar DSL;
/*
si datos.mensaje contiene "hidrostatica" o "pnd" o "corrosivas"
entonces devuelve "formato pruebas 01"
sino devuelve "no encontrado"
*/
tokens {
SI='si';
SINO='sino';
@majimenezp
majimenezp / testGenericNhibernate.cs
Created October 14, 2011 17:36
Test de nhibernate con consulta usando generics y linq
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using FluentNHibernate.Automapping;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
@majimenezp
majimenezp / NancyOwinHost.cs
Created September 29, 2011 17:12
The owin host in kayak not set the cookies, i added this code and works
private void InvokeNancy(NancyRequestParameters parameters, ResponseCallBack responseCallBack, Action<Exception> errorCallback)
{
try
{
parameters.Body.Seek(0, SeekOrigin.Begin);
var request = new Request(parameters.Method, parameters.Url, parameters.Body, parameters.Headers);
// Execute the nancy async request handler
this.engine.HandleRequest(
@majimenezp
majimenezp / AttachmentFileResponse.cs
Created August 18, 2011 21:28
Class for reponse file as attachment in #NancyFX
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nancy;
using System.IO;
namespace Nancy
{
public class AttachmentFileResponse : Response
{