Menu Close

devstate.de

A Dreams Engine Blog. This Blog may not make any sense to you. This is a collection of internal snippets that we collect with our experiences, but we hope some of our post will help you in some way.

.Gitignoring the hardway

To untrack a single file that has already been added/initialized to your repository, i.e., stop tracking the file but not delete it from your system use: git rm –cached filename

To untrack every file that is now in your .gitignore:

First commit any outstanding code changes, and then, run this command:

git rm -r --cached .

This removes any changed files from the index(staging area), then just run:

git add .

Commit it:

git commit -m ".gitignore is now working"

To undo

git rm --cached filename

, use git add filename.

Source: http://stackoverflow.com/a/1139797/3912326

Solve MySQL(MariaDB) Bad Socket

To find all socket files on your system run:

sudo find / -type s

My Mysql server system had the socket open at /var/lib/mysql/mysql.sock

Once you find where the socket is being opened, add or edit the line to your /etc/my.cnf file with the path to the socket file:

socket=/var/lib/mysql/mysql.sock

Sometimes the system startup script that launched the command line executable specifies a flag –socket=path. This flag could override the my.cnf location, and that would result in a socket not being found where the my.cnf file indicates it should be. Then when you try to run the mysql command line client, it will read my.cnf to find the socket, but it will not find it since it deviates from where the server created one. So, Unless you care where the socket resides, just changing the my.cnf to match should work. I

If you’re super user in the linux system, based on the above just do this:

kill -9 4969

or sometimes you can do this:

pkill -9 mysqld

After you do this you might want to look for a pid file in /var/run/mysqld/ and delete it

Make sure the permissions on your socket is such that whatever user mysqld is running as can read/write to it. An easy test is to open it up to full read/write and see if it still works:

chmod 777 '/var/run/mysqld/mysqld.sock

If that fixes the issue, you can tailor the permissions and ownership of the socket as needed based on your security settings.

Also, the directory the socket resides in has to be reachable by the user running the mysqld process.

Install Pure-FTP , –Purge VSFTP

#Install Pure-FTPd

aptitude -y install pure-ftpd

#run as a daemon

echo "yes" > /etc/pure-ftpd/conf/Daemonize

#prohibit Anonymous

echo "yes" > /etc/pure-ftpd/conf/NoAnonymous

#enable chroot

echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone

#only IPV4

echo "yes" > /etc/pure-ftpd/conf/IPV4Only

service pure-ftpd restart

#Restarting ftp server: Running: 
/usr/sbin/pure-ftpd -l pam -E -A -8 UTF-8 -B -O clf:/var/log/pure-ftpd/transfer.log -u 1000 -4 -B

Remove (PURGE!!!) VSFTPD

#remove first:

#Stop: Unknown instance
#and when I used:

ps -a | grep ftp

#I can still see vsftpd was running, That meant the vsftpd was not stopped.
#So I used: 

kill -9 25676

#the stop
service vsftp stop
sudo aptitude remove --purge vsftpd
sudo aptitude install vsftpd


#delete via rm -rf or FTP 
/etc/vsftpd.conf






Solve Upgrade Oh My ZSH Issue

If you get :

[Oh My Zsh] Would you like to check for updates?
Type Y to update oh-my-zsh: Y
Upgrading Oh My Zsh
Cannot pull with rebase: You have unstaged changes.
Please commit or stash them.
There was an error updating. Try again later?

To solve this on OSX or Server Without proper permissions or no root privileges:

#1)
 cd ~/.oh-my-zsh/
#2)
 git add .
#3)
 git commit -m "commit message"
#4)
 upgrade_oh_my_zsh

Install LEMP (Basic)

Ahora si!, a instalar LEMP Hardcore

