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 | |
namespace Atakan\ElasticEx; | |
class MySearchEngine | |
{ | |
public function search($params) | |
{ | |
$elastic = Elastic::getInstance(); | |
$client = $elastic->getClient(); |
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 | |
namespace Atakan\ElasticEx; | |
class Elastic | |
{ | |
private static $instance = null; | |
private $client = null; | |
private function __construct() |
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
#!/bin/bash | |
# Define the process name to monitor | |
process_name="chrome" | |
# Check if the process is running | |
if pgrep -x "$process_name" >/dev/null; then | |
echo "Puppeteer script is running." | |
else | |
echo "Puppeteer script is not running. Starting it..." |
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
#!/usr/bin/env php | |
<?php | |
use PhpCliAppExample\ExampleCLI as PhpCliAppExampleExampleCLI; | |
require __DIR__.'/vendor/autoload.php'; | |
$app = new PhpCliAppExampleExampleCLI(new Symfony\Component\Console\Application()); | |
$app->run(); |
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 | |
namespace PhpCliAppExample\Commands; | |
use Symfony\Component\Console\Command\Command; | |
use Symfony\Component\Console\Helper\Table; | |
use Symfony\Component\Console\Input\InputArgument; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; |
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 | |
namespace PhpCliAppExample; | |
use PhpCliAppExample\Commands\ExampleCommand; | |
use Symfony\Component\Console\Application; | |
use Symfony\Component\Console\Command\Command; | |
class ExampleCLI | |
{ |
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 | |
class TestClass | |
{ | |
public function isUsernameStartsWithLetter($username) | |
{ | |
// if empty string trow exception | |
if (empty($username)) { | |
throw new Exception('Username is empty'); | |
} |
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 | |
function saveProfile($data) { | |
$errors = []; | |
if (!isset($data['email'])) { | |
$errors[] = 'Email address is required'; | |
} else { | |
if (!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) { | |
$errors[] = 'Email address is not valid'; |
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 | |
function update($contact, $data) { | |
if (valid($data)) { | |
$contact->update($data); | |
} | |
} | |
// How about like that? |
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 axios = require("axios"); | |
const xml2js = require("xml2js"); | |
const mediumFeedURL = "https://medium.com/feed/@"; | |
const { sendResponse } = require("./responseController"); | |
// find first image in the body of the article | |
const findImage = (body) => { | |
const imgRegex = /<img.*?src="(.*?)"/; | |
const imgSrc = body.match(imgRegex); | |
if (imgSrc) { |