snipt

Ctrl+h for KB shortcuts

PHP

Generate random hex color

1
2
3
4
5
<?php

$color = '#'.str_pad(dechex(rand(0,255)), 2, 0).str_pad(dechex(rand(0,255)), 2, 0).str_pad(dechex(rand(0,255)), 2, 0);

?>
https://snipt.net/embed/6cf0e2b075edfb2514c35c15e9f17dc4/
https://snipt.net/raw/6cf0e2b075edfb2514c35c15e9f17dc4/
6cf0e2b075edfb2514c35c15e9f17dc4
php
PHP
5
2016-09-28T19:47:32
True
False
False
/api/public/snipt/147047/
generate-random-hex-color
<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 id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="nv">$color</span> <span class="o">=</span> <span class="s1">&#39;#&#39;</span><span class="o">.</span><span class="nb">str_pad</span><span class="p">(</span><span class="nb">dechex</span><span class="p">(</span><span class="nb">rand</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">255</span><span class="p">)),</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="nb">str_pad</span><span class="p">(</span><span class="nb">dechex</span><span class="p">(</span><span class="nb">rand</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">255</span><span class="p">)),</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="nb">str_pad</span><span class="p">(</span><span class="nb">dechex</span><span class="p">(</span><span class="nb">rand</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">255</span><span class="p">)),</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
color, hex, php

Shell Session

Colorize console for git

git config --global color.ui true
https://snipt.net/embed/99042d201bbce5a6dc3a670d1ec83389/
https://snipt.net/raw/99042d201bbce5a6dc3a670d1ec83389/
99042d201bbce5a6dc3a670d1ec83389
shell-session
Shell Session
1
2016-09-25T06:40:25
True
False
False
Sep 27, 2013 at 01:48 PM
/api/public/snipt/83653/
colorize-console-for-git
<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 id="L-1"><a name="L-1"></a><span class="go">git config --global color.ui true</span> </span></pre></div> </td></tr></table>
color, colorscheme, console, git, terminal

Java

Loop Through All Values of Luminance

int dmod = frameCount%510;
int col = dmod<255?dmod:510-dmod;
https://snipt.net/embed/1401a9bebbf0fc3b97bc401abdc003ad/
https://snipt.net/raw/1401a9bebbf0fc3b97bc401abdc003ad/
1401a9bebbf0fc3b97bc401abdc003ad
java
Java
2
2016-09-21T19:14:57
True
False
False
Aug 01, 2013 at 07:40 AM
/api/public/snipt/71174/
loop-through-all-values-of-luminance
<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 id="L-1"><a name="L-1"></a><span class="kt">int</span> <span class="n">dmod</span> <span class="o">=</span> <span class="n">frameCount</span><span class="o">%</span><span class="mi">510</span><span class="o">;</span> </span><span id="L-2"><a name="L-2"></a><span class="kt">int</span> <span class="n">col</span> <span class="o">=</span> <span class="n">dmod</span><span class="o">&lt;</span><span class="mi">255</span><span class="o">?</span><span class="n">dmod</span><span class="o">:</span><span class="mi">510</span><span class="o">-</span><span class="n">dmod</span><span class="o">;</span> </span></pre></div> </td></tr></table>
color, processing
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.