snipt

Ctrl+h for KB shortcuts

PHP

Timestamp in PHP for up to the minute changes

<!-- Just because I'm bored to look at the PHP docs -->
<?php echo date('YmdHi'); ?>
https://snipt.net/embed/b6f70ec894c0566d2eb5cf9b6ff37027/
/raw/b6f70ec894c0566d2eb5cf9b6ff37027/
b6f70ec894c0566d2eb5cf9b6ff37027
php
PHP
3
2019-08-22T10:04:17
True
False
False
Feb 08, 2014 at 07:45 AM
/api/public/snipt/111918/
timestamp-in-php-for-up-to-the-minute-changes
<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><span class="x">&lt;!-- Just because I&#39;m bored to look at the PHP docs --&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nb">date</span><span class="p">(</span><span class="s1">&#39;YmdHi&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
php, timestamp

Nginx configuration file

Backbone.js rewrite for Nginx

1
2
3
4
5
        location / {
        		if (!-e $request_filename){
        			rewrite ^(.*)$ /index.html break;
        		}
        }
https://snipt.net/embed/ab9ed4a5f3702f4c11307dd1f510415f/
/raw/ab9ed4a5f3702f4c11307dd1f510415f/
ab9ed4a5f3702f4c11307dd1f510415f
nginx
Nginx configuration file
5
2019-08-21T19:21:28
True
False
False
Apr 30, 2013 at 08:22 PM
/api/public/snipt/60379/
backbonejs-rewrite-for-nginx
<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> <span class="k">location</span> <span class="s">/</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="kn">if</span> <span class="s">(!-e</span> <span class="nv">$request_filename</span><span class="s">)</span><span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="kn">rewrite</span> <span class="s">^(.*)</span>$ <span class="s">/index.html</span> <span class="s">break</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> <span class="p">}</span> </span><span id="L-5"><a name="L-5"></a> <span class="p">}</span> </span></pre></div> </td></tr></table>
backbone.js, nginx, rewrite, rewrites

JavaScript

PHP rand() equivalent for JavaScript

1
2
3
function rand(min, max){
    return Math.floor(Math.random() * (max - min + 1)) + min;
}
https://snipt.net/embed/dbc9960b0a7f663f9d52e39df736d87d/
/raw/dbc9960b0a7f663f9d52e39df736d87d/
dbc9960b0a7f663f9d52e39df736d87d
js
JavaScript
3
2019-08-24T19:39:49
True
False
False
Apr 13, 2013 at 11:21 AM
/api/public/snipt/59262/
php-rand-equivalent-for-javascript
<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="kd">function</span> <span class="nx">rand</span><span class="p">(</span><span class="nx">min</span><span class="p">,</span> <span class="nx">max</span><span class="p">){</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">return</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">(</span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span> <span class="o">*</span> <span class="p">(</span><span class="nx">max</span> <span class="o">-</span> <span class="nx">min</span> <span class="o">+</span> <span class="mi">1</span><span class="p">))</span> <span class="o">+</span> <span class="nx">min</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
function, javascript, php, rand, random

CSS

Native style momentum scrolling to arrive in iOS 5

1
2
3
4
element {
	overflow: scroll;
	-webkit-overflow-scrolling: touch;
}
https://snipt.net/embed/0fd63372964650875f919b4be9b3d8a6/
/raw/0fd63372964650875f919b4be9b3d8a6/
0fd63372964650875f919b4be9b3d8a6
css
CSS
4
2019-08-22T12:14:57
True
False
False
Jan 24, 2013 at 08:53 AM
/api/public/snipt/54385/
native-style-momentum-scrolling-to-arrive-in-ios-5
<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="nt">element</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="nb">overflow</span><span class="o">:</span> <span class="nb">scroll</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a> <span class="o">-</span><span class="n">webkit</span><span class="o">-</span><span class="nb">overflow</span><span class="o">-</span><span class="n">scrolling</span><span class="o">:</span> <span class="n">touch</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>
ios, ipad, iphone, mobile, scrolling

PHP

Grab website screenshot using Wordpress.com

<img src="<?php echo 'http://s.wordpress.com/mshots/v1/'.urlencode('http://domain.com/').'?w=200' ?>" />
https://snipt.net/embed/003bf7ddb1d2a3b0619427fbddf729e1/
/raw/003bf7ddb1d2a3b0619427fbddf729e1/
003bf7ddb1d2a3b0619427fbddf729e1
php
PHP
1
2019-08-23T18:17:14
True
False
False
Dec 14, 2012 at 10:19 AM
/api/public/snipt/51850/
grab-website-screenshot-using-wordpresscom
<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">&lt;img src=&quot;</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="s1">&#39;http://s.wordpress.com/mshots/v1/&#39;</span><span class="o">.</span><span class="nb">urlencode</span><span class="p">(</span><span class="s1">&#39;http://domain.com/&#39;</span><span class="p">)</span><span class="o">.</span><span class="s1">&#39;?w=200&#39;</span> <span class="cp">?&gt;</span><span class="x">&quot; /&gt;</span> </span></pre></div> </td></tr></table>