Skip to content

Instantly share code, notes, and snippets.

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

Amitav Roy amitavroy

🏠
Working from home
View GitHub Profile
#!/bin/bash
# declare an array called array and define 3 vales
databases=( drupal fresh lasalle_wp_fts )
username=root
password=password
filepath=/home/amitavroy/code/backup
for i in "${databases[@]}"
do
filename=${i}_$(date +"%m%d%Y-%k%M")
mysqldump -u${username} -p${password} ${i} > ${filepath}/${filename}.sql
@amitavroy
amitavroy / ga_event.js
Created March 27, 2013 14:18
This code shows how to add an event to a click or other user event.
$('.tab').click(function() {
$(this).show();
var eventCategory = jQuery(this).attr('data-category');
var eventAction = jQuery(this).attr('data-action');
var eventLabel = window.document.title;
_gaq.push(['_trackEvent', eventCategory, eventAction, eventLabel]);
});
# Installing Apache, PHP and MySQL
sudo apt install -y apache2
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
sudo apt install -y zip unzip git curl
sudo apt-get install -y php7.3-fpm php7.3-cli php7.3-gd php7.3-mysql \
php7.3-mbstring php7.3-xml php7.3-curl \
php7.3-bcmath php7.3-sqlite3 php7.3-zip
@amitavroy
amitavroy / TimeEntrySeeder.php
Created August 15, 2020 06:09
Get a lot of Time Entries
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\TimeEntry;
use Faker\Generator as Faker;
$factory->define(TimeEntry::class, function (Faker $faker) {
$username = [
'Amitav',
@amitavroy
amitavroy / Dockerfile
Created November 23, 2021 01:54
Composer PHP 7.4 Docker file
FROM phpdockerio/php74-cli as php
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /app
CMD ["composer"]
@amitavroy
amitavroy / docker_on_ubuntu.sh
Last active December 4, 2021 08:54
Installing Docker on a new Ubuntu Server
sudo apt update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@amitavroy
amitavroy / Fileupload.vue
Created November 19, 2018 16:35
Vue.js component for a File field which makes an Ajax request to server
<template>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card card-default">
<div class="card-header">Example Component</div>
<div class="card-body upload-file-wrapper">
<input
type="file"
@amitavroy
amitavroy / Dockerfile
Created November 18, 2018 04:10
Docker setup with Laravel
FROM php:7.2.10-apache-stretch
RUN apt-get update -yqq && \
apt-get install -y apt-utils zip unzip && \
apt-get install -y nano && \
apt-get install -y libzip-dev libpq-dev && \
a2enmod rewrite && \
docker-php-ext-install pdo_pgsql && \
docker-php-ext-install pgsql && \
docker-php-ext-configure zip --with-libzip && \
@amitavroy
amitavroy / button.tsx
Last active May 10, 2022 04:14
Some useful React codes
// A sample button component with proper Typescript definitions
// and it also spreads all props coming from the parent component
import { HTMLAttributes, ReactNode } from "react";
interface Props extends HTMLAttributes<HTMLButtonElement> {
children: ReactNode;
variant: "primary" | "secondary";
}
@amitavroy
amitavroy / .php-cs-fixer.php
Created December 5, 2021 08:34
php cs fixer rules for Laravel
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => ['=>' => null],