Skip to content

Instantly share code, notes, and snippets.

View grzegorz-rozycki's full-sized avatar

Grzegorz Różycki grzegorz-rozycki

View GitHub Profile
@grzegorz-rozycki
grzegorz-rozycki / Dockerfile
Created May 15, 2023 06:31
Dockerfile with local-php-security-checker
FROM alpine as builder
RUN apk update && apk upgrade && apk add --no-cache ca-certificates;\
update-ca-certificates
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY ./local-php-security-checker /usr/local/bin/local-php-security-checker
WORKDIR "/app"
@grzegorz-rozycki
grzegorz-rozycki / wp-pot.sh
Created April 14, 2018 08:08
Collects translations from wordpress plugin / theme
#!/bin/bash
# NOTICE it only collects translations made by __() function
find ./ -iname '*.php' | xargs xgettext --keyword=__ --language=PHP --add-comments --sort-output -o languages/gr-sms.pot
#!/bin/bash
# A wrapper for the box command.
# Disables the phar.readonly PHP option before running the build command.
#
if [ -z "${@}" ]
then
CMD=build
else
CMD="${@}"
<?php
const MAX_REDIRECTS = 5;
const MAX_WAIT = 30; // don't wait longer than N seconds.
const USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36';
function curl_get_fileinfo($url): array
{
#!/usr/bin/env php
<?php
define('URL1', 'http://php.net/manual/en/ref.stream.php');
define('URL2', 'http://php.net/manual/en/function.stream-filter-append.php');
function stream_make_notification_handler(string $stream_id) {
return function ($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) use ($stream_id) {
echo "STREAM: {$stream_id}\t";
switch ($notification_code) {
@grzegorz-rozycki
grzegorz-rozycki / Docker cheat-sheet
Last active August 2, 2017 06:08
Usefull docker commands
#!/bin/bash
#
# Remove all containers
docker rm $(docker ps -aq)
# Remove stopped containers
docker rm $(docker ps -aqf status=exited)
# Remove untagged images
docker rmi $(docker images | awk '{ if ("<none>" == $1) print $3 }')
@grzegorz-rozycki
grzegorz-rozycki / steam_openid.php
Created May 15, 2017 05:55
Example of using Steam OpenID service in PHP.
<?php
/**
* Using Steam Id provider example.
*
* Requires: iignatov/lightopenid @{link https://github.com/iignatov/LightOpenID}
*/
ini_set('log_errors', 0);
ini_set('display_errors', 1);
ini_set('error_reporting', -1);
@grzegorz-rozycki
grzegorz-rozycki / PHP-Array.php.groovy
Last active April 17, 2024 08:06
A PhpStorm Data Extractor Script for exporting query results into a PHP array.
/*
* Extracts query results as PHP array.
* Tested against PhpStorm 2017.1.3
* Put the file under following path:
* ${HOME}/.PhpStorm2017.1/config/extensions/com.intellij.database/data/extractors
*/
SEPARATOR = ","
QUOTE = "\""
NEWLINE = System.getProperty("line.separator")