snipt

Ctrl+h for KB shortcuts

Bash

start mysql

1
2
3
4
cd /usr/local/mysql
sudo ./bin/mysqld_safe
ctrl Z
bg
https://snipt.net/embed/be91d91ed21ece7b1c476c075b7cfe6a/
/raw/be91d91ed21ece7b1c476c075b7cfe6a/
be91d91ed21ece7b1c476c075b7cfe6a
bash
Bash
4
2019-06-07T20:27:33
True
False
False
/api/public/snipt/383/
start-mysql
<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><span class="nb">cd</span> /usr/local/mysql </span><span id="L-2"><a name="L-2"></a>sudo ./bin/mysqld_safe </span><span id="L-3"><a name="L-3"></a>ctrl Z </span><span id="L-4"><a name="L-4"></a><span class="nb">bg</span> </span></pre></div> </td></tr></table>
mysql, terminal

Ruby

select

1
2
3
<% t = Tipo.find :all %>
<%= f.label :tipo %><br />
    <%= select "usuario", "tipo", t.collect{|v| [v.nombre, v.id]} %>
https://snipt.net/embed/fd45798317282490a48a30dec1a27f2e/
/raw/fd45798317282490a48a30dec1a27f2e/
fd45798317282490a48a30dec1a27f2e
rb
Ruby
3
2019-06-11T18:42:50
True
False
False
/api/public/snipt/380/
select-1
<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="o">&lt;</span><span class="sx">% t </span><span class="o">=</span> <span class="no">Tipo</span><span class="o">.</span><span class="n">find</span> <span class="ss">:all</span> <span class="sx">%&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="sx">&lt;%= f.label :tipo %&gt;</span><span class="o">&lt;</span><span class="n">br</span> <span class="sr">/&gt;</span> </span><span id="L-3"><a name="L-3"></a><span class="sr"> &lt;%= select &quot;usuario&quot;, &quot;tipo&quot;, t.collect{|v| [v.nombre, v.id]} %&gt;</span> </span></pre></div> </td></tr></table>
ruby, select

Ruby

Leer CSV

1
2
3
4
# require 'csv' al principio del script
CSV::Reader.parse(File.open('/home/boris/Escritorio/contratos.csv', 'rb')) do |row|
  row[0] # Se hace lo que se quiera
end
https://snipt.net/embed/ecd619ac4f06357c734f50bac9b8ab46/
/raw/ecd619ac4f06357c734f50bac9b8ab46/
ecd619ac4f06357c734f50bac9b8ab46
rb
Ruby
4
2019-06-18T02:52:59
True
False
False
/api/public/snipt/379/
leer-csv
<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><span class="c1"># require &#39;csv&#39; al principio del script</span> </span><span id="L-2"><a name="L-2"></a><span class="no">CSV</span><span class="o">::</span><span class="no">Reader</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="no">File</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;/home/boris/Escritorio/contratos.csv&#39;</span><span class="p">,</span> <span class="s1">&#39;rb&#39;</span><span class="p">))</span> <span class="k">do</span> <span class="o">|</span><span class="n">row</span><span class="o">|</span> </span><span id="L-3"><a name="L-3"></a> <span class="n">row</span><span class="o">[</span><span class="mi">0</span><span class="o">]</span> <span class="c1"># Se hace lo que se quiera</span> </span><span id="L-4"><a name="L-4"></a><span class="k">end</span> </span></pre></div> </td></tr></table>
csv, ruby

Bash

borrar despues de buscar

find -name "nombre" -exec rm -rf {} \;
https://snipt.net/embed/73365c24c580ca3b8d4ec9a927349c10/
/raw/73365c24c580ca3b8d4ec9a927349c10/
73365c24c580ca3b8d4ec9a927349c10
bash
Bash
1
2019-06-15T15:33:38
True
False
False
/api/public/snipt/378/
borrar-despues-de-buscar
<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;nombre&quot;</span> -exec rm -rf <span class="o">{}</span> <span class="se">\;</span> </span></pre></div> </td></tr></table>
bash, find

Bash

Adicionar a github un proyecto

1
2
3
cd existing_git_repo
git remote add origin [email protected]:boriscy/enano.git
git push origin master
https://snipt.net/embed/9859514fd0459be3ef0cfd57e0853ef3/
/raw/9859514fd0459be3ef0cfd57e0853ef3/
9859514fd0459be3ef0cfd57e0853ef3
bash
Bash
4
2019-06-16T11:20:43
True
False
False
/api/public/snipt/377/
adicionar-a-github-un-proyecto
<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="nb">cd</span> existing_git_repo </span><span id="L-2"><a name="L-2"></a>git remote add origin [email protected]:boriscy/enano.git </span><span id="L-3"><a name="L-3"></a>git push origin master </span></pre></div> </td></tr></table>
git

Perl

Declaring a Perl multi-dimensional hash

1
2
3
4
my %multidimensional_hash = (
'sub_hash1' => {'key' => 'value'},
'sub_hash2' => {'key' => 'value'}
);
https://snipt.net/embed/9ffa2371a7482a57ff5cba7c9df1ac76/
/raw/9ffa2371a7482a57ff5cba7c9df1ac76/
9ffa2371a7482a57ff5cba7c9df1ac76
perl
Perl
4
2019-06-09T12:01:20
True
False
False
/api/public/snipt/373/
declaring-a-perl-multi-dimensional-hash
<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><span class="k">my</span> <span class="nv">%multidimensional_hash</span> <span class="o">=</span> <span class="p">(</span> </span><span id="L-2"><a name="L-2"></a><span class="s">&#39;sub_hash1&#39;</span> <span class="o">=&gt;</span> <span class="p">{</span><span class="s">&#39;key&#39;</span> <span class="o">=&gt;</span> <span class="s">&#39;value&#39;</span><span class="p">},</span> </span><span id="L-3"><a name="L-3"></a><span class="s">&#39;sub_hash2&#39;</span> <span class="o">=&gt;</span> <span class="p">{</span><span class="s">&#39;key&#39;</span> <span class="o">=&gt;</span> <span class="s">&#39;value&#39;</span><span class="p">}</span> </span><span id="L-4"><a name="L-4"></a><span class="p">);</span> </span></pre></div> </td></tr></table>
perl

Django/Jinja

How long Years Field Chose

years = list((('%s' % x, '%s' % x) for x in range(1,100)))
https://snipt.net/embed/9284a08f3f2a46cf3be5f28f481d9820/
/raw/9284a08f3f2a46cf3be5f28f481d9820/
9284a08f3f2a46cf3be5f28f481d9820
django
Django/Jinja
1
2019-05-25T19:43:54
True
False
False
/api/public/snipt/362/
how-long-years-field-chose
<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="x">years = list(((&#39;%s&#39; % x, &#39;%s&#39; % x) for x in range(1,100)))</span> </span></pre></div> </td></tr></table>
choices, django, field, python, year