Skip to content

Instantly share code, notes, and snippets.

View atakde's full-sized avatar
🎯
Focusing

Atakan Demircioğlu atakde

🎯
Focusing
View GitHub Profile
{
"Nice output for debugging": {
"prefix": "dbg",
"body": [
"echo \"<pre>\";",
"print_r($1);",
"echo \"</pre>\";",
"die();"
],
"description": "Nice output of Array with print_r"
<?php
$color = "red";
switch ($color) {
case "red":
echo "The color is red.";
break;
case "blue":
echo "The color is blue.";
@atakde
atakde / remove_empty_from_array.php
Created March 17, 2023 19:00
Remove empty values PHP
<?php
$my_array = array('apple', '', null, false, 'banana', 0, 'orange', 'grape');
// Remove empty values from the array
$my_array = array_filter($my_array);
print_r($my_array);
// Output: Array ( [0] => apple [4] => banana [6] => orange [7] => grape )
<?php
$users = [
'Asd' => '123',
'Qwe' => '456',
'Zxc' => '789',
];
$users = array_change_key_case($users, CASE_LOWER);
<?php
$users = [
[
'id' => 123,
'username' => 'admin',
'name' => 'John Doe',
'avatar' => 'https://example.com/avatar.jpg',
],
[
chrome.webNavigation.onHistoryStateUpdated.addListener(function (details) {
// Check if the URL matches medium.com and if the page is fully loaded
if (details.url.includes('medium.com/@') && details.frameId === 0) {
// Execute the content script in the new page
console.log('Injecting content script');
// execute main.js
chrome.scripting.executeScript({
target: { tabId: details.tabId },
files: ['main.js']
console.log('Hello from main.js!');
// IIFE
(async () => {
// Wait for the target element to appear in the DOM
await new Promise(resolve => {
const observer = new MutationObserver(() => {
if (document.querySelector('.pw-post-title')) {
resolve();
observer.disconnect();
{
"name": "Mark as Read Medium Posts",
"version": "1.0",
"manifest_version": 3,
"permissions": [
"webNavigation",
"scripting",
"tabs"
],
"content_scripts": [
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Services\UserService;
use App\Repositories\UserRepository;
class UserController extends Controller
{
<?php
class UserService
{
private $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}