Skip to content

Instantly share code, notes, and snippets.

@iprodev
iprodev / make_api_calls.php
Created December 14, 2018 18:46
PHP : Make API Calls in PHP
<?php
/**
* Make API Calls in PHP
*
* @param string $method The HTTP method (GET or POST) to be used
* @param string $url The URL
* @param array $data The data should send with POST
* @return string Response from the url
*/
function CallAPI( $method, $url, $data = false ) {
@iprodev
iprodev / neon.css
Last active December 14, 2018 18:37
CSS : Neon Text Effect with CSS3
body {
background-color:#424242;
}
.neon-effect {
text-align:center;
font-size:40px;
margin:20px 0 20px 0;
color:#ffffff;
text-shadow: 0 0 10px #ffffff,
@iprodev
iprodev / openssl_hash_cipher.php
Last active December 14, 2018 19:43
PHP : Powerful encrypt and decrypt using OpenSSL
<?php
/**
* Powerful method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@iprodev
iprodev / search-and-replace.sql
Created December 14, 2018 18:11
SQL : Search and Replace
UPDATE tableName
SET columnName = REPLACE(
columnName,
'TEXT TO SEARCH FOR',
'TEXT TO REPLACE WITH'
)
@iprodev
iprodev / faster-mysql-counting-on-joins.sql
Last active December 14, 2018 18:09
SQL : Faster MySQL Counting on JOINS
SELECT
user_accounts.id,
user_accounts.company_name,
IFNULL(suppliers.count, 0) AS suppliers,
IFNULL(customers.count, 0) AS customers,
IFNULL(inventory_transactions.count, 0) AS transactions
FROM user_accounts
LEFT JOIN (SELECT
user_account_id,
@iprodev
iprodev / has-duplicate.php
Last active December 14, 2018 18:00
PHP : Check if array has duplicate values
<?php
/**
* Check if array has duplicate values
*
* @param array $array Specific array to check
* @return boolean
*/
function array_has_duplicate( $array ) {
return count( $array ) !== count( array_keys( array_flip( $array ) ) );