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
@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 && \
#!/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 / PasswordHash.php
Created August 6, 2018 06:09
Wordpress user password check on other system
<?php
/**
* Portable PHP password hashing framework.
* @package phpass
* @since 2.5.0
* @version 0.3 / WordPress
* @link http://www.openwall.com/phpass/
*/
#
@amitavroy
amitavroy / LEMP Stack
Last active October 20, 2023 00:55
Setup for a new linux server with Nginx PHP and MySQL
# Basics
sudo apt-get update
sudo apt-get install -y git tmux vim curl wget zip unzip htop
# Nginx
sudo apt-get install -y nginx
# PHP
sudo add-apt-repository ppa:nginx/stable
sudo add-apt-repository -y ppa:ondrej/php
# 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 / .gitlab-ci.yml
Last active January 25, 2019 23:47
Continuous Integration with Gitlab
stages:
- test
# Variables: these have to match
# the .env.example credentials in your Laravel app
# use the default homestead/secret combination, since
# that database gets created in the edbizarro/gitlab-ci-pipeline-php:7.1
# docker image.
variables:
MYSQL_ROOT_PASSWORD: root
@amitavroy
amitavroy / gist:6507518
Created September 10, 2013 10:20
Calculate Page load time
<script>
var t0 = window.performance.now();
</script>
<script>
var t1 = window.performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.")
</script>
@amitavroy
amitavroy / html_default
Last active December 18, 2015 22:59
This is my default html file as a starting point
<!doctype html>
<html lang="en" ng-app="anim">
<head>
<meta charset="UTF-8">
<title>Test page</title>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.min.js"></script>
<script>
var anim = angular.module('anim', []);
anim.controller('MainCtrl', ['$scope', function ($scope) {
@amitavroy
amitavroy / gist:5748261
Created June 10, 2013 12:04
Adding odd even class
<div class="example-class<?php echo ($xyz++%2); ?>">
@amitavroy
amitavroy / gist:5748254
Created June 10, 2013 12:03
Get all tweets of a specific hashtag
function getTweets($hash_tag) {
$url = 'http://search.twitter.com/search.atom?q='.urlencode($hash_tag) ;
echo "<p>Connecting to <strong>$url</strong> ...</p>";
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$xml = curl_exec ($ch);
curl_close ($ch);
//If you want to see the response from Twitter, uncomment this next part out: