tag:blogger.com,1999:blog-75531495161210876312024-02-19T22:06:05.817-08:0033 NotasJM Trujillohttp://www.blogger.com/profile/07329322432631758432noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-7553149516121087631.post-61708742736471234402014-05-14T01:43:00.000-07:002014-05-14T01:45:03.041-07:00Simple things are fun.After a couple or hours doing nothing, I found a question related to a simple algorithm about a <a href="http://www.geeksforgeeks.org/find-subarray-with-given-sum/">Subarray</a>, here is the immproved single loop O(n) worst case python version.<br />
<br />
<div>
<br /></div>
<script src="http://ideone.com/e.js/MrRt5z" type="text/javascript"></script>JM Trujillohttp://www.blogger.com/profile/07329322432631758432noreply@blogger.com0tag:blogger.com,1999:blog-7553149516121087631.post-20966604778835860682011-02-01T14:50:00.000-08:002011-02-01T15:03:17.390-08:00How to delete all files from a directory but X<span class="Apple-style-span" style="color: #cccccc; font-family: Verdana, Geneva, sans-serif; font-size: 12px; line-height: 16px;"></span><br />
<div class="post-body entry-content" style="font-size: 13px; line-height: 1.4; position: relative; width: 710px;">We can use find for this!<br />
<i>find . -not -name 'X' -delete</i></div>JM Trujillohttp://www.blogger.com/profile/07329322432631758432noreply@blogger.com0tag:blogger.com,1999:blog-7553149516121087631.post-40046976082525816492011-02-01T14:48:00.000-08:002011-02-01T14:49:09.044-08:00Como borrar todos los archivos de un directorio menos XPara borrar los archivos de un directorio menos X archivo en unix se puede usar:<br />
<i><br />
</i><br />
<i>find . -not -name 'X' -delete</i>JM Trujillohttp://www.blogger.com/profile/07329322432631758432noreply@blogger.com0tag:blogger.com,1999:blog-7553149516121087631.post-77627401616902972032011-01-20T01:09:00.000-08:002011-01-20T01:17:10.260-08:00web.py-starter-template<span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: x-small;"><span class="Apple-style-span" style="line-height: 18px;">I has been working in my part of my spare time ( a lot lately) in an application template for <a href="http://webpy.org/">web.py</a>. I just started this because i wanted a python web framework that let you write some code. So, i just this very nice piece of python, <a href="http://webpy.org/">web.py</a> . Well this small project is the app-template that I'm using right now in a small web project, I think this starter app is scalable enough to have a pretty big website using it.</span></span><br />
<span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: x-small;"><span class="Apple-style-span" style="line-height: 18px;"><br />
</span></span><br />
<span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: x-small;"><span class="Apple-style-span" style="line-height: 18px;">Directory structure.</span></span><br />
<span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">|-- app.py ................................ Starting point, development web server. </span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"> </span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">|-- model ................................ Model classes </span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"> </span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- BaseModel.py ................ Example.</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">|-- pages .................................. Your web pages -- python way</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"> </span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- __init__.py</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| `-- public </span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- index.py </span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- __init__.py</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- user.py</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">|-- service ............................... Web services</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- auth.py </span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"> </span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- __init__.py</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">|-- static ................................... Static files.</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- css</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- images</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- js</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">|-- templates</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"> </span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- layout.html </span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| |-- public</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| | `-- index.html</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| `-- user</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">| `-- index.html</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">|-- urls.py .............................. URL mapping</span><span class="Apple-style-span" style="font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="color: #cccccc; font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><br />
</span><span class="Apple-style-span" style="color: #cccccc; font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;">Download: </span><span class="Apple-style-span" style="color: #cccccc; font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18px;"><a href="https://github.com/pepetrujillo/web.py-starter-template" style="color: #dd7700; text-decoration: none;">https://github.com/pepetrujillo/web.py-starter-template</a></span><br />
[Spanish version: <a href="http://33notas.blogspot.com/2011/01/webpy-template-de-aplicacion.html">http://33notas.blogspot.com/2011/01/webpy-template-de-aplicacion.html</a>]JM Trujillohttp://www.blogger.com/profile/07329322432631758432noreply@blogger.com0tag:blogger.com,1999:blog-7553149516121087631.post-68119387955383196372011-01-20T00:19:00.000-08:002011-01-20T01:27:09.991-08:00Web.py , template de aplicacion.He estado trabajando en algunos ratos libres en una template de una aplicaciĆ³n usando <a href="http://webpy.org/">web.py</a>, es algo muy sencillo, pero lo publico por que estuve buscando uno en internet, y no encontre nunguno que me mostrara de una manera facil como poder hacer una aplicacion web separando la logica, la vista y el modelo de una manera sencilla.<br />
En esta 'template' no agrego ningun engine de persistencia, pero si unas clases donde se puede implementar como ejemplo, ya que aqui el que la use puede usar algun engine (como <a href="http://www.sqlalchemy.org/">sqlalchemy</a> ), usar db columares o cualquier otra cosa que quiera. El proposito de esto es mostrar como pudiera ser una aplicacion usando web.py.<br />
<br />
Estructura de archivos.<br />
<br />
<br />
|-- app.py ................................ Punto de entrada, y servidor web de desarrollo. <br />
|-- model ................................ Clases relacionadas con el modelo de datos. <br />
| |-- BaseModel.py ................ Ejemplo de modelo de datos.<br />
|-- pages .................................. Clases relacionadas con la paginas. <br />
| |-- __init__.py<br />
| `-- public ........................... Paginas publicas.<br />
| |-- index.py ..................... Ejemplo de pagina publica.<br />
| |-- __init__.py<br />
| |-- user.py<br />
|-- service ............................... Web services y clases que dan algun servicio a la aplicacion--<br />
| |-- auth.py <br />
| |-- __init__.py<br />
|-- static ................................... Archivos estaticos.<br />
| |-- css<br />
| |-- images<br />
| |-- js<br />
|-- templates <br />
| |-- layout.html .................... Template base.<br />
| |-- public<br />
| | `-- index.html<br />
| `-- user<br />
| `-- index.html<br />
|-- urls.py .............................. Mapeo de urls.<br />
<br />
Para descargarlo: <a href="https://github.com/pepetrujillo/web.py-starter-template">https://github.com/pepetrujillo/web.py-starter-template</a>JM Trujillohttp://www.blogger.com/profile/07329322432631758432noreply@blogger.com0