Skip to content

Instantly share code, notes, and snippets.

View osbre's full-sized avatar
🇺🇦
#StandWithUkraine

Ostap Brehin osbre

🇺🇦
#StandWithUkraine
View GitHub Profile
@osbre
osbre / convert.sh
Created August 7, 2019 18:18
Convert all mkv-files in folder, to 3gp
for i in *.mkv;
do name=`echo "$i"`
echo "$name"
ffmpeg -y -i "$i" \
-r 20 -s 352x288 -vb 400k \
-acodec aac -strict experimental -ac 1 -ar 8000 -ab 24k \
"phone/${name}.3gp"
done
<?php
namespace App;
use Modules\Forum\Entities\ReplyWithThread;
use Spatie\Activitylog\Models\Activity as BaseActivity;
class Activity extends BaseActivity
{
private $morphRelationModels = [
@osbre
osbre / MorphMap.php
Created August 22, 2019 23:08
Laravel morph map validation rule.
<?php
namespace App\Validation\Rules;
use Illuminate\Contracts\Validation\ImplicitRule;
use Illuminate\Database\Eloquent\Relations\Relation;
class MorphMap implements ImplicitRule
{
public function passes($attribute, $value)
@osbre
osbre / HasUserMentions.php
Last active September 4, 2019 17:43
Laravel user mentions
<?php
namespace Modules\User\Traits;
trait HasUserMentions
{
protected static function bootHasUserMentions()
{
static::retrieved(function ($model) {
foreach (static::$mentionedAttributes as $attribute){
@osbre
osbre / AppServiceProvider.php
Created September 7, 2019 16:08
Laravel notifications - how to use custom type
<?php
namespace App\Providers;
use App\Notifications\DatabaseChannel as CustomDatabaseChannel;
use Illuminate\Notifications\Channels\DatabaseChannel;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@osbre
osbre / Dockerfile
Last active January 13, 2020 18:31
[not working, todo - remove gist] sudo docker run -d -p 8080:8000 -e VIRTUAL_HOST=asdf.ost.pp.ua foo
FROM nginx:1.17.7
COPY ./nginx.conf /etc/nginx/nginx.conf
RUN apt update
RUN apt install nodejs npm -y
# https://github.com/nodejs/help/issues/1877
RUN npm install npm@latest -g
@osbre
osbre / nginx.conf
Created January 13, 2020 18:29
NJS example - random access #nginx #nginx-scripting
pid /var/run/nginx.pid;
load_module modules/ngx_stream_js_module.so;
events {
worker_connections 1024;
}
error_log /var/log/nginx/error.log;
error_log /var/log/nginx/error.log notice;
@osbre
osbre / docker-compose.yml
Last active February 16, 2020 15:20
Legacy Docker PHP-FPM 5.3 + Mysql 5.7
version: '3.1'
services:
php:
image: devilbox/php-fpm-5.3
restart: always
ports:
- 9000:9000
volumes:
- ./htdocs:/var/www/default/htdocs
@osbre
osbre / description.txt
Created February 3, 2020 20:43
CodeBattle: "Given a sentence, sort characters in each word alphabetically."
Examples:
"Eey fo Entw, adn Eot fo Fgor, Loow fo Abt, adn Egnotu fo Dgo." == solution("Eye of Newt, and Toe of Frog, Wool of Bat, and Tongue of Dog.")
<?php //only for Github syntax highlight
Layout::wrapper('wrappers.left-right', [
'left' => Layout::rows([
Button::make(__('Change percent'))
->modal('change-percent')
->class('btn btn-block btn-info'),
]),
'right' => Layout::rows([
ModalToggle::make(__('Change amount'))
->modal('setPercent')