Skip to main content

Posts

Making Celery 4 work in Django 1.10 and Elastic Beanstalk

Finally after many many days of trying to make it work and reading thousand of pages, I got Celery working with django 1.10 in Amazon AWS Elastic Beanstalk with SQS (Simple Queue Services) – including Celery Beat!. First, the files I ended up with, then the explanation of what I understand (some of those things still remain being a mystery) STEP 0: Install using the following: pip install -U celery[sqs] pip install django-celery-beat I’m using the following versions of the apps: boto (2.45.0) botocore (1.4.63) celery (4.0.2) Django (1.10.1) django-celery-beat (1.0.1) kombu (4.0.2) pip (9.0.1) pycurl (7.43.0) FILE: /src/PROJECT_NAME/celery.py from __future__ import absolute_import , unicode_literals import os from celery import Celery # set the default Django settings module for the 'celery' program. # DONE IN __init__.py os . environ . setdefault ( "DJANGO_SETTINGS_MODULE" , "PROJECT_NAME.settings.production" ) app = Celery ( 'PR...

Stripping HTML from text in SQL Server–Version 3

  I’ve used the HTML stripping function for SQL Server available in lazycoders.blogspot.com , which is the second version of the originally published in blog.sqlauthority.com . But neither one removes the comments in this case: <!-- <b>hello world</b> --> Hello which is more or less the code that MS Word generates. Well, the function with that fixed is this (changes are in bold): ALTER FUNCTION [dbo].[DeHtmlize] ( @HTMLText varchar ( MAX ) ) RETURNS varchar ( MAX ) AS BEGIN DECLARE @ Start int DECLARE @ End int DECLARE @Length int -- Replace the HTML entity &amp; with the '&' character (this needs to be done first, as -- '&' might be double encoded as '&amp;amp;') SET @ Start = CHARINDEX( '&amp;' , @HTMLText) SET @ End = @ Start + 4 SET @Length = (@ End - @ Start ) + 1 WHILE (@ Start > 0 AND @ End > 0 AND @Length > 0) BEGIN SET @HTMLText = STUFF(@HTMLText, @ Start , @Le...

NHibernate: Using multiple database schemas with SchemaExport

Let's say you want to use NHibernate, and have tables on multiple schemas on your database. I'm using SQL Server, and my quick solution is not supported by all the databases NH supports, but it shouldn't be hard to change. If you run the SchemaExport, you will receive an error telling you that the DB schema does not exist or you have no access to it. It makes sense since the utility does not handle multiple schemas. Well, here's a simple code snipped I've written after debugging and digging into the NH source code: private void CreateSchema() { var provider = ConnectionProviderFactory.NewConnectionProvider(NHConfigs.Properties); using (var connection = provider.GetConnection()) { using (var cmd = connection.CreateCommand()) { cmd.CommandText = "IF (SCHEMA_ID('your_schema_name') IS NULL) EXEC('CREATE SCHEMA your_schema_name')" ; cmd.ExecuteNonQuery(); } provider.CloseConnect...

FitNesse + Selenium = Acceptance Testing

Update: I don't know why I've written this post in English, the presentation is in Spanish. The virtual ALT.NET was about acceptance testing, and mainly about FitNesse. It's publicly available on http://altnet-hispano.pbworks.com/van-2010-01-16-fitnesse . Hopefully any .NET developer will be able to easily setup an Acceptance Testing environment after watching this video; I've tried to cover all the important stuff required to start using it. Special thanks to Jorge Gamba for editing the video and making the whole presentation possible. Enjoy!

Full Text Searching XMLs (Lucene.NET Version)

There was a question in a spanish DBMS list, because a guy was trying to use the SQL Server Full Text Search for indexing any object in the application. The objects were being serialized as XML objects and indexed using the FTS engine, but it started to became complex when trying to perform the query. Anyway, this post is not about SQL Server, but Lucene.NET . So, I started playing again with that and I end up with this: Download Source Code . I guess this test describes all the power of the mini-framework built over Lucene: public void MixObjects() { var obj = new Foo() .SetDescription( "hello world" ) .AddBar( "text containing the word happy" ) .AddBar( "some comments the word programming" ); var obj2 = new Bar( "some comments" ); Engine.IndexObject(obj, 5); Engine.IndexObject(obj2, 5); Engine.DumpIndexInfo(); Assert.Equal(1, Engine.LookForAll() .Where( @...

Added Notes to ZedGraph

ZedGraph has a really good support for extending it, and it's well documented in the code if you want to try to do it. Today, I've just created a new object called AnnotationObj (the Obj postfix is due to ZedGraph conventions). To use it, you just have to include this .cs file in you source: http://tinyurl.com/cqgwcc After that, you can add your own notes this way: var annotationObj = new AnnotationObj(MyGraph, position, "this will be the tooltip" ); MyGraph.GraphPane.GraphObjList.Add(annotationObj); This is how it will look: From this.Blog

Worst UI You’ve Ever Used

This post was copied from an answer in stackoverflow ... But, still the winner is the awsome IBM Lotus Notes

Hacking ASP.NET - Rendering Controls Alone

Sometimes we want to render just a control into the client browser using native ajax (I mean, without atlas or ajax extensions), but it's not as easy as you could think... For example, if you have to render a GridView alone, without another html information you will probably see some unknown exceptions... - 1st try The first thing I made was create an empty aspx page (with no html tags) and add a GridView, but oops!, when I runned it, asp.net throws a exception saying that all the controls need to be inside a html <form>... It has sense, so close IE and try again... - 2nd try Ok... Now I already added the <form> tag into the aspx page, opened it into the browser and everything works great. But wait!, I still haven't the ajax part written.... it's not hard to do, I just have to create a XMLHttpRequest in javascript and write the response into a <div>.. When I run the page containing the ajax script, IE throws a 'Unknown Error' exactly where i wr...

Reflection sobre .aspx, eh?

Acceder a absolutamente todo mediante reflection es algo que se es poniendo cada vez mas de moda y puede traer varios problemas. Pero no voy a hablar de como solucionar los problemas sino de como usar Reflection aun mas :) En algunos casos puede ser muy util ver que controles hay en una pagina que de mi aplicacion, por ejemplo puede servir para configurar permisos sobre controles como Toolbars o Grillas, editar informacion dinamicamente en base a WebParts de otras paginas, etc.. Cuando se crea un Toolbar en una pagina lo mas normal es cargar la informacion sobre que operaciones (botones) tiene en una base de datos manualmente, pero es aun mucho mejor si la pagina en la que se configuran esos permisos puede saber automaticamente que botones tiene cada pagina.... Lo primero que hay que hacer para obtener una pagina es crear un PageHandler, para eso lo unico necesario es la URL, por ejemplo "/Carpeta/Pagina1.aspx": // Creo un Request Mock, realmente no se va a realizar ning...

WakeUp on LAN

(Este articulo fue publicado hace un tiempo en El Guille ) Como funciona? El WakeUp On Lan, permite encender una pc de forma remota, siempre y cuando la computadora remota lo permita y este habilitado desde el BIOS de la pc. Para permitir el encendido remoto, la pc que se va a encender requiere estar conectada via ethernet (configuracion utilizada en casi todas las redes) y poseer la tecnología ACPI, que aunque es una tecnología bastante antigua, solo es permitido en las computadoras con fuentes ATX, las cuales vienen en todos los modelos desde hace unos cuantos años. Para permitir el encendido, la computadora debe estar "escuchando" (o listening) en el puerto 9 de la interfaz de red, esto se hace solamente habilitando una opción en el BIOS (siempre y cuando este permitido!). Los mensajes que espera recibir son de cualquier protocolo, aunque se usa UDP por el modelo de coneccion que utiliza. El protocolo A la hora de enviar un mensaje, hay que utilizar un protocolo ...