Last active
April 23, 2017 08:47
-
-
Save nixon1333/a42fed6ca6cea87dbfae8fd69ffbc393 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//======================== | |
//curl | |
//======================== | |
$post = [ | |
'username' => 'user1', | |
'password' => 'passuser1', | |
'gender' => 1, | |
]; | |
$headers = array( | |
'Content-Type:application/json', | |
'Authorization: Bearer sk_test_b17f357f0aefb9be65097c98b24bf2ff1bfd9e78'); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, 'http://www.domain.com'); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |
$response = curl_exec($ch); | |
var_export($response); | |
//======================== | |
//db select | |
//======================== | |
$servername = "localhost"; | |
$username = "username"; | |
$password = "password"; | |
$dbname = "myDB"; | |
// Create connection | |
$conn = new mysqli($servername, $username, $password, $dbname); | |
// Check connection | |
if ($conn->connect_error) { | |
die("Connection failed: " . $conn->connect_error); | |
} | |
//============ | |
//select data | |
$sql = "SELECT id, firstname, lastname FROM TABLE_NAME LIMIT 10 OFFSET 15"; | |
$result = $conn->query($sql); | |
if ($result->num_rows > 0) { | |
// output data of each row | |
while($row = $result->fetch_assoc()) { | |
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>"; | |
} | |
} else { | |
echo "0 results"; | |
} | |
//end select data | |
//============ | |
//============ | |
//insert data | |
$sql = "INSERT INTO TABLE_NAME (firstname, lastname, email) VALUES ('John', 'Doe', 'john@example.com')"; | |
if ($conn->query($sql) === TRUE) { | |
echo "New record created successfully"; | |
} else { | |
echo "Error: " . $sql . "<br>" . $conn->error; | |
} | |
//end insert data | |
//============ | |
//============ | |
//update data | |
$sql = "UPDATE TABLE_NAME SET lastname='Doe' WHERE id=2"; | |
if ($conn->query($sql) === TRUE) { | |
echo "Record updated successfully"; | |
} else { | |
echo "Error updating record: " . $conn->error; | |
} | |
//end update data | |
//============ | |
//============ | |
//delete data | |
$sql = "DELETE FROM TABLE_NAME WHERE id=3"; | |
if ($conn->query($sql) === TRUE) { | |
echo "Record deleted successfully"; | |
} else { | |
echo "Error deleting record: " . $conn->error; | |
} | |
//end delete data | |
//============ | |
$conn->close(); | |
//======================== | |
//image resize using imagemagic | |
//======================== | |
shell_exec ("convert -resize {$this->width}^x{$this->height}^ -gravity center -crop {$this->width}x{$this->height}+0+0 +repage \"{$this->tempFile}\" \"" . $this->fileDir . $this->processedFile . '"'); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//=============== | |
//composer | |
//=============== | |
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer | |
composer install --prefer-dist -vvv --profile | |
composer update --prefer-dist -vvv --profile | |
//swap | |
dd if=/dev/zero of=/swapfile bs=1024 count=512k | |
mkswap /swapfile | |
swapon /swapfile | |
echo "/swapfile none swap sw 0 0 " >> /etc/fstab | |
echo 0 > /proc/sys/vm/swappiness | |
chown root:root /swapfile | |
chmod 0600 /swapfile | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment