Skip to content

Instantly share code, notes, and snippets.

View sagar290's full-sized avatar
🏠
Working from home

Sagar sagar290

🏠
Working from home
View GitHub Profile
@sagar290
sagar290 / golang-errors-stack-line.go
Created March 26, 2023 05:28 — forked from rms1000watt/golang-errors-stack-line.go
Golang Errors Stacktrace and Line Number
// https://godoc.org/github.com/pkg/errors#Frame.Format
package main
import (
"fmt"
"github.com/pkg/errors"
)
@sagar290
sagar290 / .php-cs-fixer.php
Created November 17, 2022 13:25 — forked from laravel-shift/.php-cs-fixer.php
PHP CS Fixer - Laravel Coding Style Ruleset
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
@sagar290
sagar290 / Dockerfile
Created February 18, 2022 14:48 — forked from Machy8/Dockerfile
PHP-FPM 7.1 with Unix Sockets + Nginx in Docker
FROM debian:stretch
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
wget \
zip \
git \
unzip && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean
git_current_branch () {
local ref
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]
then
[[ $ret == 128 ]] && return
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
@sagar290
sagar290 / wc_order_status_changes.php
Created July 3, 2021 16:37 — forked from abegit/wc_order_status_changes.php
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
@sagar290
sagar290 / Makefile
Created May 28, 2021 08:43 — forked from PhirePhly/Makefile
A crazy simple SMTP server, for educational purposes only.
default:
cc ccsmtp.c -o ccsmtpd -lpthread
@sagar290
sagar290 / alter-user.sql
Created April 15, 2021 22:00 — forked from backslash112/alter-user.sql
Blog: Start a Remote MySQL Server with Docker quickly
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<password>';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '<password>';
@sagar290
sagar290 / mamp-sql-dump-export.sh
Created February 25, 2021 18:25 — forked from oliveratgithub/mamp-sql-dump-export.sh
MAMP MySQL dump export using Terminal.app in macOS
$ cd /Applications/MAMP/Library/bin/
$ ./mysqldump --host=localhost -uroot -proot source_database > ~/Desktop/database_name-dump.sql
@sagar290
sagar290 / Dockerfile
Created April 20, 2020 09:20 — forked from iki/Dockerfile
Test volume mount in docker
FROM alpine
WORKDIR /data
COPY . .
CMD ls -l /data
@sagar290
sagar290 / run-command.php
Created January 24, 2020 17:36 — forked from codeZoner/run-command.php
Execute Shell Script using PHP (Git Pull Example)
<?php
// chdir to the correct directory before calling the script
//Ref: https://stackoverflow.com/questions/11052162/run-bash-command-from-php#answer-11052453
$old_path = getcwd();
chdir('/path/to/file');
//make sure to make the shell file executeable first before running the shell_exec function
$output = shell_exec('./shell-script.sh');
chdir($old_path);
echo $output;