Skip to content

Instantly share code, notes, and snippets.

View sourovroy's full-sized avatar

Sourov Roy sourovroy

View GitHub Profile
@sourovroy
sourovroy / .bascrc.md
Last active February 23, 2024 08:08
Show git branch name in ubuntu terminal

Show git branch name in ubuntu terminal

Add these lines in your ~/.bashrc file

# Show git branch name
force_color_prompt=yes
color_prompt=yes
parse_git_branch() {
 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
@sourovroy
sourovroy / languages.php
Last active November 25, 2023 14:58
PHP array to get the language by country locale.
<?php
return [
'bs' => 'Bosnian',
'ee_TG' => 'Ewe (Togo)',
'ms' => 'Malay',
'kam_KE' => 'Kamba (Kenya)',
'mt' => 'Maltese',
'ha' => 'Hausa',
'es_HN' => 'Spanish (Honduras)',
@sourovroy
sourovroy / CI.yml
Last active February 3, 2023 00:59
GitHub Actions for Laravel application
name: Continuous Integration
on:
push:
branches:
- master
- develop
- 'feature/**'
defaults:
@sourovroy
sourovroy / script.js
Created June 30, 2022 07:08
Update WooCommerce fragment cache
jQuery(document.body).trigger('wc_fragment_refresh');
@sourovroy
sourovroy / preview-email.php
Created July 13, 2021 04:42
Preview WooCommerce Email
<?php
/**
* Plugin Name: Preview Email
* Author: Sourov
*/
function sourov_preview_woo_emails() {
$mailer = WC()->mailer();
$email = $mailer->emails['WC_Email_Customer_Processing_Order'];
@sourovroy
sourovroy / hooks.json
Created May 7, 2020 11:59
Ubuntu webhook and Supervisor setup
[
{
"id": "laravel-deploy",
"execute-command": "/home/sourov/hooks/laravel-deploy.sh",
"command-working-directory": "/home/sourov/sites/github-actions",
"trigger-rule": {
"match": {
"type": "value",
"value": "development",
"parameter": {
@sourovroy
sourovroy / Dockerfile
Created June 27, 2019 11:13
Ubuntu Dockerfile for PHP and Node
# Download base image ubuntu 18.04
FROM ubuntu:18.04
# DEBIAN_FRONTEND
ARG DEBIAN_FRONTEND=noninteractive
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Update software repository and install cURL & Wget
@sourovroy
sourovroy / Dockerfile
Created June 27, 2019 11:11
Alpine Dockerfile for PHP, Node and Git
FROM alpine:3.10
# Install cURL, Zip, Vim
RUN apk update && apk add curl zip vim
# Install PHP
RUN apk add php7 php7-common php7-curl php7-json php7-zip php7-mbstring php7-openssl php7-phar php7-xml
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- \
@sourovroy
sourovroy / back-top-top.js
Last active March 29, 2018 05:41
Simple back to top
/* JavaScript */
jQuery(document).ready(function($){
// browser window scroll (in pixels) after which the "back to top" link is shown
var offset = 300,
//browser window scroll (in pixels) after which the "back to top" link opacity is reduced
offset_opacity = 1200,
//duration of the top scrolling animation (in ms)
scroll_top_duration = 700,
//grab the "back to top" link
$back_to_top = $('.cd-top');
@sourovroy
sourovroy / smooth_scroll.js
Last active March 4, 2018 08:35
Use this code for smoth scroll
// jQuery smooth scroll
$('li.smooth-scroll a').bind('click', function(event){
event.preventDefault();
var $anchor = $(this);
var headerH = '40';
$('html, body').stop().animate({
scrollTop : $($anchor.attr('href')).offset().top - headerH + "px"
}, 1200, 'linear');
});