Skip to content

Instantly share code, notes, and snippets.

View pekhota's full-sized avatar

Oleksandr Piekhota pekhota

  • Teaching Strategies, LLC
  • Edinburgh
View GitHub Profile
@pekhota
pekhota / GroupOfExceptions.php
Created December 26, 2017 17:46
Быстрая telegram интеграция
<?php
namespace App\Exceptions;
use Throwable;
class GroupOfExceptions extends \RuntimeException
{
@pekhota
pekhota / prod-user-check.php
Last active December 20, 2017 19:43
Проверяем пользователя на prod'e. Таким образом наши log'и не будут с root или ubuntu правами
app/Providers/AppServiceProvider.php:22
if ($this->app->runningInConsole())
{
if ($this->app->environment('production')) {
$allowedUsers = ['www-data'];
// https://stackoverflow.com/questions/28548743/php-get-current-user-vs-execwhoami
if(!in_array(exec('whoami'), $allowedUsers)) {
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
@pekhota
pekhota / a.md
Created April 5, 2017 09:39 — forked from danharper/a.md
Laravel Queue Supervisor

Install Supervisor with sudo apt-get install supervisor. Ensure it's started with sudo service supervisor restart.

In /etc/supervisord/conf.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

This file points at /usr/local/bin/run_queue.sh, so create that file there. Give this execute permissions, too: chmod +x run_queue.sh.

Now update Supervisor with: sudo supervisorctl reread. And start using those changes with: sudo supervisorctl update.

#!/bin/bash
sudo -u www-data "$@"
/* YourDuino.com Example Software Sketch
16 character 2 line I2C Display
Backpack Interface labelled "A0 A1 A2" at lower right.
..and
Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
MOST use address 0x27, a FEW use 0x3F
terry@yourduino.com */
/*-----( Import needed libraries )-----*/
#include <Wire.h> // Comes with Arduino IDE
<?php
namespace App\Http\Controllers\Traits;
use App\Exceptions\NotSupportedMethodException;
use Illuminate\Http\Request;
use App\Http\Requests;
trait ResourceTemplate
@pekhota
pekhota / after.sh
Created February 3, 2016 11:20 — forked from cluppi/after.sh
Turning SSL on for Homestead
#!/bin/sh
# Config for SSL.
echo "--- Making SSL Directory ---"
mkdir /etc/nginx/ssl
echo "--- Copying $i SSL crt and key ---"
openssl req -nodes -new -x509 -keyout /etc/nginx/ssl/server.key -out /etc/nginx/ssl/server.crt -subj "/C=US/ST=NY/L=NYC/O=Dis/CN=www.example.com"
echo "--- Turning SSL on in nginx.conf. ---"
@pekhota
pekhota / .gitconfig
Created December 16, 2015 08:57 — forked from robmiller/.gitconfig
Some useful Git aliases that I use every day
#
# Working with branches
#
# Get the current branch name (not so useful in itself, but used in
# other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
@pekhota
pekhota / massInsertOrUpdate.php
Created October 5, 2015 21:51 — forked from RuGa/massInsertOrUpdate.php
Mass (bulk) insert or update on duplicate for Laravel 4/5
/**
* Mass (bulk) insert or update on duplicate for Laravel 4/5
*
* insertOrUpdate([
* ['id'=>1,'value'=>10],
* ['id'=>2,'value'=>60]
* ]);
*
*
* @param array $rows
@pekhota
pekhota / squid.conf
Last active August 29, 2015 14:28 — forked from hpcorona/squid.conf
simple squid3 configuration to allow all to connect to all
#Recommended minimum configuration:
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl localnet src 0.0.0.0/8 192.168.100.0/24 192.168.101.0/24
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher