Skip to content

Instantly share code, notes, and snippets.

View Shaked's full-sized avatar

Shaked Klein Orbach Shaked

View GitHub Profile
<?php
..
..
$cmd = 'docker build someimage';
$process = Process::fromShellCommandline($cmd);
$process->setTimeout(0);
$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
echo 'ERR > '.$buffer;
@Shaked
Shaked / gist:90af6960ddb940d76b4a4e1117a00552
Created January 30, 2019 11:31 — forked from tonyc/gist:1384523
Using strace and lsof

Using strace and lsof to debug blocked processes

You can use strace on a specific pid to figure out what a specific process is doing, e.g.:

strace -fp <pid>

You might see something like:

select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)

@Shaked
Shaked / Secure.php
Created October 15, 2018 17:43
PHP Security Question - Is This Secure?
<?php
$userRequest = $_GET['userRequest'] ?? null;
$path = 'file' . $userRequest;
if (file_exists($path)) {
require_once($path);
} else {
echo 'File does not exist';
}
<?php
class A {
/**
* @param $args
*/
public function methodIsCool($args) {
var_dump($args);
}
<?php
namespace App;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Psr\Log\LoggerInterface;
class ExceptionListener {
@Shaked
Shaked / IndexController.php
Last active August 3, 2018 05:34
Symfony error example
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
@Shaked
Shaked / content.js
Created May 5, 2018 03:39
Skip specific youtube videos by their names
console.log('SKIPYOUTUBE: before ready');
var skippedList = [
'שלמה ארצי'
];
function run() {
var videoName = $('#info-contents h1').text();
console.log('SKIPYOUTUBE: run started, videoName: ', videoName);
if (!videoName) {
setTimeout(run, 300);
@Shaked
Shaked / README.md
Last active April 15, 2018 20:47
WIP integration example

WIP integration example

Setup

  1. $ composer install
  2. Change $wipApiKey (see code)
  3. $ php command.php;
@Shaked
Shaked / php-ffmpeg.php
Created March 6, 2018 00:48
PHP-FFMPEG possible ExtractMultipleFramesFilter bug
<?php
require 'vendor/autoload.php';
use \FFMpeg\Filters\Video\ExtractMultipleFramesFilter;
/**
* @param $fromUrl
*/
function getIGOriginalVideoUrl($fromUrl) {
$html = file_get_contents($fromUrl);
@Shaked
Shaked / site-nginx.conf
Created March 6, 2018 00:23
Enable letsencrypt to access non HTTPS URL when redirecting to HTTPS #SSL
# certbot-auto -n --agree-tos --email='my@email.com' certonly -a webroot --webroot-path=/var/www/html -d domain.com
server {
listen 80;
server_name domain.com;
location ~ /.well-known {
allow all;
root /var/www/html;
}