#super user
sudo su
#update
aptitude update && aptitude upgrade
#sever name
echo "earth" > /etc/hostname
hostname -F /etc/hostname
hostname
#añade el nombre de tu server a tu la ip local de tu maquina virtual (server local)
nano /etc/hosts
#arregla el horario de tu Linux
dpkg-reconfigure tzdata
#actualiza nuevamente
aptitude update && aptitude upgrade
#cambia el password de tu usuario root
passwd root
#Instalar Esenciales
aptitude install build-essential
aptitude install python-software-properties
#agregar repositorios
add-apt-repository ppa:ondrej/php5
add-apt-repository ppa:nginx/stable
#actualiza nuevamente
aptitude update
#instalar nginx
aptitude install nginx
#instalar php5 & php-fpm
aptitude install php5-common php5-mysqlnd php5-xmlrpc php5-curl php5-gd php5-cli php5-fpm php-pear php5-dev php5-imap php5-mcrypt
#instalar mariadb  (recuerden cambiar todo lo apt-get a aptitude)
https://downloads.mariadb.org/mariadb/repositories/#mirror=jmu&distro=Ubuntu&distro_release=precise&version=10.1


#inicia todos los servicios
nginx -t && service nginx restart && service php5-fpm restart

#intalar Git
aptitude install git-core

#inicia todos los servicios
nginx -t && service nginx restart && service php5-fpm restart otravez

Instalar Good Nginx

#Cambiamos a /ETC
cd /etc

#Eliminamos la carpeta default de NGINX
rm -rf nginx

#Clona el Repositorio de nginx-dreams.git de bitbucket
#repositorio + nombre de carpeta
git clone https://[email protected]/dreamsengineering/nginx-dreams.git nginx

#Verificamos que este todo bien
cd /etc/nginx
#Lista de Directorios sobre nginx
la

#Editar dominio en /etc/nginx/sites-available, Duplicamos my-domain.com
cd sites-available
cp my-domain.com my-new-doamain.com

#Editamos nuestro nuevo archivo a conveniencia de nuestro dominio de elección.
vim my-new-domain.com

#Hacemos un symbolic link
ln -s /etc/nginx/sites-available/my-new-domain.com /etc/nginx/sites-enabled/my-new-domain.com

#Creamos Las Carpetas de dominio

mkdir /sites

cd /sites

mkdir my-new-domain.com

cd my-new-domain.com

mkdir public api cdn logs backup


#inicia todos los servicios
nginx -t && service nginx restart && service php5-fpm restart


Git

Primer Paso es hacer un folder en tu

######
#Repositorio Nuevo
#Crea tu repositorio en Bitbucket con Create
#Llena los datos
######

##1 Inicia Git de un repositorio nuevo (recuerda sudo si no tienes privilegios root)
git init

##2 Suma tu Git a la repo de tu Bitbucket
git remote add origin https://[email protected]/dreamsengineering/$TU_USER.git 

##3 Tu Repositorio ya debe de tener algo en el Folder (por lo menos un file), para entonces añadir a la cola de commits (-A es acro de --ALL)
git add -A 


##4 Listo para hacer Commit
git commit "initial commit"

##5 Subimos git al Repositorio Master Remoto
git push -u origin master


##########
#Repositorio en Branch
#El siguiente paso es después del Paso numero #4
##########

##Crea un Branch
git branch NEW_BRANCH

##Cambia al Branch 
git checkout NEW_BRANCH

##Hacer Push para sincronizar tu branch
git push -u origin NEW_BRANCH


.zsh in favor of .bash

Instalar ZSH en Linux

apt-get install zsh //or aptitude

Cambiar permanentemente a zsh

chsh
/bin/zsh 

(En OSX: En OSX , solo habra que ir a las configuraciones de usuarios y en opciones avanzadas cambiamos de

/bin/bash

a

/bin/zsh


)

Prettifying:

Instalar oh-my-zsh!

#OSX
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

#LINUX
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

Acceder a .oh-my-zsh

#Entrar a carpeta
cd ~/.oh-my-zsh

#Accede al folder de themes
cd themes

#Crear nuestro theme
touch cirkusmono.zsh-theme

#Abre el archivo creado con nano o vim para crear nuestro template
nano cirkusmono.zsh-theme

Copia el siguiente codigo y guarda el archivo

function git_prompt_info() {
  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}

function get_pwd() {
  print -D $PWD
}

function battery_charge() {
  if [ -e ~/bin/batcharge.py ]
  then
    echo python ~/bin/batcharge.py
  else
    echo ''
  fi
}

