Skip to content

Instantly share code, notes, and snippets.

View fmtarif's full-sized avatar

Faisal Muhammad fmtarif

View GitHub Profile
@fmtarif
fmtarif / change-php-version-cli.txt
Last active June 13, 2019 08:10
#cli dreamhost stuff
#https://help.dreamhost.com/hc/en-us/articles/214202148-How-do-I-change-the-PHP-version-my-shell-uses-
#for seeing installed php versions
ls -la /usr/local
#or any other installed PHP version
echo "export PATH=/usr/local/php71/bin:$PATH" >> ~/.bash_profile
#or through alias
echo "alias php='/usr/local/php71/bin/php'" >> ~/.bash_profile
@fmtarif
fmtarif / ssh-config
Created April 3, 2019 06:52 — forked from chales/ssh-config
#ssh #cli SSH Config - Sample file to show staff the common options to add to your '~/.ssh/config' file. This is just a text file and should have the same perms as the other files in ~/.ssh, usually 600 (read and write by user only).
#### Example SSH config file
# Host = a list of domains, IPs and personalized aliases that use this config
# entry. These alias names follow "Host" and are space delimited.
# e.g. Host 192.168.1.1 example.com example1 myalias1
# Hostname = the IP or real hostname
# e.g. Hostname 192.168.1.1
# User = the username
# e.g. User jdoe
# Port = if this is a non standard port, i.e. not 22
@fmtarif
fmtarif / dbdump.sh
Last active September 9, 2019 13:58
#bash #cli #wp DB backup script, parse DB credentials from wp-config.php or .env (ini format) files
#!/bin/bash
#change these variables as necessary for current deployment
CONFIG_FILE_PATH=/path/to/config_file
MYCONF_EXTRA_FILE=./.mysqlpwd
BACKUP_FILE_PATH=./dbdump-$(date '+%F_time_%I%M%p').sql
##for wp-config.php file format
DBHOST=`cat $CONFIG_FILE_PATH | grep DB_HOST | cut -d \' -f 4`
DBNAME=`cat $CONFIG_FILE_PATH | grep DB_NAME | cut -d \' -f 4`
@fmtarif
fmtarif / mysql_replication_autostart.sh
Created February 24, 2019 11:07 — forked from nicomak/mysql_replication_autostart.sh
This script automates the process of starting a Mysql Replication on 1 master node and N slave nodes. More details on how it works at http://blog.ditullio.fr/2016/04/30/initialize-mysql-master-slave-replication-script/
#!/bin/bash
#title : replication-start.sh
#description : This script automates the process of starting a Mysql Replication on 1 master node and N slave nodes.
#author : Nicolas Di Tullio
#date : 20160706
#version : 0.2
#usage : bash mysql_replication_autostart.sh
#bash_version : 4.3.11(1)-release
#=============================================================================
@fmtarif
fmtarif / bitbucket-webhook.php
Created February 14, 2019 14:25 — forked from maztch/bitbucket-webhook.php
A simple php script for deploy using bitbucket webhook
<?php
//edit with your data
$repo_dir = '~/repository.git';
$web_root_dir = '~/project';
$post_script = '~/project/scripts/post_deploy.sh';
$onbranch = 'master';
// A simple php script for deploy using bitbucket webhook
// Remember to use the correct user:group permisions and ssh keys for apache user!!
// Dirs used here must exists on server and have owner permisions to www-data
@fmtarif
fmtarif / webdev_online_resources.md
Created January 29, 2019 16:18 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
@fmtarif
fmtarif / time-elapsed.php
Created January 23, 2019 17:52
#php execution profiling, get elapsed time
<?php
function get_execution_time()
{
static $microtime_start = null;
if($microtime_start === null)
{
$microtime_start = microtime(true);
return 0.0;
}
@fmtarif
fmtarif / tracker.service.ts
Last active June 27, 2018 07:51
websocket realtime code from jhipster
import { Injectable } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { Observable, Observer, Subscription } from 'rxjs';
import { CSRFService } from '../auth/csrf.service';
import { WindowRef } from './window.service';
import { AuthServerProvider } from '../auth/auth-jwt.service';
import * as SockJS from 'sockjs-client';
import * as Stomp from 'webstomp-client';
@fmtarif
fmtarif / angular-error-handling.js
Created April 16, 2018 12:56 — forked from abyx/angular-error-handling.js
AngularJS HTTP Error Handling Mechanism
var HEADER_NAME = 'MyApp-Handle-Errors-Generically';
var specificallyHandleInProgress = false;
angular.module('myApp').factory('RequestsErrorHandler', ['$q', function($q) {
return {
// --- The user's API for claiming responsiblity for requests ---
specificallyHandled: function(specificallyHandledBlock) {
specificallyHandleInProgress = true;
try {
return specificallyHandledBlock();
@fmtarif
fmtarif / angularjs-providers-explained.md
Last active February 28, 2018 10:42 — forked from demisx/angularjs-providers-explained.md
AngularJS Providers: Constant/Value/Service/Factory/Decorator/Provider

call order: jsfiddle link

Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes