Skip to content

Instantly share code, notes, and snippets.

View flangofas's full-sized avatar
🎯
Focusing

Antonis Flangofas flangofas

🎯
Focusing
View GitHub Profile
@flangofas
flangofas / health-check-with-throttler.php
Created December 2, 2020 08:44
Health check monitor on URL, it times out when throttle time is being expired. [VANILLA PHP]
<?php
const HEALTH_CHECK_INTERVAL_IN_SECONDS = '15';
const HEALTH_CHECK_THROTTLE = '10 minutes';
if (!isset($argv[1])) {
throw new InvalidArgumentException('Please provide one argument in JSON format');
}
$data = json_decode($argv[1]);
@flangofas
flangofas / parseUrlParams.js
Created November 2, 2020 15:29
Parses current URL and uses the query parameters to replace them on an existing URL
/**
* Parses current URL and uses the query parameters to
* replace them on an existing URL of a CTA in the document.
*
* For example,
* Current URL is: http://localhost:8000/?foobar=fromQuery#
* <a
* href="#"
* data-url="http://foobar.com/?foobar=foobarValue&regulator=regulatorValue"
* onclick="parseUrlAndInjectToCtaUrl(event)">Register here</a>
@flangofas
flangofas / backup.sh
Created March 22, 2020 17:30
Database backup -- Bash script ready to be used in crontab
#!/bin/bash
################################################################
##
## MySQL Database Backup Script
## Written By: Rahul Kumar
## Updated by: Antonis Flangofas
## URL: https://tecadmin.net/bash-script-mysql-database-backup/
## Last Update: Nov 28, 2019
##
@flangofas
flangofas / sp.sql
Last active March 19, 2020 13:49
Store procedures for deleting dummies users
# Change delimiter // so SP can be created
DELIMITER //
CREATE PROCEDURE selectXamplifierUsers()
BEGIN
select id from users where is_system_user = 0 and email like "%xamplifier%";
END
//
CREATE PROCEDURE deleteXamplifierUsers()
BEGIN
@flangofas
flangofas / fizzBuzz.php
Created January 24, 2020 14:15
Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.You can use JavaScript or PHP as those are the main languages we're using in SOCi. Use console.log() (in JavaScrip…
<?php
declare(strict_types=1);
function sayFizzBuzz(int $times = 0)
{
$iterationPrint = '';
for ($i = 0; $i <= $times; $i++) {
$iterationPrint = $i;
@flangofas
flangofas / reverse_binary.js
Created October 11, 2019 09:05
Write a function for reversing numbers in binary. For instance, the binary representation of 13 is 1101, and reversing it gives 1011, which corresponds to number 11
//Reverse Binary
//Useful link: https://aticleworld.com/5-way-to-reverse-bits-of-an-integer/
let decimal = process.argv[2]
if (typeof decimal === "undefined") {
throw new Error('Please provide a decimal number');
}
console.log(reverseBits(new Number(decimal)))
@flangofas
flangofas / change_directory.php
Created October 11, 2019 09:03
Write a function that provides change directory (cd) function for an abstract file system.
<?php
/**
* Write a function that provides change directory (cd) function for an abstract file system.
* Notes:
* root path is '/'.
* path separator is '/'.
* parent directory is addressable as '..'.
* directory names consist only of English alphabet letters (A-Z and a-z).
* the function will not be passed any invalid paths.
* do not use built-in path-related functions.
@flangofas
flangofas / commonLongestSubSequence.php
Last active January 18, 2019 12:56
Interview programming question Get the
<?php
/*
* Intreview question
*
* Build a function that returns common and longest sub-sequence of
* the two strings.
*
* For example,
* AAAA,AA outputs: AA
@flangofas
flangofas / assignment.js
Created January 16, 2018 21:23
JavaScript/DOM university assignment
// Add courses to the list (disallow adding same item twice)
// Remove courses from the list
// Limit courses by category
// Each course takes 5 credits, the list MUST have 6 courses
// Find desire course's category and suggest it on submit
// Course(or module) belongs to a Program
// Algebra belongs to math
// Linear belongs to math
@flangofas
flangofas / composer.json
Last active December 28, 2016 09:34
Creating JSON with million records
{
"name": "aflangofas/json",
"require": {
"fzaninotto/faker": "^1.6"
},
"authors": [
{
"name": "Antonis Flangofas",
"email": "antonisflags@gmail.com"
}