Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Common Lisp

repeat text n times - useful in the emacs editor

1
2
3
4
5
6
7
8
(defun text-repeat (n)
  "Insert a block of text,repeated n times."
  (interactive "p")
  (progn
    (insert "the text to repeat\n")
    (cond ((> n 1) (text-repeat (- n 1))))))

(define-key global-map [f7] 'text-repeat)
https://snipt.net/embed/981842e4e0807173bb21b6dfa62dc0d8/
https://snipt.net/raw/981842e4e0807173bb21b6dfa62dc0d8/
981842e4e0807173bb21b6dfa62dc0d8
common-lisp
Common Lisp
8
2016-12-02T16:15:26
True
False
False
/api/public/snipt/26953/
repeat-text-n-times
<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="p">(</span><span class="nb">defun</span> <span class="nv">text-repeat</span> <span class="p">(</span><span class="nv">n</span><span class="p">)</span> </span><span id="L-2"><a name="L-2"></a> <span class="s">&quot;Insert a block of text,repeated n times.&quot;</span> </span><span id="L-3"><a name="L-3"></a> <span class="p">(</span><span class="nv">interactive</span> <span class="s">&quot;p&quot;</span><span class="p">)</span> </span><span id="L-4"><a name="L-4"></a> <span class="p">(</span><span class="k">progn</span> </span><span id="L-5"><a name="L-5"></a> <span class="p">(</span><span class="nv">insert</span> <span class="s">&quot;the text to repeat\n&quot;</span><span class="p">)</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">(</span><span class="nb">cond</span> <span class="p">((</span><span class="nb">&gt;</span> <span class="nv">n</span> <span class="mi">1</span><span class="p">)</span> <span class="p">(</span><span class="nv">text-repeat</span> <span class="p">(</span><span class="nb">-</span> <span class="nv">n</span> <span class="mi">1</span><span class="p">))))))</span> </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a><span class="p">(</span><span class="nv">define-key</span> <span class="nv">global-map</span> <span class="nv">[f7]</span> <span class="ss">&#39;text-repeat</span><span class="p">)</span> </span></pre></div> </td></tr></table>
elisp, emacs, lisp, recursion

Bash

Delete recursively a file (.DS_Store, thumbs.db, desktop.ini, etc.)

find . -name ".DS_Store" -depth -exec rm {} \;
https://snipt.net/embed/faadacd4013789e46ac9532c9829ed72/
https://snipt.net/raw/faadacd4013789e46ac9532c9829ed72/
faadacd4013789e46ac9532c9829ed72
bash
Bash
1
2016-12-02T16:42:37
True
False
False
/api/public/snipt/1625/
delete-recursively-a-file-ds_store-thumbsdb-desktopini-etc
<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>find . -name <span class="s2">&quot;.DS_Store&quot;</span> -depth -exec rm <span class="o">{}</span> <span class="se">\;</span> </span></pre></div> </td></tr></table>
bash, delete, file, files, find, recursion, recursively
Copyrighted, illegal, or inappropriate content? Email [email protected].