Skip to content

Instantly share code, notes, and snippets.

View alexrusin's full-sized avatar

Alex alexrusin

View GitHub Profile
@alexrusin
alexrusin / CurlConnection.php
Created June 25, 2019 15:36
Curl Connection
function makeCURLconnection($postURL, $curlTYPE, $dataToPost = null, $headerPOST = null)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $postURL);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, '0');
@alexrusin
alexrusin / RetryDecorator.php
Created June 21, 2019 22:40
Connector Retry Decorator
<?php
namespace SunriseIntegration\PeruConnector\Connector;
class RetryDecorator
{
protected $connector;
protected $method;
protected $arguments = [];
protected $soapFaultRetries = 0;
@alexrusin
alexrusin / sluggable.php
Created May 24, 2019 23:09
Bootable Sluggable Trait
// https://dotdev.co/creating-unique-title-slugs-with-laravel/
// https://andy-carter.com/blog/using-laravel-s-eloquent-traits
<?php
namespace App\Traits;
use Illuminate\Support\Str;
trait Sluggable
<?php
if (!isset($_SERVER['REQUEST_URI']) || strtok($_SERVER["REQUEST_URI"],'?') !== '/greetings') {
http_response_code(404);
die();
}
$name = $_GET['name'] ?? 'Anonymous';
$greeting = $_GET['greeting'] ?? 'How do you do';
@alexrusin
alexrusin / gist:6c75898808f1fa9c5845f0db3c21bac3
Last active April 19, 2019 18:09
Notes for Scheduling Tasks
// Console/Kernel.php
protected $commands = [
Commands\MasterCommand::class,
Commands\CommandOne::class,
Commands\CommandTwo::class
];
/**
@alexrusin
alexrusin / gist:0c666869930a7ad83ad1d5b971df8aa8
Created December 31, 2018 18:25
supervisord.conf file for websockets
[supervisord]
nodaemon=true
[program:websockets]
command=/usr/bin/php /var/www/html/artisan websockets:serve
numprocs=1
autostart=true
autorestart=true
user=www-data
@alexrusin
alexrusin / gist:20eed13c6257d97666210d46d6cd1c3d
Created December 31, 2018 18:15
Dockerfile for websockets
FROM ubuntu:16.04
MAINTAINER Alex Rusin
RUN apt-get update \
&& apt-get install -y locales \
&& locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
@alexrusin
alexrusin / gist:108b88ab47d5d8b7c0016ae699e7ee82
Created December 31, 2018 18:03
env file for websockets
APP_NAME=Websockets
APP_ENV=production
APP_KEY=base64:87fP6T6NYDlGthaKZoPUs6gcBHt+LoluOvs88TewC9BC
APP_DEBUG=true
APP_URL=
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=db_ip_address
@alexrusin
alexrusin / laravel_vue_test_setup
Created November 24, 2018 16:31
Laravel Vue testing set up
// package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
@alexrusin
alexrusin / regex_practice.php
Last active October 27, 2018 23:59
RegEx practice
<?php
$string = "This website is stupid. Your speaking style is idiotic. Your knowledge is crap.This is so stupid. You are an idiot. You are an IDIOT!";
echo preg_replace('/stupid|idiot(?:ic)?|crap/i', 'amazing', $string) . PHP_EOL . PHP_EOL;
$website1 = 'www.laracasts.com';
$website2 = 'alexrusin.com';
echo preg_replace('/www\.([^\.]+)/i', '$1', $website1) . PHP_EOL;
echo preg_replace('/www\.([^\.]+)/i', '$1', $website2) . PHP_EOL . PHP_EOL;