Skip to content

Instantly share code, notes, and snippets.

@trbsi
trbsi / PushNotifications.php
Last active March 11, 2018 04:18 — forked from joashp/PushNotifications.php
Simple PHP script to send Android Push Notification, iOS Push Notification and Windows Phone 8 Push Notification
<?php
// Server file
class PushNotifications
{
// (Android)API access key from Google API's Console.
private static $API_ACCESS_KEY = 'AIzaSyDG3fYAXXXXX-XXXXXJyJXiO5JagAsYI';
// (iOS) Private key's passphrase.
private static $passphrase = 'joashp';
// (Windows Phone 8) The name of our push channel.

(this is you connecting to your remote server)

ssh username@xxx.xxx.xxx.xxx

(this gets you to the 'absolute root' of the server)

cd ../

(navigate to the directory one level above your website directory - e.g. your website directory being where you would upload your HTML files etc)

@trbsi
trbsi / User.php
Last active August 14, 2018 10:00
Entity Listener example
/**
* @ORM\EntityListeners({"Domena\UserBundle\Listener\UserListener"})
*/
class User extends AbstractUser implements UserSecurityInterface
{}
[ req ]
default_bits = 2048
default_keyfile = server-key.pem
distinguished_name = subject
req_extensions = req_ext
x509_extensions = x509_ext
string_mask = utf8only
[ subject ]
@echo off
set /p domain="Enter Domain: "
set OPENSSL_CONF=../conf/openssl.cnf
if not exist .\%domain% mkdir .\%domain%
..\bin\openssl req -config cert.conf -new -sha256 -newkey rsa:2048 -nodes -keyout %domain%\server.key -x509 -days 365 -out %domain%\server.crt
echo.
echo -----
@trbsi
trbsi / run.sh
Created October 23, 2020 17:05 — forked from nailton/run.sh
RUN composer install in hostgator with php 7.1
/opt/php71/bin/php /opt/cpanel/composer/bin/composer install
@trbsi
trbsi / pre-commit
Created February 17, 2021 11:28 — forked from fesor/pre-commit
php-cs-fixer pre-commit hook
#!/usr/bin/env bash
echo "php-cs-fixer pre commit hook start"
PHP_CS_FIXER="bin/php-cs-fixer"
PHP_CS_CONFIG=".php_cs"
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '*.php')
if [ -n "$CHANGED_FILES" ]; then
$PHP_CS_FIXER fix --config "$PHP_CS_CONFIG" $CHANGED_FILES;
git add $CHANGED_FILES;
@trbsi
trbsi / ExtractTranslationsCommand.php
Last active December 26, 2023 11:02
LARAVEL. Scripts goes through all .php and .blade.php files and looks for missing translation keys and adds it to the en.json file. If there are some non-used translations in en.json file they will be deleted.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RecursiveRegexIterator;
use RegexIterator;