Skip to content

Instantly share code, notes, and snippets.

View yasaryousuf's full-sized avatar

Yasar Yousuf yasaryousuf

  • Dhaka, Bangladesh.
View GitHub Profile
<?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
<?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];
}
<?php
$hay = 'aabdf';
$nee = 'aaf';
$lenHay = strlen($hay);
$lenNee = strlen($nee);
$arrNee = str_split($nee);
for($i = $lenNee; $i <= $lenHay; $i++){
<?php
//Enter your code here, enjoy!
$array = [1, 2, 2, 2, 3];
$newArray = [];
$dupCount = 0;
foreach($array as $el) {
if(in_array($el, $newArray)) {
const isPrime = num => {
let sqrt = Math.sqrt(num);
for(let i = 2; i <= sqrt; i++) {
if(num % i === 0){
return false;
}
}
return true;
}
// 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
'use strict';
/**
* Detail Component
*/
class ContactDetail extends React.Component {
constructor(props) {
super(props);
this.state = props.selectedContact
}
<?php if (isset($_SESSION['message'])) : ?>
<div class="alert alert-<?= $_SESSION['type'] ?>">
<?= $_SESSION['message'] ?>
</div>
<?php endif; unset($_SESSION['message']); unset($_SESSION['type']); ?>
<?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">
$('[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;
}