function put_spacing() {
  local git=$(git_prompt_info)
  if [ ${#git} != 0 ]; then
    ((git=${#git} - 10))
  else
    git=0
  fi

  local bat=$(battery_charge)
  if [ ${#bat} != 0 ]; then
    ((bat = ${#bat} - 18))
  else
    bat=0
  fi

  local termwidth
  (( termwidth = ${COLUMNS} - 3 - ${#HOST} - ${#$(get_pwd)} - ${bat} - ${git} ))

  local spacing=""
  for i in {1..$termwidth}; do
    spacing="${spacing} " 
  done
  echo $spacing
}

function precmd() {
print -rP '
$fg[cyan]%m: $fg[yellow]$(get_pwd)$(put_spacing)$(git_prompt_info) $(battery_charge)'
}

PROMPT='%{$reset_color%}→ '

ZSH_THEME_GIT_PROMPT_PREFIX="[git:"
ZSH_THEME_GIT_PROMPT_SUFFIX="]$reset_color"
ZSH_THEME_GIT_PROMPT_DIRTY="$fg[red]+"
ZSH_THEME_GIT_PROMPT_CLEAN="$fg[green]"

Cargar el archivo creado:

#Cambia de directorio 
cd ~/

#Edita .zshrc
vi .zshrc

En la linea 8 aproximadamente y guarda:

#Cambia el theme por cirkusmon
ZSH_THEME="cirkusmono"

Reiniciamos el server en caso de ser LINUX y reabrimos terminal.

Swageamos iTerm con Solarized

lo bajamos de :

#Thema
http://michaelheap.com/solarized-with-iterm2/
#Font
http://levien.com/type/myfonts/inconsolata.html

Logrotate

for WordPress

/sites/*/public/wp-content/*.log {
        weekly
        missingok
        rotate 4
        compress
        copytruncate
        size 1024k
        postrotate
        endscript
        maxage 10
        compresscmd /bin/bzip2
        compressext .bz2
}

/sites/*/public/assets/*.log {
        weekly
        missingok
        rotate 4
        compress
        copytruncate
        size 1024k
        postrotate
        endscript
        maxage 10
        compresscmd /bin/bzip2
        compressext .bz2
}

for Nginx Log Sites

/sites/*/log/*.log {
        weekly
        missingok
        rotate 4
        compress
        copytruncate
        size 1024k
        postrotate
        endscript
        maxage 10
        compresscmd /bin/bzip2
        compressext .bz2
}

Install Vagrant

Instalemos Vagrant!!
Instalar Virtualbox: https://www.virtualbox.org/
Instalar Vagrant: http://vagrantup.com/
Instalar Host : https://github.com/specialunderwear/Hosts.prefpane/downloads

Selecciona el Distro desde Vagrant Box https://vagrantcloud.com

#añadirlo a tu lsita de BOXES
vagrant box add hashicorp/precise32
#crea tu folder donde se creara tu servdor e iniciliciara tu side vagrant
vagrant init hashicorp/precise32
#runmachine
vagrant up
#ssh en el nuevo servidor local
vagrant ssh

Y ahora que estas conectado a tu server local

– escribe

exit

para desconectar

Hagamos que este Fake se vea real:
#abre to Vagrantfile y quita el comentario:

config.vm.network "privatenetwork", ip: "22.22.22.22"

#reinicia Vagrant en terminal:

vagrant reload

#añade la ip de tu dominio fake desde Preferencias del Sistema o

sudo open /etc/hosts -a "Sublime Text"

para abrir directamente tu /etc/hosts en Sublime Text
#añade las lineas de tu ip a tu sitio

5.55.55.5 forbes.mx

El siguiente post , hablara de configurar NGINX y poder ver tu sitio en el servidor local

Terminal Guide

#dar permiso simple
sudo
#dar super permisos
sudo su
#enlista el contenido de un directorio en particular
ls
#cambia de directorio
cd
#elimina archivo o folder simple
rm
#elimina archivo o folder en inception
rm -rf
Newer Posts
Older Posts