Skip to content

Instantly share code, notes, and snippets.

View fokosun's full-sized avatar
:octocat:
I may be slow to respond.

fokosun fokosun

:octocat:
I may be slow to respond.
  • Individual contributor, Founder/Owner CookbooksHQ
  • Toronto, Canada
  • 18:05 (UTC -05:00)
  • LinkedIn in/florenceokosun
View GitHub Profile
<?php
// This solution does not care for $n <= 1
function displayCheckerBoard($n): string {
$gridStartWithX = 'XY';
$gridStartWithY = 'YX';
if ($n === 2) {
return $gridStartWithX . PHP_EOL . $gridStartWithY . PHP_EOL;
}
@fokosun
fokosun / HealthCheckController.php
Created June 7, 2024 15:16
Full Code for HealthCheckController and HealthChecksDto
<?php
namespace App\Http\Controllers;
use App\Dtos\HealthChecksDto;
use Illuminate\Http\JsonResponse;
use Spatie\CpuLoadHealthCheck\CpuLoadCheck;
use Spatie\Health\Checks\Checks\UsedDiskSpaceCheck;
use Spatie\Health\Checks\Result;
use Spatie\Health\Health;
package main
import "fmt"
func main() {
values := []int{10, 5, 23, 54, 99}
minimum, maximum := values[0], values[0]
for _, value := range values[1:] {
if value > maximum {
<?php
$nums = [10, 5, 253, 54, 4];
$max = $nums[0];
$min = $nums[0];
$count = count($nums) - 1;
foreach(range(0, $count) as $i) {
if ($nums[$i] > $max) {
$max = $nums[$i];
@fokosun
fokosun / fizzbuzz.go
Created September 11, 2023 14:53
coding exercise
package main
import "fmt"
func main() {
fmt.Println("fizz buzz game for developers!")
for n := 1; n <= 20; n++ {
if n%15 == 0 {
@fokosun
fokosun / e2e-tests.yml
Created July 28, 2023 03:06 — forked from stfsy/e2e-tests.yml
Simple opinionated GitHub Actions workflow for end-to-end testing of Vue.js with TailwindCSS
name: e2e-tests
on: push
jobs:
build:
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
@fokosun
fokosun / index.js
Created January 11, 2023 19:45 — forked from ismailbaskin/index.js
GCP Pub/Sub to Slack message Cloud Function
const https = require('https');
const url = require('url');
const slackWebhookURL = 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'; // CHANGE ME PLZ!
exports.gceAudit = (event, callback) => {
const msg = JSON.parse(Buffer.from(event.data.data, 'base64').toString());
const slackRequest = https.request({
hostname: url.parse(slackWebhookURL).hostname,
method: 'POST',
@fokosun
fokosun / ThrottleRequests.php
Created December 10, 2020 20:38 — forked from developerdino/ThrottleRequests.php
Lumen Middleware for rate limiting - based on Laravel's implementation.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
use Illuminate\Cache\RateLimiter;
class ThrottleRequests
{
@fokosun
fokosun / sum_closest_to_target
Created July 27, 2020 17:30
Write a function that returns a pair of numbers from the 2 arrays whose sum is the closest to the target
<!-- Given: two integer arrsya and a target which is just a number.
Write a function that returns a pair of numbers from the 2 arrays whose sum is the closest to the target
e.g ([-1, 3, 8, 2, 9, 5], [4, 1, 2, 10, 5, 20], 24))
should return [[3, 20], [5, 20]] -->
@fokosun
fokosun / watermelon-challenge.php
Last active August 26, 2019 16:53
watermelon challenge
<?php
/*
* ROOM FOR IMPROVEMENT
* both halves have to be divisible by 2
*/
function watermelon($n) {
$ans = array();
if(is_integer($n)) {
$parts = range(1, ($n - 1));
foreach($parts as $part) {