Skip to content

Instantly share code, notes, and snippets.

View bosunolanrewaju's full-sized avatar
😅
Dancing in the Rain

'Bosun Olanrewaju bosunolanrewaju

😅
Dancing in the Rain
View GitHub Profile
@bosunolanrewaju
bosunolanrewaju / test.retry.php
Last active May 9, 2022 17:21 — forked from mudge/test.retry.php
A retry function for PHP.
<?php
require_once dirname(__FILE__) . '/../lib/simpletest/autorun.php';
// Retries $f (A function) with arguments ($args as array)
// 3 ($retries) times after 10 secs $delay
// Usage:
// retry( 'function_name', array('arg1', 'arg2'), 15, 5 );
// #=> Retries function_name 5 times with arg1 and $arg2 as arguments at interval of 15 secs
function retry($f, $args = null, $delay = 10, $retries = 3)
{
@bosunolanrewaju
bosunolanrewaju / caesar.rb
Created November 3, 2016 15:19 — forked from matugm/caesar.rb
Caesar cipher using Ruby
ALPHABET_SIZE = 26
def caesar_cipher(string)
shiftyArray = []
charLine = string.chars.map(&:ord)
shift = 1
ALPHABET_SIZE.times do |shift|
shiftyArray << charLine.map do |c|
((c + shift) < 123 ? (c + shift) : (c + shift) - 26).chr
<?php
global $post;
$author_id=$post->post_author;
?>
<?php
/* You can also use one of these instead:
- nickname
- user_nicename
- display_name
@flattened_array = [] #To store the flattened array
def flatten(array)
array.each do |value|
# If value is itself an array, call the function recursively
# Store each value found that is not array in the flattened array
value.instance_of? Array ? flatten value : @flattened_array << value
end
@flattened_array
end