snipt

Ctrl+h for KB shortcuts

Python

serve media_url in dev for django

1
2
3
4
5
6
7
8
from django.conf.urls.defaults import *
from django.conf import settings

if settings.DEBUG:
    urlpatterns += patterns('django.views.static',
        (r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:], 'serve',
        {'document_root': settings.MEDIA_ROOT}),
    )
https://snipt.net/embed/104c8b7a1dc9f37a28a69d7a4d246fdd/
/raw/104c8b7a1dc9f37a28a69d7a4d246fdd/
104c8b7a1dc9f37a28a69d7a4d246fdd
python
Python
8
2019-08-15T14:25:54
True
False
False
/api/public/snipt/28103/
serve-media_url-in-dev-for-django
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kn">from</span> <span class="nn">django.conf.urls.defaults</span> <span class="kn">import</span> <span class="o">*</span> </span><span id="L-2"><a name="L-2"></a><span class="kn">from</span> <span class="nn">django.conf</span> <span class="kn">import</span> <span class="n">settings</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="k">if</span> <span class="n">settings</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">:</span> </span><span id="L-5"><a name="L-5"></a> <span class="n">urlpatterns</span> <span class="o">+=</span> <span class="n">patterns</span><span class="p">(</span><span class="s1">&#39;django.views.static&#39;</span><span class="p">,</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">(</span><span class="s1">r&#39;^</span><span class="si">%s</span><span class="s1">(?P&lt;path&gt;.*)$&#39;</span> <span class="o">%</span> <span class="n">settings</span><span class="o">.</span><span class="n">MEDIA_URL</span><span class="p">[</span><span class="mi">1</span><span class="p">:],</span> <span class="s1">&#39;serve&#39;</span><span class="p">,</span> </span><span id="L-7"><a name="L-7"></a> <span class="p">{</span><span class="s1">&#39;document_root&#39;</span><span class="p">:</span> <span class="n">settings</span><span class="o">.</span><span class="n">MEDIA_ROOT</span><span class="p">}),</span> </span><span id="L-8"><a name="L-8"></a> <span class="p">)</span> </span></pre></div> </td></tr></table>
django, static

Bash

Remove pastas .svn recursivamente

1
2
3
# remove todas as pastas .svn na pasta atual e subpastas
# ref:http://whitt.wordpress.com/2006/11/14/how-to-recursively-remove-svn-metadata/
find . -name .svn -print0 | xargs -0 rm -rf
https://snipt.net/embed/e3db6f3ecaa5b9ef173b2c4381d23306/
/raw/e3db6f3ecaa5b9ef173b2c4381d23306/
e3db6f3ecaa5b9ef173b2c4381d23306
bash
Bash
3
2019-08-18T07:40:39
True
False
False
/api/public/snipt/21327/
remove-pastas-svn-recursivamente
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># remove todas as pastas .svn na pasta atual e subpastas</span> </span><span id="L-2"><a name="L-2"></a><span class="c1"># ref:http://whitt.wordpress.com/2006/11/14/how-to-recursively-remove-svn-metadata/</span> </span><span id="L-3"><a name="L-3"></a>find . -name .svn -print0 <span class="p">|</span> xargs -0 rm -rf </span></pre></div> </td></tr></table>
remove, svn

Bash

nice settings for mplayer. I call it turtle-player

1
2
3
4
5
6
7
8
# dev: Italo Maia
# description: nice settings for mplayer. Those nasty hard-to-play videos will run better with
# this.
# date: 06/06/2010
# ----
# save to a file called turtle-player.sh and link it in /usr/bin/ as 
# turtle-player
mplayer -cache 8912 -cache-min 20 -af volnorm -vo xv x11 -ao alsa oss -framedrop "$1"
https://snipt.net/embed/949f3f25d2f220ac8cb96e832f7af91e/
/raw/949f3f25d2f220ac8cb96e832f7af91e/
949f3f25d2f220ac8cb96e832f7af91e
bash
Bash
8
2019-08-16T03:32:13
True
False
False
/api/public/snipt/15414/
nice-settings-for-mplayer
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># dev: Italo Maia</span> </span><span id="L-2"><a name="L-2"></a><span class="c1"># description: nice settings for mplayer. Those nasty hard-to-play videos will run better with</span> </span><span id="L-3"><a name="L-3"></a><span class="c1"># this.</span> </span><span id="L-4"><a name="L-4"></a><span class="c1"># date: 06/06/2010</span> </span><span id="L-5"><a name="L-5"></a><span class="c1"># ----</span> </span><span id="L-6"><a name="L-6"></a><span class="c1"># save to a file called turtle-player.sh and link it in /usr/bin/ as </span> </span><span id="L-7"><a name="L-7"></a><span class="c1"># turtle-player</span> </span><span id="L-8"><a name="L-8"></a>mplayer -cache <span class="m">8912</span> -cache-min <span class="m">20</span> -af volnorm -vo xv x11 -ao alsa oss -framedrop <span class="s2">&quot;</span><span class="nv">$1</span><span class="s2">&quot;</span> </span></pre></div> </td></tr></table>
mplayer, script

ApacheConf

servindo favicon pelo apache. Config do htaccess

RewriteRule ^favicon\.ico$ /media/images/favicon.ico [L]
https://snipt.net/embed/0fa84d2f4d395b7456db449a7ec3c389/
/raw/0fa84d2f4d395b7456db449a7ec3c389/
0fa84d2f4d395b7456db449a7ec3c389
apacheconf
ApacheConf
1
2019-08-14T14:52:54
True
False
False
/api/public/snipt/14738/
servindo-favicon-pelo-apache-config-do-htaccess
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nb">RewriteRule</span> ^favicon\.ico$ <span class="sx">/media/images/favicon.ico</span> [L] </span></pre></div> </td></tr></table>
apache, favicon

Bash

exemplo de uso do modeladmin do django com jquery

1
2
3
4
5
from django.contrib import admin

class ModeloAdmin(admin.ModelAdmin):
    class Media:
        js = ("js/jquery.js", "js/my_code.js",)
https://snipt.net/embed/55fc303fffefecc9f915c1f44ffc13c9/
/raw/55fc303fffefecc9f915c1f44ffc13c9/
55fc303fffefecc9f915c1f44ffc13c9
bash
Bash
6
2019-08-17T03:21:51
True
False
False
/api/public/snipt/14061/
exemplo-de-uso-do-modeladmin-do-django-com-jquery
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>from django.contrib import admin </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>class ModeloAdmin<span class="o">(</span>admin.ModelAdmin<span class="o">)</span>: </span><span id="L-4"><a name="L-4"></a> class Media: </span><span id="L-5"><a name="L-5"></a> <span class="nv">js</span> <span class="o">=</span> <span class="o">(</span><span class="s2">&quot;js/jquery.js&quot;</span>, <span class="s2">&quot;js/my_code.js&quot;</span>,<span class="o">)</span> </span></pre></div> </td></tr></table>
django, jquery, python