Skip to content

Instantly share code, notes, and snippets.

@ManishLSN
ManishLSN / curlBackground.php
Created July 13, 2017 06:39
curl in backgroupd by php
<?php
$request = array("abc"=> $abcd, "adsf"=> $asdf, "duration" => $duration, "callback_url"=>$callBackUrl);
// echo "<pre>"; print_r($request); die;
$json = json_encode($request);
$ch = curl_init(HUB_MEDIA_SERVER_TEXT2VIDEO.'phpfile.php');
// $ch = curl_init(HUB_MEDIA_SERVER_TEXT2VIDEO.'textToVideoDev.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
@ManishLSN
ManishLSN / saveIPandReferer.php
Created July 12, 2017 09:19
Save IP address and referrer of our page Let's suppose we want to record the IP address and Referrer of all visitors to our page. The script bellow may be placed within the code of our page and it will create two files to store both data: "ips_file.txt" to store IP addresses and "ref_file.txt" to store referrers. Additionally, this script may be…
<?
// save ip
$ip=$_SERVER["REMOTE_ADDR"];
if ($ip!=""){
$ipfile= "ips_file.txt";
$allips = file_get_contents ($ipfile);
if (strpos($allips," $ip ")>0){
$allips = preg_replace ("/ $ip /"," $ip x",$allips);
$tempvar= fopen($ipfile, "w");
fwrite ($tempvar, $allips);
@ManishLSN
ManishLSN / node-and-npm-in-30-seconds.sh
Created May 3, 2017 12:27 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
<?php
function processURL($url){
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2
));
@ManishLSN
ManishLSN / db-connect-test.php
Created February 8, 2017 11:06 — forked from chales/db-connect-test.php
Script for a quick PHP MySQL DB connection test.
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
@ManishLSN
ManishLSN / for vishal file
Created December 8, 2016 07:06
this is just a testing gist
<pre>
<?php
$origarray1 = array(2.4, 2.6, 3.5);
$origarray2 = array(2.4, 2.6, 3.5);
print_r(array_map('floor', $origarray1)); // $origarray1 stays the same
// changes $origarray2
array_walk($origarray2, function (&$v, $k) { $v = floor($v); });