Page 3 of 4

Horizontal rule in zsh prompt

zsh-horizontal-rule-prompt

Put in your ~/.zshrc :

PS1=$'%U${(r:$COLUMNS:: :)}%u'$PS1

src = superuser.com

Increase wordpress max file upload size

On Ubuntu/Debian distro, edit the /etc/wordpress/htaccess and add this lines :

php_value upload_max_filesize 50M
php_value post_max_size 50M
php_value memory_limit 50M

Substitute a text only in files where it appears

For example, to substitute foo with bar

for f in `grep -lR foo`; do
	echo -n ">> $f";
	sed 's/foo/bar/g' $f > $f.tmp ;
	mv $f.tmp $f ;
	echo " done.";
done
  • 1) for loops on all files containing the text “foo”, grep -l only show the file name with corresponding text inside.
  • 3) sed replace foo with bar in all file
  • 4) mv save the modification (delete if you don’t want to overwrite the original files, the modified files is named with .tmp at the end)
  • 2) & 5) echo: which file is treated

Convert multiple files to utf8 using vim

The fastest and more efficient way to batch multiple files encoding conversion :

vim +"argdo se fileencoding=utf-8 | w | bnext" +"q" ` find . -type f -name "*.rsp" `

+”argdo” : execute the following vim commands for each file (filencode, save and next buffer)

+”q” : quit after last one

find : get all files with corresponding name

GIT – stop tracking files

If you have some files that you need to have in your repo but don’t need to have updates, git allows it :

git update-index --skip-worktree <FILES>

Then a “git status” won’t show those files until you do :

git update-index --no-skip-worktree <FILES>

To show the skipped files :

git ls-files -v . | grep ^S

–skip-worktree is a better solution than –assume-unchanged because status will not get lost once an upstream change is pulled.

source : http://stackoverflow.com/a/39776107/3181414

 

ZSH, nohup and background process that lasts…

When I switched to  ZSH, and letting BASH behind, I missed some behaviour : one of them was the ability to quit my terminal while some jobs are still alive.

In ZSH, I get a message like this if I exist with running jobs :

zsh you have running jobs

If I exit again, my jobs are killed. But zsh accept some useful option to overide this :

setopt NO_HUP
 setopt NO_CHECK_JOBS

First one is for not killing process after terminal exit, and second one is for not warning you about it.

Install minimum php (no apache)

To code with php, no need to install apache and other dependencies, especially as php has a builtin web server.

apt-get install php5-cli

Then use

php -S localhost:4444

and you’re done.

Get rid of the Desktop icon in Nautilus 3.10 side bar

Add in ~/.config/gtk-3.0/settings.ini

gtk-shell-shows-desktop=0

Remove all entries in ~/.config/user-dirs.dirs but let this one :

XDG_DESKTOP_DIR="$HOME/"

If you remove this too, each time nautilus is launched, it will create a ~/Desktop folder.

Remove folder Desktop if it exists

Stretched background with IE8

Side note : Microsoft has dropped support for IE8 last april 2014 🙁

There are still some clients that want their webapp to work perfectly on IE8. They can’t make all their clients move to the newest browsers. But some times, it can drive you nuts to achieve simple things. Our problem was about a background image in a div that doesn’t want to strech. Just some css will do it for all other browsers, but not for IE8. It needs a special “filter” like this :


.logondesktop { filter:progid:DXImageTransform.Microsoft.AlphaImageLoader( enabled=true, src='http://lorempixel.com/1200/800/', sizingMethod='scale');}

More info on this filter at Microsoft

Here we add a nice background (thanks to Lorem Pixel) to the ‘logondesktop’ element. Ok, that made the trick. But, wait ?!? What happen to my links and form input inside the div ? There are no more clickable !!!

Damned IE8, another bug… Now, dig again to find a fix. Hopefully, it was easy. The div content must be relatively positioned. So the html looks like


<div class="logondesktop">
  <div class="logon">
    <a href="#">CLICK ME IF YOU DARE!</a>
  </div>
</div>

And the css to fix the IE8 bug :


.logon { position: relative; }

See an example here (open with IE8) : http://fiddle.jshell.net/hamdouni/w4BBE/show

Speech Tasks : a voice driven todo webapp

With the Web Speech Api, some good javascript libs and several lines of code, you can easily add speech recognition in your web application. All is done thanks to AnnYang JS lib made by Tal Ater, plumbing with Angular Light by Oleg Nechaev and served by a Go http server. (By the way, I love opensource community !)

Try the demo !

See the code !

And thanks to Mark McGranaghan for his tutorial to deploy go app on Heroku