Skip to content

Instantly share code, notes, and snippets.

@Mrkisha
Mrkisha / switchphp.sh
Created March 16, 2017 22:49
Switch between php version on debian/ubuntu
sudo a2dismod php5.6
sudo a2enmod php7.0
sudo service apache2 restart
@Mrkisha
Mrkisha / BookController.php
Created December 10, 2016 21:36 — forked from silviuvoicu/BookController.php
Spec with phpspec a symfony2 controller. I know which is the normal work flow: write first the spec, and then the code, but in order to understand better how to spec a symfony2 controller, I first create a simple book entity with just id and name, and then with the help of generators I created a crud system, which I modified a little. Then havin…
<?php
namespace Acme\DemoBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Acme\DemoBundle\Entity\Book;
@Mrkisha
Mrkisha / dockerGetIP.sh
Created November 18, 2016 14:35
Get IP of docker container
docker inspect <container ID> | grep IPAddress | cut -d '"' -f 4
@Mrkisha
Mrkisha / remove-docker.sh
Created November 17, 2016 16:14
Bash script to remove all docker images
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@Mrkisha
Mrkisha / recreateDB.sh
Created June 22, 2016 11:27
Cli to recreate database without structure and content
#!/bin/bash
mysqladmin -u<user> -p<password> drop <database>
mysqladmin -u<user> -p<password> create <database>
@Mrkisha
Mrkisha / dumpDbToFile.sh
Created June 22, 2016 11:25
Bash command to dump database into file with content and append timestamp to file
mysqldump -u <user> --password=<password> <database> > ~/somefolder/some-file-name-$(date -d "today" +"%Y%m%d%H%M").sql
@Mrkisha
Mrkisha / gist:0fd2d252ba67061a949fbf0ce53b0d5c
Created June 16, 2016 11:38 — forked from Suave/gist:6127873
mysql: truncate all tables in one command line
mysql -Nse 'show tables' DATABASE_NAME | while read table; do mysql -e "truncate table $table" DATABASE_NAME; done
@Mrkisha
Mrkisha / .bashrc
Created February 28, 2016 13:19
Custom linux bashrc
[ -r /etc/bashrc ] && source /etc/bashrc
[ -r /etc/bash_completion ] && source /etc/bash_completion
[ -r ~/.git-completion.bash ] && source ~/.git-completion.bash
[ -r ~/.git-prompt.sh ] && source ~/.git-prompt.sh
[ -r /usr/local/rvm/scripts/rvm ] && source /usr/local/rvm/scripts/rvm
__has_parent_dir () {
# Utility function so we can test for things like .git/.hg without firing up a
# separate process
test -d "$1" && return 0;
# screen
#You SSH into a server, run a command, the internet goes off…profanities all around you!
#Had you used screen, this wouldn’t have happened!
#With screen, you will:
#create a new terminal session with
screen -S executing-long-command
@Mrkisha
Mrkisha / AppKernel.php
Last active November 14, 2015 20:40
Make vagrant run faster
<?php
class AppKernel extends Kernel
{
// ...
public function getCacheDir()
{
if (in_array($this->environment, array('dev', 'test'))) {
return '/dev/shm/appname/cache/' . $this->environment;