Skip to content

Instantly share code, notes, and snippets.

@ankurk91
ankurk91 / laravel_horizon.md
Last active May 31, 2024 01:57
Laravel Horizon, redis-server, supervisord on Ubuntu server

Laravel Horizon, redis-server, supervisord on Ubuntu 20/22 server

Laravel 8+, Horizon 5.x, Redis 6+

Parepare application

  • Install and configure Laravel Horizon as instructed in docs
  • Make sure you can access the Horizon dashboard like - http://yourapp.com/horizon
  • For now; it should show status as inactive on horizon dashbaord

Install redis-server

@val-bubbleflat
val-bubbleflat / install.bash
Last active April 15, 2020 13:03
Install V8Js on Laravel Forge
sudo add-apt-repository ppa:pinepain/libv8-5.2
sudo apt-get update
sudo apt-get install libv8-5.2
sudo pecl install v8js
sudo su
echo "extension=v8js.so" >> /etc/php/7.1/fpm/php.ini
echo "extension=v8js.so" >> /etc/php/7.1/cli/php.ini
exit
sudo service nginx restart && sudo service php7.1-fpm restart
@iben12
iben12 / 1_Laravel_state-machine.md
Last active August 12, 2023 08:36
Laravel: State-machine on Eloquent Model

Implementing State Machine On Eloquent Model*

* Update (12.09.2017): I have improved the trait so that it can be used with objects other than Eloquent Models.

Some days ago I came across a task where I needed to implement managable state for an Eloquent model. This is a common task, actually there is a mathematical model called "Finite-state Machine". The concept is that the state machine (SM) "can be in exactly one of the finite number of states at any given time". Also changing from one state to another (called transition) depends on fulfilling the conditions defined by its configuration.

Practically this means you define each state that the SM can be in and the possible transitions. To define a transition you set the states on which the transition can be applied (initial conditions) and the only state in which the SM should be after the transition.

That's the theory, let's get to the work.

@danilostrazzullo
danilostrazzullo / import-dump.sh
Created May 4, 2016 14:02
Import a large sql dump file to a MySQL database from command line
#!/bin/sh
# Import a large sql dump file to a MySQL database from command line
# https://cmanios.wordpress.com/2013/03/19/import-a-large-sql-dump-file-to-a-mysql-database-from-command-line/
# store start date to a variable
imeron=`date`
echo "Import starting..."
dumpfile="/path/to/dumpfile.sql"
@junkystu
junkystu / laravel-forge-deployment-script.sh
Last active May 23, 2021 05:18
Script for quicker deployment with Laravel and Forge
# The idea of this deployment script is to create a deploy copy of your website and handle
# Git and Composer updates in there. Aferwards, it just renames that deploy copy to become the
# live website. We then run the database migrations and take the application out of maintenance mode.
# Obviously, you will have to replace all instances of {{ websiteName }} with the name of your website and
# {{ branchName }} with the name of the branch you would like to pull changes from. This is usually the master branch.
# Start by checking for for old deployment folder and remove it if we have one.
if [ -d "/home/forge/{{ websiteName }}-deploy" ]; then
rm -Rf /home/forge/{{ websiteName }}-deploy
@paulirish
paulirish / what-forces-layout.md
Last active June 18, 2024 12:00
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@alexpchin
alexpchin / restful_routes.md
Last active June 16, 2024 04:26
7 Restful Routes
URL HTTP Verb Action
/photos/ GET index
/photos/new GET new
/photos POST create
/photos/:id GET show
/photos/:id/edit GET edit
/photos/:id PATCH/PUT update
/photos/:id DELETE destroy
@mitchwongho
mitchwongho / Docker
Last active November 29, 2023 06:36
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
@mythmon
mythmon / sumo_db_import.sh
Created August 9, 2013 17:23
This is the script I use to set import a large database dump. It goes faster than simply piping into mysql.
#!/bin/bash
SCHEMA="support_mozilla_com.2013.07.17.schema.sql"
DATA="support_mozilla_com.2013.07.17.data.sql"
SIZE="$(du $DATA | awk '{ print $1 }')K"
DBNAME="kitsune"
{
echo "Dropping/creating database ${DBNAME}" >&2
echo "DROP DATABASE IF EXISTS ${DBNAME};"
@bsodmike
bsodmike / restore_dump.sh
Created July 26, 2013 15:59
A shell script to restore a large MySQL dump using root login.
#!/bin/bash
# A shell script to restore a large SQL dump using root login.
# Usage: ./restore_dump.sh dump.sql app_devdb
#
# Author: Michael de Silva (michael@mwdesilva.com / http://github.com/bsodmike)
(( $# != 2 )) && { echo "Usage: $0 dump.sql database_name"; exit 1; }
[ ! -f $1 ] && { echo "$1 not found1"; exit 1; }
RESULT=`mysql -u root -p --skip-column-names -e "SHOW DATABASES LIKE '$2'"`