snipt

Ctrl+h for KB shortcuts

Text only

Create a symbolic link on windows

1
2
3
4
5
C:\mklink /D C:\TestFolder C:\Users\Geek\TestFolder

symbolic link created for C:\TestFolder <<===>> C:\Users\Geek\TestFolder

src: http://www.howtogeek.com/howto/windows-vista/using-symlinks-in-windows-vista/
https://snipt.net/embed/2292b873cca27e43091fa1f3ad9f65fe/
/raw/2292b873cca27e43091fa1f3ad9f65fe/
2292b873cca27e43091fa1f3ad9f65fe
text
Text only
5
2019-06-19T06:22:37
True
False
False
/api/public/snipt/7838/
create-a-symbolic-link-on-windows
<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>C:\mklink /D C:\TestFolder C:\Users\Geek\TestFolder </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>symbolic link created for C:\TestFolder &lt;&lt;===&gt;&gt; C:\Users\Geek\TestFolder </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>src: http://www.howtogeek.com/howto/windows-vista/using-symlinks-in-windows-vista/ </span></pre></div> </td></tr></table>
symboliclink, windows

Text only

PHP Find & Replace, to fix unquoted array indexes [key] => ['key']

1
2
3
4
5
regex:
(\[)[a-zA-Z0-9\-]*(\])

replace:
['$2']
https://snipt.net/embed/0b09676f104e19d27e02faedb04e3464/
/raw/0b09676f104e19d27e02faedb04e3464/
0b09676f104e19d27e02faedb04e3464
text
Text only
6
2019-06-18T06:37:17
True
False
False
/api/public/snipt/7007/
php-find-replace-to-fix-unquoted-array-indexes-key-key
<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>regex: </span><span id="L-2"><a name="L-2"></a>(\[)[a-zA-Z0-9\-]*(\]) </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>replace: </span><span id="L-5"><a name="L-5"></a>[&#39;$2&#39;] </span></pre></div> </td></tr></table>
php, regex

Text only

Django tip from StackOverflow

1
2
3
4
5
6
Install Django Command Extensions and pygraphviz and then issue the following command to get a really nice looking Django model visualization:

./manage.py graph_models -a -g -o my_project.png

See the rest here:
http://stackoverflow.com/questions/550632/favorite-django-tips-features
https://snipt.net/embed/d4d40e12173ab323b2dfbb1c8d1359e6/
/raw/d4d40e12173ab323b2dfbb1c8d1359e6/
d4d40e12173ab323b2dfbb1c8d1359e6
text
Text only
6
2019-05-29T14:07:48
True
False
False
/api/public/snipt/6475/
django-tip-from-stackoverflow
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>Install Django Command Extensions and pygraphviz and then issue the following command to get a really nice looking Django model visualization: </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>./manage.py graph_models -a -g -o my_project.png </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>See the rest here: </span><span id="L-6"><a name="L-6"></a>http://stackoverflow.com/questions/550632/favorite-django-tips-features </span></pre></div> </td></tr></table>
django

Django/Jinja

Iterate over a dict in a Django template

{% for key,value in dictionary.items %}{{ value }}{% endfor %}
https://snipt.net/embed/bddb1ace7b9a1ebc0a171afc7190704b/
/raw/bddb1ace7b9a1ebc0a171afc7190704b/
bddb1ace7b9a1ebc0a171afc7190704b
django
Django/Jinja
1
2019-06-08T03:23:47
True
False
False
/api/public/snipt/6334/
iterate-over-a-dict-in-a-django-template
<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="cp">{%</span> <span class="k">for</span> <span class="nv">key</span><span class="o">,</span><span class="nv">value</span> <span class="k">in</span> <span class="nv">dictionary.items</span> <span class="cp">%}{{</span> <span class="nv">value</span> <span class="cp">}}{%</span> <span class="k">endfor</span> <span class="cp">%}</span><span class="x"></span> </span></pre></div> </td></tr></table>
django

Bash

awk command for printing out a list of unique IP addresses from an apache access_log

awk '{ip[$1]=0} END {for (address in ip) { print address} }' /home/admin/logs/access_log
https://snipt.net/embed/b40e2bfb63ad279ce459b5d2ee0d1980/
/raw/b40e2bfb63ad279ce459b5d2ee0d1980/
b40e2bfb63ad279ce459b5d2ee0d1980
bash
Bash
1
2019-06-17T23:59:15
True
False
False
/api/public/snipt/6121/
awk-command-for-printing-out-a-list-of-unique-ip-addresses-from-an-apache-access_log
<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>awk <span class="s1">&#39;{ip[$1]=0} END {for (address in ip) { print address} }&#39;</span> /home/admin/logs/access_log </span></pre></div> </td></tr></table>
awk, bash

Bash

Globally ignore .pyc files

1
2
3
nano ~/.subversion/config
global-ignores = *.pyc
ctrl-x-z
https://snipt.net/embed/e3ebb456ace0c2321aa13434354355dc/
/raw/e3ebb456ace0c2321aa13434354355dc/
e3ebb456ace0c2321aa13434354355dc
bash
Bash
3
2019-05-29T14:51:10
True
False
False
/api/public/snipt/5133/
globally-ignore-pyc-files
<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>nano ~/.subversion/config </span><span id="L-2"><a name="L-2"></a>global-ignores <span class="o">=</span> *.pyc </span><span id="L-3"><a name="L-3"></a>ctrl-x-z </span></pre></div> </td></tr></table>
svn

Bash

Apache2 permanent redirect to external URL

1
2
3
## APACHE2: permanently redirect local link to external URL

Redirect 301 /blog/rss http://feeds2.feedburner.com/petekarl
https://snipt.net/embed/c131cd47d5804ebd98776f65b56fa731/
/raw/c131cd47d5804ebd98776f65b56fa731/
c131cd47d5804ebd98776f65b56fa731
bash
Bash
3
2019-05-30T22:26:45
True
False
False
/api/public/snipt/4976/
apache2-permanent-redirect-to-external-url
<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">## APACHE2: permanently redirect local link to external URL</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>Redirect <span class="m">301</span> /blog/rss http://feeds2.feedburner.com/petekarl </span></pre></div> </td></tr></table>
apache, redirect