Skip to content

Instantly share code, notes, and snippets.

@xtfs
xtfs / php-xdebug.install
Last active January 11, 2018 17:48
install php xdebug on linux
with sudo
run > apt-get install php-xdebug
edit > nano /etc/php/7.0/mods-available/xdebug.ini
Add this:
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
@xtfs
xtfs / mysql-docker.sh
Created May 10, 2018 23:51 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@xtfs
xtfs / git branch name
Last active August 23, 2018 22:35
Show git branch name
# 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)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
@xtfs
xtfs / full path zsh
Created September 25, 2018 00:44
see the full path zsh
PS1='${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[green]%}Location: %~%{$reset_color%} $(git_prompt_info) '
@xtfs
xtfs / formatterDate.jsx
Created November 1, 2018 14:29
Formatter redux-form
import React from "react";
import { Field, reduxForm } from "redux-form";
import normalizePhone from "./normalizePhone";
const upper = value => value && value.toUpperCase();
const lower = value => value && value.toLowerCase();
const lessThan = otherField => (value, previousValue, allValues) =>
parseFloat(value) < parseFloat(allValues[otherField]) ? value : previousValue;
const greaterThan = otherField => (value, previousValue, allValues) =>
parseFloat(value) > parseFloat(allValues[otherField]) ? value : previousValue;
@xtfs
xtfs / how_to_use_existing_ssh_key
Last active January 8, 2020 18:48
use existing ssh key on newly installed ubuntu
cp /path/to/my/key/id_rsa ~/.ssh/id_rsa
cp /path/to/my/key/id_rsa.pub ~/.ssh/id_rsa.pub
# change permissions on file
sudo chmod 600 ~/.ssh/id_rsa
# start the ssh-agent in the background
eval $(ssh-agent -s)
ssh-keygen -f ~/.ssh/id_rsa -y > ~/.ssh/id_rsa.pub
sudo chmod 600 ~/.ssh/id_rsa.pub
# make ssh agent to actually use copied key
ssh-add ~/.ssh/id_rsa
@xtfs
xtfs / nginx 80 already in use.txt
Created February 8, 2019 18:50
nginx emerg bind 80 already in use
sudo fuser -k 80/tcp
service nginx start
@xtfs
xtfs / ListAmazonSQSMessagesCommand.php
Created December 16, 2019 14:13
example to list amazon sqs on php
<?php
namespace App\Command;
use Aws\Sqs\SqsClient;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@xtfs
xtfs / gist:968c65ce231ced35caba865b174182b8
Created January 9, 2020 20:19
remove memory limit to run composer require/install
COMPOSER_MEMORY_LIMIT=-1 php composer.phar require symfony/form
@xtfs
xtfs / Strong Password RegEx
Created January 11, 2021 01:08 — forked from ravibharathii/Strong Password RegEx
A Regular Expression for a Strong Password
Description of this regular expression is as below:
Passwords will contain at least 1 upper case letter
Passwords will contain at least 1 lower case letter
Passwords will contain at least 1 number or special character
Passwords will contain at least 8 characters in length
Password maximum length should not be arbitrarily limited
(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$