This file contains hidden or 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 | |
$args = [ | |
'headers' => [ | |
'X-Api-Key' => 'Ek7o0F5OX29MzDjQYuDzy9FimBEOKwuukixRryN4' | |
] | |
]; | |
$response = wp_remote_get( "https://sandbox.postcodeapi.nu/v3/lookup/6545CA/29", $args); | |
if ( is_array( $response ) && ! is_wp_error( $response ) ) { | |
$body = $response['body']; # RESPONSE FROM API |
This file contains hidden or 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 | |
// A O(n^2) time and O(1) space program to find the longest palindromic substring | |
// A utility function to print a substring str[low..high] | |
function printSubStr($str, $low, $high) | |
{ | |
for( $i = $low; $i <= $high; ++$i ) | |
echo $str[$i]; | |
} |
This file contains hidden or 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 | |
$hay = 'aabdf'; | |
$nee = 'aaf'; | |
$lenHay = strlen($hay); | |
$lenNee = strlen($nee); | |
$arrNee = str_split($nee); | |
for($i = $lenNee; $i <= $lenHay; $i++){ |
This file contains hidden or 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 | |
//Enter your code here, enjoy! | |
$array = [1, 2, 2, 2, 3]; | |
$newArray = []; | |
$dupCount = 0; | |
foreach($array as $el) { | |
if(in_array($el, $newArray)) { |
This file contains hidden or 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
const isPrime = num => { | |
let sqrt = Math.sqrt(num); | |
for(let i = 2; i <= sqrt; i++) { | |
if(num % i === 0){ | |
return false; | |
} | |
} | |
return true; | |
} |
This file contains hidden or 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
// Print out all the numbers from 1 to 100. But for every number divisible by 3 print replace it with the | |
// word “Fizz,” for any number divisible by 5 replace it with the word “Buzz” and for a number divisible | |
// by both 3 and 5 replace it with the word “FizzBuzz.” | |
// So your program should output: | |
// 1 | |
// 2 | |
// Fizz | |
// 4 | |
// Buzz | |
// Fizz |
This file contains hidden or 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
'use strict'; | |
/** | |
* Detail Component | |
*/ | |
class ContactDetail extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = props.selectedContact | |
} |
This file contains hidden or 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 if (isset($_SESSION['message'])) : ?> | |
<div class="alert alert-<?= $_SESSION['type'] ?>"> | |
<?= $_SESSION['message'] ?> | |
</div> | |
<?php endif; unset($_SESSION['message']); unset($_SESSION['type']); ?> |
This file contains hidden or 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 | |
<?php | |
$user_data = wp_get_current_user(); | |
if (!is_user_logged_in()) : ?> | |
<div class="alert alert-danger"> | |
You don't have permission. | |
</div> | |
<?php | |
return false; elseif (!in_array('webmaster', (array) $user_data->roles) && !in_array('administrator', (array) $user_data->roles) && !in_array('editor', (array) $user_data->roles)) : ?> | |
<h1 class="text-danger"> |
This file contains hidden or 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
$('[name="student-profile-form"]').submit(function(event) { | |
event.preventDefault(); | |
let formMethod = $(this).attr('method'); | |
let url = $(this).attr('action'); | |
let fields = []; | |
for (let i = 0; i < event.target.length; i++) { | |
fields[event.target[i].name] = event.target[i].value; | |
} |
NewerOlder