snipt

Ctrl+h for KB shortcuts

Text only

set psycopg2 to return unicode objects

1
2
3
4
import psycopg2
import psycopg2.extensions
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
https://snipt.net/embed/7a2dd85c29300da943e1d0d84e963816/
/raw/7a2dd85c29300da943e1d0d84e963816/
7a2dd85c29300da943e1d0d84e963816
text
Text only
5
2019-06-04T10:30:52
True
False
False
/api/public/snipt/19547/
set-psycopg2-to-return-unicode-objects
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>import psycopg2 </span><span id="L-2"><a name="L-2"></a>import psycopg2.extensions </span><span id="L-3"><a name="L-3"></a>psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) </span><span id="L-4"><a name="L-4"></a>psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY) </span></pre></div> </td></tr></table>
psycopg2

Text only

simple cron log

* * * * * ( date ; python /home/script.py ) >>/tmp/fetch.out 2>&1
https://snipt.net/embed/de14660d5b40c742b384974853c6a9be/
/raw/de14660d5b40c742b384974853c6a9be/
de14660d5b40c742b384974853c6a9be
text
Text only
2
2019-06-04T03:37:28
True
False
False
/api/public/snipt/19451/
simple-cron-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>* * * * * ( date ; python /home/script.py ) &gt;&gt;/tmp/fetch.out 2&gt;&amp;1 </span></pre></div> </td></tr></table>
cron

Text only

copy psql db from local to remote

pg_dump -C dbname | bzip2 | ssh  [email protected] -p 99 "bunzip2 | psql dbname"
https://snipt.net/embed/42502787170385059b0bf15f30bd5313/
/raw/42502787170385059b0bf15f30bd5313/
42502787170385059b0bf15f30bd5313
text
Text only
2
2019-05-31T19:18:59
True
False
False
/api/public/snipt/10416/
copy-psql-db
<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>pg_dump -C dbname | bzip2 | ssh [email protected] -p 99 &quot;bunzip2 | psql dbname&quot; </span></pre></div> </td></tr></table>
db, dump, psql

Text only

X,gnome start/stop

1
2
3
/etc/init.d/gdm stop

/etc/init.d/gdm start
https://snipt.net/embed/bddebb008a593d8d1fa88ce431aacde5/
/raw/bddebb008a593d8d1fa88ce431aacde5/
bddebb008a593d8d1fa88ce431aacde5
text
Text only
3
2019-05-27T03:00:17
True
False
False
/api/public/snipt/6750/
xgnome-startstop
<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>/etc/init.d/gdm stop </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>/etc/init.d/gdm start </span></pre></div> </td></tr></table>
gnome, ubuntu, x

Text only

micro configure emacs color settings

Mx-describe-face
https://snipt.net/embed/c077a60c8db6a5d33329a34402ba5582/
/raw/c077a60c8db6a5d33329a34402ba5582/
c077a60c8db6a5d33329a34402ba5582
text
Text only
1
2019-06-07T11:07:13
True
False
False
/api/public/snipt/6739/
micro-configure-emacs-color-settings
<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>Mx-describe-face </span></pre></div> </td></tr></table>
emacs, font

Text only

show java object in clojure

1
2
3
 showing the members of a java object (eg HashMap)

(show java.util.HashMap)
https://snipt.net/embed/499f400249744add5496acc145355acc/
/raw/499f400249744add5496acc145355acc/
499f400249744add5496acc145355acc
text
Text only
4
2019-06-01T01:56:39
True
False
False
/api/public/snipt/6738/
show-java-object-in-clojure
<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> showing the members of a java object (eg HashMap) </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>(show java.util.HashMap) </span></pre></div> </td></tr></table>
java, show

Text only

get clojure function code

(use 'clojure.contrib.repl-utils) 
(source symbol) 
https://snipt.net/embed/c78bd1b462541dca2a3c89ff874f7fc9/
/raw/c78bd1b462541dca2a3c89ff874f7fc9/
c78bd1b462541dca2a3c89ff874f7fc9
text
Text only
3
2019-06-16T05:40:27
True
False
False
/api/public/snipt/6737/
get-clojure-function-code
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>(use &#39;clojure.contrib.repl-utils) </span><span id="L-2"><a name="L-2"></a>(source symbol) </span></pre></div> </td></tr></table>
clj, clojure, source

Text only

hackpush

1
2
3
4
5
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
git checkout master
git merge ${CURRENT}
git push origin master
git checkout ${CURRENT}
https://snipt.net/embed/8e41eba11ecc86e73693cd88e8d9ab5d/
/raw/8e41eba11ecc86e73693cd88e8d9ab5d/
8e41eba11ecc86e73693cd88e8d9ab5d
text
Text only
5
2019-05-22T17:19:12
True
False
False
/api/public/snipt/5839/
hackpush
<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>CURRENT=`git branch | grep &#39;\*&#39; | awk &#39;{print $2}&#39;` </span><span id="L-2"><a name="L-2"></a>git checkout master </span><span id="L-3"><a name="L-3"></a>git merge ${CURRENT} </span><span id="L-4"><a name="L-4"></a>git push origin master </span><span id="L-5"><a name="L-5"></a>git checkout ${CURRENT} </span></pre></div> </td></tr></table>
git