diff --git a/arch-linux-fixes.html b/arch-linux-fixes.html index 20f8eae..81259a6 100644 --- a/arch-linux-fixes.html +++ b/arch-linux-fixes.html @@ -91,6 +91,8 @@

Latest entries

+
Progress bars in python
+
python
Arch Linux Fixes
arch
linux
@@ -108,12 +110,6 @@
webdav
nginx
apache
-
Proxies with Apache and python
-
python
-
apache
-
proxy
-
gunicorn
-
uwsgi
@@ -123,6 +119,7 @@
Org-mode tricks + Progress bars in python

Arch Linux Fixes

@@ -136,7 +133,7 @@

Black screen and LightDM doesn't unlock

Add this to your /etc/lightdm/lightdm.conf file:

1
-2
[LightDM]
+2
[LightDM]
 logind-check-graphical=true
 
diff --git a/archives.html b/archives.html index be201e6..8b48b87 100644 --- a/archives.html +++ b/archives.html @@ -89,6 +89,8 @@

Latest entries

+
Progress bars in python
+
python
Arch Linux Fixes
arch
linux
@@ -106,12 +108,6 @@
webdav
nginx
apache
-
Proxies with Apache and python
-
python
-
apache
-
proxy
-
gunicorn
-
uwsgi
@@ -122,6 +118,8 @@

Archives for balkian.com

+
Wed 28 September 2016
+
Progress bars in python
Wed 03 February 2016
Arch Linux Fixes
Thu 10 December 2015
diff --git a/author/j-fernando-sanchez.html b/author/j-fernando-sanchez.html index 9ebf81b..2895642 100644 --- a/author/j-fernando-sanchez.html +++ b/author/j-fernando-sanchez.html @@ -89,6 +89,8 @@

Latest entries

+
Progress bars in python
+
python
Arch Linux Fixes
arch
linux
@@ -106,12 +108,6 @@
webdav
nginx
apache
-
Proxies with Apache and python
-
python
-
apache
-
proxy
-
gunicorn
-
uwsgi
@@ -126,6 +122,27 @@ +
+

Progress bars in python

+ 2016-09-28 + python +
+
+

tqdm is a nice way to add progress bars in the command line or in a jupyter notebook.

+ +
1
+2
+3
+4
+5
from tqdm import tqdm
+import time
+
+for i in tqdm(range(100)):
+    time.sleep(1)
+
+
+
+
Read more...

Arch Linux Fixes

2016-02-03 @@ -137,7 +154,7 @@

Black screen and LightDM doesn't unlock

Add this to your /etc/lightdm/lightdm.conf file:

1
-2
[LightDM]
+2
[LightDM]
 logind-check-graphical=true
 
@@ -155,7 +172,7 @@

Show plain text version

-
1
(font-lock-mode)
+
1
(font-lock-mode)
 
@@ -209,7 +226,7 @@ a WSGI application with the name application. Hence, wsgi:application.< 2 3 4 -5
<Location /myapp/>
+5
<Location /myapp/>
     ProxyPass http://127.0.0 ...
Read more...
@@ -251,7 +268,7 @@ gathered from media in several languages. Then we aggregated ...

A simple trick. If you want to remove all the '.swp' files from a git repository, just use:

-
1
git rm --cached '\*\*.swp'
+
1
git rm --cached '\*\*.swp'
 
diff --git a/authors.html b/authors.html index f3d9633..42a7483 100644 --- a/authors.html +++ b/authors.html @@ -89,6 +89,8 @@ @@ -121,7 +117,7 @@

Authors on balkian.com

