snipt

Ctrl+h for KB shortcuts

Text only

get text to call android

1
2
3
4
5
6
7
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+txtPhn.getText().toString()));
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(callIntent);

set permission into manifest
<uses-permission android:name="android.permission.CALL_PHONE" />
https://snipt.net/embed/a5ce4ccd5a8f914efac17cdf48640d2e/
https://snipt.net/raw/a5ce4ccd5a8f914efac17cdf48640d2e/
a5ce4ccd5a8f914efac17cdf48640d2e
text
Text only
7
2016-09-28T08:22:00
True
False
False
Mar 22, 2016 at 09:56 AM
/api/public/snipt/144849/
get-text-to-call-android
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>Intent callIntent = new Intent(Intent.ACTION_CALL); </span><span id="L-2"><a name="L-2"></a>callIntent.setData(Uri.parse(&quot;tel:&quot;+txtPhn.getText().toString())); </span><span id="L-3"><a name="L-3"></a>callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); </span><span id="L-4"><a name="L-4"></a>startActivity(callIntent); </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a>set permission into manifest </span><span id="L-7"><a name="L-7"></a>&lt;uses-permission android:name=&quot;android.permission.CALL_PHONE&quot; /&gt; </span></pre></div> </td></tr></table>
android, call, text

JavaScript

Initiate Phone Call

<script>window.location.href='tel:9998887777';</script>
https://snipt.net/embed/49774867697d463695eec22b882871ca/
https://snipt.net/raw/49774867697d463695eec22b882871ca/
49774867697d463695eec22b882871ca
js
JavaScript
1
2016-09-29T12:31:29
True
False
False
Aug 18, 2015 at 11:43 AM
/api/public/snipt/140670/
initiate-phone-call
<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="o">&lt;</span><span class="nx">script</span><span class="o">&gt;</span><span class="nb">window</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">href</span><span class="o">=</span><span class="s1">&#39;tel:9998887777&#39;</span><span class="p">;</span><span class="o">&lt;</span><span class="err">/script&gt;</span> </span></pre></div> </td></tr></table>
"click to call", call, javascript

Python

read stdout after system call

str = subprocess.Popen(['ls', '-l'], stdout=subprocess.PIPE).communicate()[0]
https://snipt.net/embed/eb6050a55db29206e7fa679860cc22cb/
https://snipt.net/raw/eb6050a55db29206e7fa679860cc22cb/
eb6050a55db29206e7fa679860cc22cb
python
Python
1
2016-09-28T21:06:38
True
False
False
/api/public/snipt/21868/
read-stdout-after-system-call
<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="nb">str</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">([</span><span class="s">&#39;ls&#39;</span><span class="p">,</span> <span class="s">&#39;-l&#39;</span><span class="p">],</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">)</span><span class="o">.</span><span class="n">communicate</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> </span></pre></div> </td></tr></table>
call, read, stdout, system

JavaScript+Ruby

Array.map

1
2
3
4
5
6
7
8
Array.prototype.map = function(func) {
  var arr = [];
  for(var i = 0, l = this.length; i < l; i++) {
    arr.push( func.call(this, this[i]) );
  }
  return arr;
};
[1,2,3,4].map( function(v) { return v * v * v } );
https://snipt.net/embed/80baf340a435f46fd8973205ec33adcb/
https://snipt.net/raw/80baf340a435f46fd8973205ec33adcb/
80baf340a435f46fd8973205ec33adcb
js+erb
JavaScript+Ruby
8
2016-09-29T12:39:03
True
False
False
/api/public/snipt/17601/
arraymap
<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 id="L-1"><a name="L-1"></a><span class="nb">Array</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">map</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">func</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="kd">var</span> <span class="nx">arr</span> <span class="o">=</span> <span class="p">[];</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">l</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">l</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="nx">arr</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span> <span class="nx">func</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="k">this</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span> <span class="p">);</span> </span><span id="L-5"><a name="L-5"></a> <span class="p">}</span> </span><span id="L-6"><a name="L-6"></a> <span class="k">return</span> <span class="nx">arr</span><span class="p">;</span> </span><span id="L-7"><a name="L-7"></a><span class="p">};</span> </span><span id="L-8"><a name="L-8"></a><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">].</span><span class="nx">map</span><span class="p">(</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">v</span> <span class="o">*</span> <span class="nx">v</span> <span class="o">*</span> <span class="nx">v</span> <span class="p">}</span> <span class="p">);</span> </span></pre></div> </td></tr></table>
call, closure, javascript
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.