-
  • J. Fernando Sánchez (9)
  • +
    diff --git a/categories.html b/categories.html index 85eec63..d5dcbc5 100644 --- a/categories.html +++ b/categories.html @@ -89,6 +89,8 @@ diff --git a/category/cheats.html b/category/cheats.html index efbf181..4f7bcd1 100644 --- a/category/cheats.html +++ b/category/cheats.html @@ -123,7 +123,7 @@

    Black screen and LightDM doesn't unlock

    Add this to your /etc/lightdm/lightdm.conf file:

    1
    -2
    [LightDM]
    +2
    [LightDM]
     logind-check-graphical=true
     
    @@ -141,7 +141,7 @@

    Show plain text version

    -
    1
    (font-lock-mode)
    +
    1
    (font-lock-mode)
     
    diff --git a/category/misc.html b/category/misc.html index 0b8fdfc..21011a8 100644 --- a/category/misc.html +++ b/category/misc.html @@ -90,6 +90,8 @@ @@ -127,6 +125,27 @@ +
    +

    Progress bars in python

    + 2016-09-28 + python +
    +
    +

    tqdm is a nice way to add progress bars in the command line or in a jupyter notebook.

    + +
    1
    +2
    +3
    +4
    +5
    from tqdm import tqdm
    +import time
    +
    +for i in tqdm(range(100)):
    +    time.sleep(1)
    +
    +
    +
    +

    Sharing dotfiles

    2015-04-10 @@ -175,7 +194,7 @@ a WSGI application with the name application. Hence, wsgi:application.< 2 3 4 -5
    <Location /myapp/>
    +5
    <Location /myapp/>
         ProxyPass http://127.0.0 ...
    @@ -217,7 +236,7 @@ gathered from media in several languages. Then we aggregated ...

    A simple trick. If you want to remove all the '.swp' files from a git repository, just use:

    -
    1
    git rm --cached '\*\*.swp'
    +
    1
    git rm --cached '\*\*.swp'
     
    diff --git a/creating-my-web.html b/creating-my-web.html index c5c831d..4ff8a93 100644 --- a/creating-my-web.html +++ b/creating-my-web.html @@ -91,6 +91,8 @@ @@ -163,7 +159,7 @@ on Github. You can clone and deploy it easily like this:

    1
     2
    -3
    git clone
    +3
    git clone
     https://github.com/balkian/balkian.github.com cd balkian.github.com
     jekyll serve -w
     
    diff --git a/feeds/all.atom.xml b/feeds/all.atom.xml index 60a47d9..04ffce7 100644 --- a/feeds/all.atom.xml +++ b/feeds/all.atom.xml @@ -1,15 +1,27 @@ -balkian.comhttp://balkian.com/2016-02-03T20:00:00+01:00Arch Linux Fixes2016-02-03T20:00:00+01:00J. Fernando Sáncheztag:balkian.com,2016-02-03:arch-linux-fixes.html<div class="section" id="black-screen-and-lightdm-doesn-t-unlock"> +balkian.comhttp://balkian.com/2016-09-28T18:47:00+02:00Progress bars in python2016-09-28T18:47:00+02:00J. Fernando Sáncheztag:balkian.com,2016-09-28:progress-bars-in-python.html<p><a class="reference external" href="https://github.com/noamraph/tqdm">tqdm</a> is a nice way to add progress bars in the command line or in a jupyter notebook.</p> +<img alt="" src="https://camo.githubusercontent.com/48838faaa8d00ea297f18e5bf55d3c6bb4e0ba6b/68747470733a2f2f692e696d6775722e636f6d2f686539417735432e676966" /> +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 +2 +3 +4 +5</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">tqdm</span> <span class="kn">import</span> <span class="n">tqdm</span> +<span class="kn">import</span> <span class="nn">time</span> + +<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">tqdm</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">100</span><span class="p">)):</span> + <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> +</pre></div> +</td></tr></table>Arch Linux Fixes2016-02-03T20:00:00+01:00J. Fernando Sáncheztag:balkian.com,2016-02-03:arch-linux-fixes.html<div class="section" id="black-screen-and-lightdm-doesn-t-unlock"> <h2>Black screen and LightDM doesn't unlock</h2> <p>Add this to your <cite>/etc/lightdm/lightdm.conf</cite> file:</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 -2</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">[LightDM]</span> +2</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="k">[LightDM]</span> <span class="na">logind-check-graphical</span><span class="o">=</span><span class="s">true</span> </pre></div> </td></tr></table></div> Org-mode tricks2015-12-10T11:34:00+01:00J. Fernando Sáncheztag:balkian.com,2015-12-10:org-mode-tricks.html<div class="section" id="show-plain-text-version"> <h2>Show plain text version</h2> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="p">(</span><span class="nv">font-lock-mode</span><span class="p">)</span> +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="p">(</span><span class="nv">font-lock-mode</span><span class="p">)</span> </pre></div> </td></tr></table></div> Sharing dotfiles2015-04-10T17:47:00+02:00J. Fernando Sáncheztag:balkian.com,2015-04-10:sharing-dotfiles.html<p>Today's post is half a quick note, half public shaming. In other words, it is a reminder to be very careful with OAuth tokens and passwords.</p> @@ -19,13 +31,13 @@ This is cool and convenient, unless you <a class="reference external" href="h <p>So, how can you still share your gitconfig without sharing your password/token with the rest of the world? Since Git 1.7.0, you can <a class="reference external" href="http://stackoverflow.com/questions/1557183/is-it-possible-to-include-a-file-in-your-gitconfig">include other files in your gitconfig</a>.</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 -2</pre></div></td><td class="code"><div class="highlight"><pre>[include] +2</pre></div></td><td class="code"><div class="highlight"><pre><span></span>[include] path = ~/.gitconfig_secret </pre></div> </td></tr></table><p>And now, in your .gitconfig_secret file, you just have to add this:</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 -3</pre></div></td><td class="code"><div class="highlight"><pre>[github] +3</pre></div></td><td class="code"><div class="highlight"><pre><span></span>[github] user = balkian token = &quot;&lt; Your secret token &gt;&quot; </pre></div> @@ -41,10 +53,10 @@ Debian/Ubuntu.</p> <div class="section" id="setting-up-apache"> <h2>Setting up Apache</h2> <p>First we need to install Apache:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>sudo apt-get install apache2 +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>sudo apt-get install apache2 </pre></div> </td></tr></table><p>Change the head of &quot;/etc/apache2/sites-enabled/000-default&quot; to:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="nt">&lt;VirtualHost</span> <span class="s">*:880</span><span class="nt">&gt;</span> +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="nt">&lt;VirtualHost</span> <span class="s">*:880</span><span class="nt">&gt;</span> </pre></div> </td></tr></table><p>Then, create a file /etc/apache2/sites-available/webdav:</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1 @@ -59,7 +71,7 @@ Debian/Ubuntu.</p> 10 11 12 -13</pre></div></td><td class="code"><div class="highlight"><pre><span class="nb">Alias</span> <span class="sx">/dav</span> <span class="sx">/home/webdav/dav</span> +13</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="nb">Alias</span> <span class="sx">/dav</span> <span class="sx">/home/webdav/dav</span> <span class="nt">&lt;Location</span> <span class="s">/dav</span><span class="nt">&gt;</span> <span class="nb">Dav</span> <span class="k">on</span> <span class="nb">Order</span> Allow,Deny @@ -83,7 +95,7 @@ other application using webdav.</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 -4</pre></div></td><td class="code"><div class="highlight"><pre>sudo adduser webdav +4</pre></div></td><td class="code"><div class="highlight"><pre><span></span>sudo adduser webdav sudo htpasswd -c /home/webdav/.htpasswd webdav sudo htpasswd /home/webdav/.htpasswd zotero sudo mkdir -p /home/webdav/dav/zotero @@ -92,7 +104,7 @@ sudo mkdir -p /home/webdav/dav/zotero <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 -4</pre></div></td><td class="code"><div class="highlight"><pre>sudo a2enmod webdav +4</pre></div></td><td class="code"><div class="highlight"><pre><span></span>sudo a2enmod webdav sudo a2enmod dav_fs sudo a2ensite webdav sudo service apache2 restart @@ -110,7 +122,7 @@ cleaner URIs. In your desired site/location, add this:</p> 4 5 6 -7</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">location</span> <span class="s">/dav</span> <span class="p">{</span> +7</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="k">location</span> <span class="s">/dav</span> <span class="p">{</span> <span class="kn">client_max_body_size</span> <span class="s">20M</span><span class="p">;</span> <span class="kn">proxy_set_header</span> <span class="s">X-Real-IP</span> <span class="nv">$remote_addr</span><span class="p">;</span> <span class="kn">proxy_set_header</span> <span class="s">X-Forwarded-For</span> <span class="nv">$remote_addr</span><span class="p">;</span> @@ -119,7 +131,7 @@ cleaner URIs. In your desired site/location, add this:</p> <span class="p">}</span> </pre></div> </td></tr></table><p>Now just reload nginx:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>sudo service nginx force-reload +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>sudo service nginx force-reload </pre></div> </td></tr></table></div> <div class="section" id="extras"> @@ -139,7 +151,7 @@ a WSGI application with the name <em>application</em>. Hence, wsgi:a 2 3 4 -5</pre></div></td><td class="code"><div class="highlight"><pre><span class="nt">&lt;Location</span> <span class="s">/myapp/</span><span class="nt">&gt;</span> +5</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="nt">&lt;Location</span> <span class="s">/myapp/</span><span class="nt">&gt;</span> <span class="nb">ProxyPass</span> http://127.0.0.1:8888/myapp/ <span class="nb">ProxyPassReverse</span> http://127.0.0.1:8888/myapp/ <span class="nb">RequestHeader</span> set SCRIPT_NAME <span class="s2">&quot;/myapp/&quot;</span> @@ -148,7 +160,7 @@ a WSGI application with the name <em>application</em>. Hence, wsgi:a </td></tr></table><p><strong>Important</strong>: <em>SCRIPT_NAME</em> and the end of <em>ProxyPass</em> URL <strong>MUST BE THE SAME</strong>. Otherwise, Gunicorn will fail miserably.</p> <p>Try it with:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>venv/bin/gunicorn -w <span class="m">4</span> -b 127.0.0.1:8888 --log-file - --access-logfile - wsgi:application +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>venv/bin/gunicorn -w <span class="m">4</span> -b 127.0.0.1:8888 --log-file - --access-logfile - wsgi:application </pre></div> </td></tr></table></div> <div class="section" id="uwsgi"> @@ -158,13 +170,13 @@ options for uwsgi (in a .ini file).</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 -4</pre></div></td><td class="code"><div class="highlight"><pre><span class="nt">&lt;Location</span> <span class="s">/myapp/</span><span class="nt">&gt;</span> +4</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="nt">&lt;Location</span> <span class="s">/myapp/</span><span class="nt">&gt;</span> <span class="nb">SetHandler</span> uwsgi_handler <span class="nb">uWSGISocker</span> <span class="m">127.0.0.1</span>:8888 <span class="nt">&lt;/Location&gt;</span> </pre></div> </td></tr></table><p>Try it with:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>uwsgi --socket 127.0.0.1:8888 -w wsgi:application +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>uwsgi --socket 127.0.0.1:8888 -w wsgi:application </pre></div> </td></tr></table><div class="section" id="extra-supervisor"> <h3>Extra: Supervisor</h3> @@ -188,7 +200,7 @@ supervisor config file and let it handle the server for you.</p> 16 17 18 -19</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">[unix_http_server]</span> +19</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="k">[unix_http_server]</span> <span class="na">file</span><span class="o">=</span><span class="s">/tmp/myapp.sock ; path to your socket file</span> <span class="k">[supervisord]</span> @@ -238,7 +250,7 @@ memorability over describing the functionality.</p> 10 11 12 -13</pre></div></td><td class="code"><div class="highlight"><pre><span class="err">[distutils]</span> <span class="c1"># this tells distutils what package indexes you can push to</span> +13</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="err">[distutils]</span> <span class="c1"># this tells distutils what package indexes you can push to</span> <span class="na">index-servers</span> <span class="o">=</span><span class="s"></span> <span class="s"> pypi # the live PyPI</span> <span class="s"> pypitest # test PyPI</span> @@ -276,7 +288,7 @@ root-dir/ # Any name you want <div class="section" id="setup-cfg"> <h3>setup.cfg</h3> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 -2</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">[metadata]</span> +2</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="k">[metadata]</span> <span class="na">description-file</span> <span class="o">=</span> <span class="s">README.md</span> </pre></div> </td></tr></table><p>The markdown README is the <em>de facto</em> standard in Github, but you can @@ -295,7 +307,7 @@ also use rST (reStructuredText), the standard in the python community.</p> 9 10 11 -12</pre></div></td><td class="code"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">distutils.core</span> <span class="kn">import</span> <span class="n">setup</span> +12</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">distutils.core</span> <span class="kn">import</span> <span class="n">setup</span> <span class="n">setup</span><span class="p">(</span><span class="n">name</span> <span class="o">=</span> <span class="s1">&#39;mypackage&#39;</span><span class="p">,</span> <span class="n">packages</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;mypackage&#39;</span><span class="p">],</span> <span class="c1"># this must be the same as the name above</span> @@ -313,7 +325,7 @@ host our package anywhere, but Github is a convenient option. To create the tarball and the zip packages, you only need to tag a tag in your repository and push it to github:</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 -2</pre></div></td><td class="code"><div class="highlight"><pre>git tag <span class="o">{</span>version<span class="o">}</span> -m <span class="s2">&quot;{ Description of this tag/version}&quot;</span> +2</pre></div></td><td class="code"><div class="highlight"><pre><span></span>git tag <span class="o">{</span>version<span class="o">}</span> -m <span class="s2">&quot;{ Description of this tag/version}&quot;</span> git push --tags origin master </pre></div> </td></tr></table></div> @@ -351,7 +363,7 @@ new technologies and improve it:</p> <p>The result can be <a class="reference external" href="http://eurolovemap.herokuapp.com/">seen here</a>.</p> <div class="section" id="publishing-a-python-3-app-on-heroku"> <h2>Publishing a Python 3 app on Heroku</h2> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>mkvirtualenv -p /usr/bin/python3.3 eurolovemap +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>mkvirtualenv -p /usr/bin/python3.3 eurolovemap </pre></div> </td></tr></table><p>Since Heroku uses python 2.7 by default, we have to tell it which version we want, although it supports python 3.4 as well. I couldn't get @@ -360,7 +372,7 @@ python 3.4 working using the so I used python 3.3 instead, which works fine but is not officially supported. Just create a file named <em>runtime.txt</em> in your project root, with the python version you want to use:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>python-3.3.1 +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>python-3.3.1 </pre></div> </td></tr></table><p>Don't forget to freeze your dependencies so Heroku can install them: <tt class="docutils literal">bash pip freze &gt; requirements.txt</tt></p> @@ -377,7 +389,7 @@ cipher</a>. Please, don't use it for any serious application if you are concerned about being spammed.</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 -2</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">def</span> <span class="nf">blur_email</span><span class="p">(</span><span class="n">email</span><span class="p">):</span> +2</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">blur_email</span><span class="p">(</span><span class="n">email</span><span class="p">):</span> <span class="k">return</span> <span class="s2">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="nb">chr</span><span class="p">(</span><span class="nb">ord</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">+</span><span class="mi">5</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">email</span><span class="p">])</span> </pre></div> </td></tr></table><p>And this is the client side:</p> @@ -392,7 +404,7 @@ spammed.</p> 9 10 11 -12</pre></div></td><td class="code"><div class="highlight"><pre><span class="nb">window</span><span class="p">.</span><span class="nx">onload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span> +12</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="nb">window</span><span class="p">.</span><span class="nx">onload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span> <span class="nx">elems</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByClassName</span><span class="p">(</span><span class="s1">&#39;profile-email&#39;</span><span class="p">);</span> <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">e</span> <span class="k">in</span> <span class="nx">elems</span><span class="p">){</span> <span class="kd">var</span> <span class="nx">blur</span> <span class="o">=</span> <span class="nx">elems</span><span class="p">[</span><span class="nx">e</span><span class="p">].</span><span class="nx">innerHTML</span><span class="p">;</span> @@ -436,7 +448,7 @@ the <a class="reference external" href="http://slipsum.com/">Samuel L. Jac </div> Remove git files with globbing2013-08-22T23:14:00+02:00J. Fernando Sáncheztag:balkian.com,2013-08-22:remove-git-files-with-globbing.html<p>A simple trick. If you want to remove all the '.swp' files from a git repository, just use:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>git rm --cached <span class="s1">&#39;\*\*.swp&#39;</span> +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>git rm --cached <span class="s1">&#39;\*\*.swp&#39;</span> </pre></div> </td></tr></table>Creating my web2013-08-22T14:14:22+02:00J. Fernando Sáncheztag:balkian.com,2013-08-22:creating-my-web.html<p>Finally, I've decided to set up a decent personal page. I have settled for github-pages because I like the idea of keeping my site in a @@ -466,7 +478,7 @@ on Github</a>. You can clone and deploy it easily like this:</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 -3</pre></div></td><td class="code"><div class="highlight"><pre>git clone +3</pre></div></td><td class="code"><div class="highlight"><pre><span></span>git clone https://github.com/balkian/balkian.github.com <span class="nb">cd</span> balkian.github.com jekyll serve -w </pre></div> diff --git a/feeds/cheats.atom.xml b/feeds/cheats.atom.xml index 4137e11..9c9196f 100644 --- a/feeds/cheats.atom.xml +++ b/feeds/cheats.atom.xml @@ -3,13 +3,13 @@ <h2>Black screen and LightDM doesn't unlock</h2> <p>Add this to your <cite>/etc/lightdm/lightdm.conf</cite> file:</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 -2</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">[LightDM]</span> +2</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="k">[LightDM]</span> <span class="na">logind-check-graphical</span><span class="o">=</span><span class="s">true</span> </pre></div> </td></tr></table></div> Org-mode tricks2015-12-10T11:34:00+01:00J. Fernando Sáncheztag:balkian.com,2015-12-10:org-mode-tricks.html<div class="section" id="show-plain-text-version"> <h2>Show plain text version</h2> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="p">(</span><span class="nv">font-lock-mode</span><span class="p">)</span> +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="p">(</span><span class="nv">font-lock-mode</span><span class="p">)</span> </pre></div> </td></tr></table></div> \ No newline at end of file diff --git a/feeds/misc.atom.xml b/feeds/misc.atom.xml index d67c63e..ac1221c 100644 --- a/feeds/misc.atom.xml +++ b/feeds/misc.atom.xml @@ -1,18 +1,30 @@ -balkian.comhttp://balkian.com/2015-04-10T17:47:00+02:00Sharing dotfiles2015-04-10T17:47:00+02:00J. Fernando Sáncheztag:balkian.com,2015-04-10:sharing-dotfiles.html<p>Today's post is half a quick note, half public shaming. In other words, it is a reminder to be very careful with OAuth tokens and passwords.</p> +balkian.comhttp://balkian.com/2016-09-28T18:47:00+02:00Progress bars in python2016-09-28T18:47:00+02:00J. Fernando Sáncheztag:balkian.com,2016-09-28:progress-bars-in-python.html<p><a class="reference external" href="https://github.com/noamraph/tqdm">tqdm</a> is a nice way to add progress bars in the command line or in a jupyter notebook.</p> +<img alt="" src="https://camo.githubusercontent.com/48838faaa8d00ea297f18e5bf55d3c6bb4e0ba6b/68747470733a2f2f692e696d6775722e636f6d2f686539417735432e676966" /> +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 +2 +3 +4 +5</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">tqdm</span> <span class="kn">import</span> <span class="n">tqdm</span> +<span class="kn">import</span> <span class="nn">time</span> + +<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">tqdm</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">100</span><span class="p">)):</span> + <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> +</pre></div> +</td></tr></table>Sharing dotfiles2015-04-10T17:47:00+02:00J. Fernando Sáncheztag:balkian.com,2015-04-10:sharing-dotfiles.html<p>Today's post is half a quick note, half public shaming. In other words, it is a reminder to be very careful with OAuth tokens and passwords.</p> <p>As part of moving to emacs, I starting using the incredibly useful <a class="reference external" href="https://github.com/defunkt/gist.el">gh.el</a>. When you first use it, the extension saves either your password or an OAuth token in your .gitconfig file. This is cool and convenient, unless you <a class="reference external" href="https://github.com/balkian/dotfiles">happen to be publishing your .gitconfig file in a public repo</a>.</p> <p>So, how can you still share your gitconfig without sharing your password/token with the rest of the world? Since Git 1.7.0, you can <a class="reference external" href="http://stackoverflow.com/questions/1557183/is-it-possible-to-include-a-file-in-your-gitconfig">include other files in your gitconfig</a>.</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 -2</pre></div></td><td class="code"><div class="highlight"><pre>[include] +2</pre></div></td><td class="code"><div class="highlight"><pre><span></span>[include] path = ~/.gitconfig_secret </pre></div> </td></tr></table><p>And now, in your .gitconfig_secret file, you just have to add this:</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 -3</pre></div></td><td class="code"><div class="highlight"><pre>[github] +3</pre></div></td><td class="code"><div class="highlight"><pre><span></span>[github] user = balkian token = &quot;&lt; Your secret token &gt;&quot; </pre></div> @@ -28,10 +40,10 @@ Debian/Ubuntu.</p> <div class="section" id="setting-up-apache"> <h2>Setting up Apache</h2> <p>First we need to install Apache:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>sudo apt-get install apache2 +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>sudo apt-get install apache2 </pre></div> </td></tr></table><p>Change the head of &quot;/etc/apache2/sites-enabled/000-default&quot; to:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="nt">&lt;VirtualHost</span> <span class="s">*:880</span><span class="nt">&gt;</span> +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="nt">&lt;VirtualHost</span> <span class="s">*:880</span><span class="nt">&gt;</span> </pre></div> </td></tr></table><p>Then, create a file /etc/apache2/sites-available/webdav:</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1 @@ -46,7 +58,7 @@ Debian/Ubuntu.</p> 10 11 12 -13</pre></div></td><td class="code"><div class="highlight"><pre><span class="nb">Alias</span> <span class="sx">/dav</span> <span class="sx">/home/webdav/dav</span> +13</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="nb">Alias</span> <span class="sx">/dav</span> <span class="sx">/home/webdav/dav</span> <span class="nt">&lt;Location</span> <span class="s">/dav</span><span class="nt">&gt;</span> <span class="nb">Dav</span> <span class="k">on</span> <span class="nb">Order</span> Allow,Deny @@ -70,7 +82,7 @@ other application using webdav.</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 -4</pre></div></td><td class="code"><div class="highlight"><pre>sudo adduser webdav +4</pre></div></td><td class="code"><div class="highlight"><pre><span></span>sudo adduser webdav sudo htpasswd -c /home/webdav/.htpasswd webdav sudo htpasswd /home/webdav/.htpasswd zotero sudo mkdir -p /home/webdav/dav/zotero @@ -79,7 +91,7 @@ sudo mkdir -p /home/webdav/dav/zotero <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 -4</pre></div></td><td class="code"><div class="highlight"><pre>sudo a2enmod webdav +4</pre></div></td><td class="code"><div class="highlight"><pre><span></span>sudo a2enmod webdav sudo a2enmod dav_fs sudo a2ensite webdav sudo service apache2 restart @@ -97,7 +109,7 @@ cleaner URIs. In your desired site/location, add this:</p> 4 5 6 -7</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">location</span> <span class="s">/dav</span> <span class="p">{</span> +7</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="k">location</span> <span class="s">/dav</span> <span class="p">{</span> <span class="kn">client_max_body_size</span> <span class="s">20M</span><span class="p">;</span> <span class="kn">proxy_set_header</span> <span class="s">X-Real-IP</span> <span class="nv">$remote_addr</span><span class="p">;</span> <span class="kn">proxy_set_header</span> <span class="s">X-Forwarded-For</span> <span class="nv">$remote_addr</span><span class="p">;</span> @@ -106,7 +118,7 @@ cleaner URIs. In your desired site/location, add this:</p> <span class="p">}</span> </pre></div> </td></tr></table><p>Now just reload nginx:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>sudo service nginx force-reload +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>sudo service nginx force-reload </pre></div> </td></tr></table></div> <div class="section" id="extras"> @@ -126,7 +138,7 @@ a WSGI application with the name <em>application</em>. Hence, wsgi:a 2 3 4 -5</pre></div></td><td class="code"><div class="highlight"><pre><span class="nt">&lt;Location</span> <span class="s">/myapp/</span><span class="nt">&gt;</span> +5</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="nt">&lt;Location</span> <span class="s">/myapp/</span><span class="nt">&gt;</span> <span class="nb">ProxyPass</span> http://127.0.0.1:8888/myapp/ <span class="nb">ProxyPassReverse</span> http://127.0.0.1:8888/myapp/ <span class="nb">RequestHeader</span> set SCRIPT_NAME <span class="s2">&quot;/myapp/&quot;</span> @@ -135,7 +147,7 @@ a WSGI application with the name <em>application</em>. Hence, wsgi:a </td></tr></table><p><strong>Important</strong>: <em>SCRIPT_NAME</em> and the end of <em>ProxyPass</em> URL <strong>MUST BE THE SAME</strong>. Otherwise, Gunicorn will fail miserably.</p> <p>Try it with:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>venv/bin/gunicorn -w <span class="m">4</span> -b 127.0.0.1:8888 --log-file - --access-logfile - wsgi:application +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>venv/bin/gunicorn -w <span class="m">4</span> -b 127.0.0.1:8888 --log-file - --access-logfile - wsgi:application </pre></div> </td></tr></table></div> <div class="section" id="uwsgi"> @@ -145,13 +157,13 @@ options for uwsgi (in a .ini file).</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 3 -4</pre></div></td><td class="code"><div class="highlight"><pre><span class="nt">&lt;Location</span> <span class="s">/myapp/</span><span class="nt">&gt;</span> +4</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="nt">&lt;Location</span> <span class="s">/myapp/</span><span class="nt">&gt;</span> <span class="nb">SetHandler</span> uwsgi_handler <span class="nb">uWSGISocker</span> <span class="m">127.0.0.1</span>:8888 <span class="nt">&lt;/Location&gt;</span> </pre></div> </td></tr></table><p>Try it with:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>uwsgi --socket 127.0.0.1:8888 -w wsgi:application +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>uwsgi --socket 127.0.0.1:8888 -w wsgi:application </pre></div> </td></tr></table><div class="section" id="extra-supervisor"> <h3>Extra: Supervisor</h3> @@ -175,7 +187,7 @@ supervisor config file and let it handle the server for you.</p> 16 17 18 -19</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">[unix_http_server]</span> +19</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="k">[unix_http_server]</span> <span class="na">file</span><span class="o">=</span><span class="s">/tmp/myapp.sock ; path to your socket file</span> <span class="k">[supervisord]</span> @@ -225,7 +237,7 @@ memorability over describing the functionality.</p> 10 11 12 -13</pre></div></td><td class="code"><div class="highlight"><pre><span class="err">[distutils]</span> <span class="c1"># this tells distutils what package indexes you can push to</span> +13</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="err">[distutils]</span> <span class="c1"># this tells distutils what package indexes you can push to</span> <span class="na">index-servers</span> <span class="o">=</span><span class="s"></span> <span class="s"> pypi # the live PyPI</span> <span class="s"> pypitest # test PyPI</span> @@ -263,7 +275,7 @@ root-dir/ # Any name you want <div class="section" id="setup-cfg"> <h3>setup.cfg</h3> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 -2</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">[metadata]</span> +2</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="k">[metadata]</span> <span class="na">description-file</span> <span class="o">=</span> <span class="s">README.md</span> </pre></div> </td></tr></table><p>The markdown README is the <em>de facto</em> standard in Github, but you can @@ -282,7 +294,7 @@ also use rST (reStructuredText), the standard in the python community.</p> 9 10 11 -12</pre></div></td><td class="code"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">distutils.core</span> <span class="kn">import</span> <span class="n">setup</span> +12</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">distutils.core</span> <span class="kn">import</span> <span class="n">setup</span> <span class="n">setup</span><span class="p">(</span><span class="n">name</span> <span class="o">=</span> <span class="s1">&#39;mypackage&#39;</span><span class="p">,</span> <span class="n">packages</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;mypackage&#39;</span><span class="p">],</span> <span class="c1"># this must be the same as the name above</span> @@ -300,7 +312,7 @@ host our package anywhere, but Github is a convenient option. To create the tarball and the zip packages, you only need to tag a tag in your repository and push it to github:</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 -2</pre></div></td><td class="code"><div class="highlight"><pre>git tag <span class="o">{</span>version<span class="o">}</span> -m <span class="s2">&quot;{ Description of this tag/version}&quot;</span> +2</pre></div></td><td class="code"><div class="highlight"><pre><span></span>git tag <span class="o">{</span>version<span class="o">}</span> -m <span class="s2">&quot;{ Description of this tag/version}&quot;</span> git push --tags origin master </pre></div> </td></tr></table></div> @@ -338,7 +350,7 @@ new technologies and improve it:</p> <p>The result can be <a class="reference external" href="http://eurolovemap.herokuapp.com/">seen here</a>.</p> <div class="section" id="publishing-a-python-3-app-on-heroku"> <h2>Publishing a Python 3 app on Heroku</h2> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>mkvirtualenv -p /usr/bin/python3.3 eurolovemap +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>mkvirtualenv -p /usr/bin/python3.3 eurolovemap </pre></div> </td></tr></table><p>Since Heroku uses python 2.7 by default, we have to tell it which version we want, although it supports python 3.4 as well. I couldn't get @@ -347,7 +359,7 @@ python 3.4 working using the so I used python 3.3 instead, which works fine but is not officially supported. Just create a file named <em>runtime.txt</em> in your project root, with the python version you want to use:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>python-3.3.1 +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>python-3.3.1 </pre></div> </td></tr></table><p>Don't forget to freeze your dependencies so Heroku can install them: <tt class="docutils literal">bash pip freze &gt; requirements.txt</tt></p> @@ -364,7 +376,7 @@ cipher</a>. Please, don't use it for any serious application if you are concerned about being spammed.</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 -2</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">def</span> <span class="nf">blur_email</span><span class="p">(</span><span class="n">email</span><span class="p">):</span> +2</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">blur_email</span><span class="p">(</span><span class="n">email</span><span class="p">):</span> <span class="k">return</span> <span class="s2">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="nb">chr</span><span class="p">(</span><span class="nb">ord</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">+</span><span class="mi">5</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">email</span><span class="p">])</span> </pre></div> </td></tr></table><p>And this is the client side:</p> @@ -379,7 +391,7 @@ spammed.</p> 9 10 11 -12</pre></div></td><td class="code"><div class="highlight"><pre><span class="nb">window</span><span class="p">.</span><span class="nx">onload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span> +12</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="nb">window</span><span class="p">.</span><span class="nx">onload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span> <span class="nx">elems</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByClassName</span><span class="p">(</span><span class="s1">&#39;profile-email&#39;</span><span class="p">);</span> <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">e</span> <span class="k">in</span> <span class="nx">elems</span><span class="p">){</span> <span class="kd">var</span> <span class="nx">blur</span> <span class="o">=</span> <span class="nx">elems</span><span class="p">[</span><span class="nx">e</span><span class="p">].</span><span class="nx">innerHTML</span><span class="p">;</span> @@ -423,7 +435,7 @@ the <a class="reference external" href="http://slipsum.com/">Samuel L. Jac </div> Remove git files with globbing2013-08-22T23:14:00+02:00J. Fernando Sáncheztag:balkian.com,2013-08-22:remove-git-files-with-globbing.html<p>A simple trick. If you want to remove all the '.swp' files from a git repository, just use:</p> -<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>git rm --cached <span class="s1">&#39;\*\*.swp&#39;</span> +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span>git rm --cached <span class="s1">&#39;\*\*.swp&#39;</span> </pre></div> </td></tr></table>Creating my web2013-08-22T14:14:22+02:00J. Fernando Sáncheztag:balkian.com,2013-08-22:creating-my-web.html<p>Finally, I've decided to set up a decent personal page. I have settled for github-pages because I like the idea of keeping my site in a @@ -453,7 +465,7 @@ on Github</a>. You can clone and deploy it easily like this:</p> <table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1 2 -3</pre></div></td><td class="code"><div class="highlight"><pre>git clone +3</pre></div></td><td class="code"><div class="highlight"><pre><span></span>git clone https://github.com/balkian/balkian.github.com <span class="nb">cd</span> balkian.github.com jekyll serve -w </pre></div> diff --git a/index.html b/index.html index 40463b9..138eb99 100644 --- a/index.html +++ b/index.html @@ -89,6 +89,8 @@ @@ -126,6 +122,27 @@ +
    +

    Progress bars in python

    + 2016-09-28 + python +
    +
    +

    tqdm is a nice way to add progress bars in the command line or in a jupyter notebook.

    + +
    1
    +2
    +3
    +4
    +5
    from tqdm import tqdm
    +import time
    +
    +for i in tqdm(range(100)):
    +    time.sleep(1)
    +
    +
    +
    +

    Arch Linux Fixes

    2016-02-03 @@ -137,7 +154,7 @@

    Black screen and LightDM doesn't unlock

    Add this to your /etc/lightdm/lightdm.conf file:

    1
    -2
    [LightDM]
    +2
    [LightDM]
     logind-check-graphical=true
     
    @@ -155,7 +172,7 @@

    Show plain text version

    -
    1
    (font-lock-mode)
    +
    1
    (font-lock-mode)
     
    @@ -209,7 +226,7 @@ a WSGI application with the name application. Hence, wsgi:application.< 2 3 4 -5
    <Location /myapp/>
    +5
    <Location /myapp/>
         ProxyPass http://127.0.0 ...
    @@ -251,7 +268,7 @@ gathered from media in several languages. Then we aggregated ...

    A simple trick. If you want to remove all the '.swp' files from a git repository, just use:

    -
    1
    git rm --cached '\*\*.swp'
    +
    1
    git rm --cached '\*\*.swp'
     
    diff --git a/org-mode-tricks.html b/org-mode-tricks.html index bfb041a..0c5d7d0 100644 --- a/org-mode-tricks.html +++ b/org-mode-tricks.html @@ -91,6 +91,8 @@ @@ -137,7 +133,7 @@

    Show plain text version

    -
    1
    (font-lock-mode)
    +
    1
    (font-lock-mode)
     
    diff --git a/pages/projects.html b/pages/projects.html index d6542ed..1103828 100644 --- a/pages/projects.html +++ b/pages/projects.html @@ -91,6 +91,8 @@ diff --git a/pages/to-do.html b/pages/to-do.html index bd0f36d..5c9f52d 100644 --- a/pages/to-do.html +++ b/pages/to-do.html @@ -90,6 +90,8 @@ diff --git a/progress-bars-in-python.html b/progress-bars-in-python.html new file mode 100644 index 0000000..7a11017 --- /dev/null +++ b/progress-bars-in-python.html @@ -0,0 +1,186 @@ + + + + + + balkian.com - Progress bars in python + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + + +
    +

    Progress bars in python

    + 2016-09-28 + python +
    + +
    +

    tqdm is a nice way to add progress bars in the command line or in a jupyter notebook.

    + +
    1
    +2
    +3
    +4
    +5
    from tqdm import tqdm
    +import time
    +
    +for i in tqdm(range(100)):
    +    time.sleep(1)
    +
    +
    +
    +
    +
    +
    +
    +
    +

    + J. Fernando Sánchez Rada | balkian +

    +
    +
      +
    • +
    • +
    • +
    • +
    • +
    • +
    +

    + Creative Commons A-SA-NC +

    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/proxies-with-apache-and-python.html b/proxies-with-apache-and-python.html index 32f031c..9273c78 100644 --- a/proxies-with-apache-and-python.html +++ b/proxies-with-apache-and-python.html @@ -91,6 +91,8 @@ @@ -145,7 +141,7 @@ a WSGI application with the name application. Hence, wsgi:application.< 2 3 4 -5
    <Location /myapp/>
    +5
    <Location /myapp/>
         ProxyPass http://127.0.0.1:8888/myapp/
         ProxyPassReverse http://127.0.0.1:8888/myapp/
         RequestHeader set SCRIPT_NAME "/myapp/"
    @@ -154,7 +150,7 @@ a WSGI application with the name application. Hence, wsgi:application.<
     

    Important: SCRIPT_NAME and the end of ProxyPass URL MUST BE THE SAME. Otherwise, Gunicorn will fail miserably.

    Try it with:

    -
    1
    venv/bin/gunicorn -w 4 -b 127.0.0.1:8888 --log-file - --access-logfile - wsgi:application
    +
    1
    venv/bin/gunicorn -w 4 -b 127.0.0.1:8888 --log-file - --access-logfile - wsgi:application
     
    @@ -164,13 +160,13 @@ options for uwsgi (in a .ini file).

    1
     2
     3
    -4
    <Location /myapp/>
    +4
    <Location /myapp/>
         SetHandler uwsgi_handler
         uWSGISocker 127.0.0.1:8888
     </Location>
     

    Try it with:

    -
    1
    uwsgi --socket 127.0.0.1:8888 -w wsgi:application
    +
    1
    uwsgi --socket 127.0.0.1:8888 -w wsgi:application
     

    Extra: Supervisor

    @@ -194,7 +190,7 @@ supervisor config file and let it handle the server for you.

    16 17 18 -19
    [unix_http_server]
    +19
    [unix_http_server]
     file=/tmp/myapp.sock ; path to your socket file
     
     [supervisord]
    diff --git a/publishing-on-pypi.html b/publishing-on-pypi.html
    index eb299d3..3fec1dc 100644
    --- a/publishing-on-pypi.html
    +++ b/publishing-on-pypi.html
    @@ -91,6 +91,8 @@
               
     
    @@ -162,7 +158,7 @@ memorability over describing the functionality.

    10 11 12 -13
    [distutils] # this tells distutils what package indexes you can push to
    +13
    [distutils] # this tells distutils what package indexes you can push to
     index-servers =
         pypi # the live PyPI
         pypitest # test PyPI
    @@ -200,7 +196,7 @@ root-dir/    # Any name you want
     

    setup.cfg

    1
    -2
    [metadata]
    +2
    [metadata]
     description-file = README.md
     

    The markdown README is the de facto standard in Github, but you can @@ -219,7 +215,7 @@ also use rST (reStructuredText), the standard in the python community.

    9 10 11 -12
    from distutils.core import setup
    +12
    from distutils.core import setup
     
     setup(name = 'mypackage',
           packages = ['mypackage'], # this must be the same as the name above
    @@ -237,7 +233,7 @@ host our package anywhere, but Github is a convenient option. To create
     the tarball and the zip packages, you only need to tag a tag in your
     repository and push it to github:

    1
    -2
    git tag {version} -m "{ Description of this tag/version}"
    +2
    git tag {version} -m "{ Description of this tag/version}"
     git push --tags origin master
     
    diff --git a/remove-git-files-with-globbing.html b/remove-git-files-with-globbing.html index 0f10013..bbf13c2 100644 --- a/remove-git-files-with-globbing.html +++ b/remove-git-files-with-globbing.html @@ -91,6 +91,8 @@ @@ -134,7 +130,7 @@

    A simple trick. If you want to remove all the '.swp' files from a git repository, just use:

    -
    1
    git rm --cached '\*\*.swp'
    +
    1
    git rm --cached '\*\*.swp'
     
    diff --git a/sharing-dotfiles.html b/sharing-dotfiles.html index 83fdfba..cb1fc4f 100644 --- a/sharing-dotfiles.html +++ b/sharing-dotfiles.html @@ -91,6 +91,8 @@ @@ -141,13 +137,13 @@ This is cool and convenient, unless you include other files in your gitconfig.

    1
    -2
    [include]
    +2
    [include]
         path = ~/.gitconfig_secret
     

    And now, in your .gitconfig_secret file, you just have to add this:

    1
     2
    -3
    [github]
    +3
    [github]
         user = balkian
         token = "< Your secret token >"
     
    diff --git a/tag/apache.html b/tag/apache.html index 618e921..aafa730 100644 --- a/tag/apache.html +++ b/tag/apache.html @@ -150,7 +150,7 @@ a WSGI application with the name application. Hence, wsgi:application.< 2 3 4 -5
    <Location /myapp/>
    +5
    <Location /myapp/>
         ProxyPass http://127.0.0 ...
    diff --git a/tag/arch.html b/tag/arch.html index 91c3728..5c6084e 100644 --- a/tag/arch.html +++ b/tag/arch.html @@ -118,7 +118,7 @@

    Black screen and LightDM doesn't unlock

    Add this to your /etc/lightdm/lightdm.conf file:

    1
    -2
    [LightDM]
    +2
    [LightDM]
     logind-check-graphical=true
     
    diff --git a/tag/editor.html b/tag/editor.html index e7bc574..ba4b07f 100644 --- a/tag/editor.html +++ b/tag/editor.html @@ -120,7 +120,7 @@

    Show plain text version

    -
    1
    (font-lock-mode)
    +
    1
    (font-lock-mode)
     
    diff --git a/tag/emacs.html b/tag/emacs.html index b9d0091..e6344e4 100644 --- a/tag/emacs.html +++ b/tag/emacs.html @@ -120,7 +120,7 @@

    Show plain text version

    -
    1
    (font-lock-mode)
    +
    1
    (font-lock-mode)
     
    diff --git a/tag/git.html b/tag/git.html index cd9bdaa..51d78c5 100644 --- a/tag/git.html +++ b/tag/git.html @@ -137,7 +137,7 @@ When you first use it, the extension saves either ...

    A simple trick. If you want to remove all the '.swp' files from a git repository, just use:

    -
    1
    git rm --cached '\*\*.swp'
    +
    1
    git rm --cached '\*\*.swp'
     
    diff --git a/tag/gunicorn.html b/tag/gunicorn.html index 637d221..57f8f07 100644 --- a/tag/gunicorn.html +++ b/tag/gunicorn.html @@ -129,7 +129,7 @@ a WSGI application with the name application. Hence, wsgi:application.< 2 3 4 -5
    <Location /myapp/>
    +5
    <Location /myapp/>
         ProxyPass http://127.0.0 ...
    diff --git a/tag/linux.html b/tag/linux.html index a20c557..3924c8e 100644 --- a/tag/linux.html +++ b/tag/linux.html @@ -118,7 +118,7 @@

    Black screen and LightDM doesn't unlock

    Add this to your /etc/lightdm/lightdm.conf file:

    1
    -2
    [LightDM]
    +2
    [LightDM]
     logind-check-graphical=true
     
    diff --git a/tag/org.html b/tag/org.html index 5d0e71e..738cbd1 100644 --- a/tag/org.html +++ b/tag/org.html @@ -120,7 +120,7 @@

    Show plain text version

    -
    1
    (font-lock-mode)
    +
    1
    (font-lock-mode)
     
    diff --git a/tag/productivity.html b/tag/productivity.html index 69c63e3..d44e6a8 100644 --- a/tag/productivity.html +++ b/tag/productivity.html @@ -120,7 +120,7 @@

    Show plain text version

    -
    1
    (font-lock-mode)
    +
    1
    (font-lock-mode)
     
    diff --git a/tag/proxy.html b/tag/proxy.html index 9ecf9ef..830860a 100644 --- a/tag/proxy.html +++ b/tag/proxy.html @@ -129,7 +129,7 @@ a WSGI application with the name application. Hence, wsgi:application.< 2 3 4 -5
    <Location /myapp/>
    +5
    <Location /myapp/>
         ProxyPass http://127.0.0 ...
    diff --git a/tag/python.html b/tag/python.html index d9edca8..3d7ba22 100644 --- a/tag/python.html +++ b/tag/python.html @@ -89,6 +89,8 @@

    Latest entries

    +
    Progress bars in python
    +
    python
    Proxies with Apache and python
    python
    apache
    @@ -118,6 +120,27 @@

    Entries tagged: python

    +
    +

    Progress bars in python

    + 2016-09-28 + python +
    +
    +

    tqdm is a nice way to add progress bars in the command line or in a jupyter notebook.

    + +
    1
    +2
    +3
    +4
    +5
    from tqdm import tqdm
    +import time
    +
    +for i in tqdm(range(100)):
    +    time.sleep(1)
    +
    +
    +
    +

    Proxies with Apache and python

    2014-10-09 @@ -137,7 +160,7 @@ a WSGI application with the name application. Hence, wsgi:application.< 2 3 4 -5
    <Location /myapp/>
    +5
    <Location /myapp/>
         ProxyPass http://127.0.0 ...
    diff --git a/tag/uwsgi.html b/tag/uwsgi.html index aaf6156..af06280 100644 --- a/tag/uwsgi.html +++ b/tag/uwsgi.html @@ -129,7 +129,7 @@ a WSGI application with the name application. Hence, wsgi:application.< 2 3 4 -5
    <Location /myapp/>
    +5
    <Location /myapp/>
         ProxyPass http://127.0.0 ...
    diff --git a/tags.html b/tags.html index e42766d..e6f4168 100644 --- a/tags.html +++ b/tags.html @@ -90,6 +90,8 @@ @@ -121,28 +117,28 @@
    diff --git a/updating-eurolovemap.html b/updating-eurolovemap.html index daef9fe..80c543c 100644 --- a/updating-eurolovemap.html +++ b/updating-eurolovemap.html @@ -91,6 +91,8 @@ @@ -158,7 +154,7 @@ new technologies and improve it:

    The result can be seen here.

    Publishing a Python 3 app on Heroku

    -
    1
    mkvirtualenv -p /usr/bin/python3.3 eurolovemap
    +
    1
    mkvirtualenv -p /usr/bin/python3.3 eurolovemap
     

    Since Heroku uses python 2.7 by default, we have to tell it which version we want, although it supports python 3.4 as well. I couldn't get @@ -167,7 +163,7 @@ python 3.4 working using the so I used python 3.3 instead, which works fine but is not officially supported. Just create a file named runtime.txt in your project root, with the python version you want to use:

    -
    1
    python-3.3.1
    +
    1
    python-3.3.1
     

    Don't forget to freeze your dependencies so Heroku can install them: bash pip freze > requirements.txt

    @@ -184,7 +180,7 @@ cipher. Please, don't use it for any serious application if you are concerned about being spammed.

    1
    -2
    def blur_email(email):
    +2
    def blur_email(email):
         return "".join([chr(ord(i)+5) for i in email])
     

    And this is the client side:

    @@ -199,7 +195,7 @@ spammed.

    9 10 11 -12
    window.onload = function(){
    +12
    window.onload = function(){
          elems = document.getElementsByClassName('profile-email');
          for(var e in elems){
             var blur = elems[e].innerHTML;
    diff --git a/zotero.html b/zotero.html
    index a3559bd..d82f0ff 100644
    --- a/zotero.html
    +++ b/zotero.html
    @@ -91,6 +91,8 @@
               
     
    @@ -147,10 +143,10 @@ Debian/Ubuntu.

    Setting up Apache

    First we need to install Apache:

    -
    1
    sudo apt-get install apache2
    +
    1
    sudo apt-get install apache2
     

    Change the head of "/etc/apache2/sites-enabled/000-default" to:

    -
    1
    <VirtualHost *:880>
    +
    1
    <VirtualHost *:880>
     

    Then, create a file /etc/apache2/sites-available/webdav:

     1
    @@ -165,7 +161,7 @@ Debian/Ubuntu.

    10 11 12 -13
    Alias /dav /home/webdav/dav
    +13
    Alias /dav /home/webdav/dav
     <Location /dav>
         Dav on
         Order Allow,Deny
    @@ -189,7 +185,7 @@ other application using webdav.

    1
     2
     3
    -4
    sudo adduser webdav
    +4
    sudo adduser webdav
     sudo htpasswd -c /home/webdav/.htpasswd webdav
     sudo htpasswd /home/webdav/.htpasswd zotero
     sudo mkdir -p /home/webdav/dav/zotero
    @@ -198,7 +194,7 @@ sudo mkdir -p /home/webdav/dav/zotero
     
    1
     2
     3
    -4
    sudo a2enmod webdav
    +4
    sudo a2enmod webdav
     sudo a2enmod dav_fs
     sudo a2ensite webdav
     sudo service apache2 restart
    @@ -216,7 +212,7 @@ cleaner URIs. In your desired site/location, add this:

    4 5 6 -7
    location /dav {
    +7
    location /dav {
         client_max_body_size 20M;
         proxy_set_header X-Real-IP  $remote_addr;
         proxy_set_header X-Forwarded-For $remote_addr;
    @@ -225,7 +221,7 @@ cleaner URIs. In your desired site/location, add this:

    }

    Now just reload nginx:

    -
    1
    sudo service nginx force-reload
    +
    1
    sudo service nginx force-reload