Monday, December 1, 2014

Russian of the week #3

Otlichno - Good Job !
Do Sevedania - See you later
Ya ne goloden, a ti kak ? - I am not hungry, are you ?

Saturday, November 29, 2014

how to install ps3 media server on ubuntu 14.10 ?

if you follow the steps on ubuntu help page to install Ps3 media server 

you will get an error, its because the project has not been updated since ubuntu 13.10 raring, and the there is no package for utopic to fix that, do the following :



sudo add-apt-repository ppa:happy-neko/ps3mediaserver
sudo sed -i s/utopic/raring/ /etc/apt/sources.list.d/happy-neko-ps3mediaserver-trusty.list
sudo apt-get update
sudo apt-get install ps3mediaserver
The second command simply replaces the word utopic with the latest available package in ubuntu's repository. if you are reading this article at the time that a newer version of ubuntu is released (after 14.10) simply change the utopic (marked in red) with the newer ubuntu's name

the rest of the things are same with the ubuntu's help page.

Thursday, November 13, 2014

install libs before installing vagrant-aws

ahh,,, took me a while to figure out !


sudo apt-get install build-essential libxslt-dev libxml2-dev zlib1g-dev

Wednesday, November 12, 2014

open recent files in vim

http://www.vim.org/scripts/script.php?script_id=521

Tuesday, November 11, 2014

Russian of the week 2

Ya idu damoi   - I go home
Ya ne idu damoi , I don't go home

Ya zhdu koffe, I am waiting for the coffee

Tuesday, November 4, 2014

My Russian Phrases of week 1


Dobrey Otra

Min Ya Zavot Medya

Minye govaru po russki

Kak Pozhovaesh ?

Kroota
Horosho

Spasiba


Hochesh Pozavtrakat ?
Hochesh Obait ?
Hochesh popit ?
Hochesh potantsevat ?


Paka

Tuesday, October 28, 2014

diffrence of $JAVA_HOME and JAVA_HOME

Tip of the day !

$JAVA_HOME is gonna be global and requires the right permissions
JAVA_HOME is a gonna be local

Wednesday, October 1, 2014

Monday, September 22, 2014

Find a file in linux

find / -name nameOfTheFile

Tuesday, September 9, 2014

even if it is not a scam, is AmEx that stupid ?

Today I got a phone call, someone with a heavy accent asking me,


- Hello is this "Medya ..." ?

I am pausing...hm...should I confirm my full name to this unknown number ? and I decided to say :

- Me: Who is this ?

- I am from AmEx, you had left a message for us on the website, this is regarding your question. can you please confirm your date of birth ?

- Why ?

- Sir I have to ...before I can blah blah

- if I left a message through email , why dont you just email me back ?

- Sir I need you to verify your DOB

- I am not gonna tell an uknown number who called me, my DOB or SSN, I have to drop this call, if there is something important, just email me.

-Sir it is important and I can't email you.

- I am sorry, I don't trust who you are, and this is not professional for a company to call me and ask me my DOB, if you have something important for me just email me .


so I it made me think is that a scam ? even if it is not a scam, is AmEx that stupid ? calling from a unkown number asking people to tell them their DOB ? wouldn't that be advising customers to do bad practice ? to give their info to anyone who calls them and claims they are from AmEX ?


CD (change directory) to a long path without lots of tab ...

I used to go to this directory every time I wanted to develope this cookbook,
cd /home/chef-repo/cccis-cookbooks-parent/cccis-weblogic

which involved lots of tab... one way to fix that would be creating a soft link at home or any where else you wanna acccess it, but thats would be lots of soft links,

I decided to go with environment variables

export weblogic_cookbook=/home/medya/chef-repo/cccis-cookbooks-parent/cccis-weblogic
now anywhere I am all I have to do is,
cd $weblogic_cookbook


the good thing is I dont even have to type $weblogic_cookbook, I can type $web...and press tab it will auto complete me. pretty sweet :)

to make this permanent, and make it run every time you open a new seassion (like when you duplicate a SSH seassion) you need to add to to the profile.d foder

I added it to a file under /etc/profile.d/MedyaProfile.sh


Monday, September 8, 2014

Shady Comcast, hopes customers mistake $9.95/mo fee for $2.5/month !

When you try to order cable, they have not HD reciever by default, for HD reciever there is a button "Add for $2.5", if you hover over the button a tool tip shows up, "A monthly HD Technology fee of $9.95 applies." the tooltip hides as soon as you move the mouse, so you dont have the option of copying it for a customer service.

Here is the shady part, you click on "Add for $2.5" and in the total summary it reflects only $2.5 more money (as you had expected) and then it asks for your social security number,
to proceed, once they send a inquiry to your credit report, you can see the $9.95 price been added to your monthly total. (at this point you would feel it is too late to cancel I already gave them my SSN)

I talked to multiple customer service on chat, as soon as I asked about this, they changed the topic of the conversation, I kept being presistant and they finally told me "We apologize for incorrect information being displayed as we are currently updating our website. This will be fixed as soon as possible. HD service will be $9.95/mo."

I do not trust Comcast .

Monday, September 1, 2014

how to get proccess ID of the last background process

in a shell cscript $! could be used to get the PID of the last backgrounded process,

for example

        sudo -u ${user} ${home}/bin/my_script.sh  &

        wls_pid=$!      ;

Friday, August 29, 2014

Monday, August 25, 2014

Fix numpad keys wierd behavior in Vim when using Putty

Problem:
Putty acts when whenever you press numeric keys in vim

Solution:
in Putty, Checkmark "disable application keypad mode" under terminal settings
save the session to not repeat this every time.


Thursday, August 14, 2014

Vagrant with log

VAGRANT_LOG=info vagrant up

Thursday, July 31, 2014

Back up (dump) all databases in a server in seprate .sql files


#!/bin/bash
echo "show databases;" | mysql -u root --password='YOURSECUREPASSWORD' | while read databasename
do
    echo dumping $databasename
    mysqldump -u root --password='YOURSECUREPASSWORD' "$databasename" >"$databasename.sql"
done

Wednesday, July 30, 2014

Tuesday, July 29, 2014

Fix vagrant error "sudo: sorry, you must have a tty to run sudo"

if you try to spin off a CentOs or Oracle Linux using Vagrant in AWS you will get the following error :

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mkdir -p '/vagrant'
Stderr from the command:
sudo: sorry, you must have a tty to run sudo
The fix is adding the "config.ssh.pty= true" to your Vagrantfile so it will look like something like this :

        config.vm.provider :aws do |aws,override|
                  # blah blah
                  config.ssh.pty= true
        end

Installing Java JDK 7 on Oracle Linux 5.5

Download the rpm

wget https://PATH TO THE RPM

rpm -ivh jdk-7u65-linux-x64.rpm

java -version

 /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_65/bin/java 17065

java -version


Changing the active jdk version

/usr/sbin/alternatives --config java

Monday, July 21, 2014

Change Linux machine name in Ubuntu

sudo hostname chef-worksation

Wednesday, July 9, 2014

See numeric permission in terminal

Ever wanted to see the Linux file permissions to number? (for example convert drwxr-xr-x to 755 ) ?
stat -c "%a %n" *

Sunday, July 6, 2014

Installing git on CentOs

for some reason, git wont be installed on a cent os unless you force it this way:

yum --disableexcludes=main install git

Tuesday, July 1, 2014

How to shorten terminal prompt in Linux ? (Trim Directory Path)

ever done cd into too many directory that your terminal prompt was taking the whole line making it hard to type any command ? Previously I posted about how to do shorten the terminal using PS1,

I found out a another way, which syntax doesn't require knowing any regex. simply enter:

$PROMPT_DIRTRIM=1

change 1 to the number of levels you wanna see.

here is how my prompt look before :
medya@arch-chef-001:~/chef-repo/vagrant-machines/oracle-linux-5-5$medya@arch-chef-001:~/.../vagrant-machines/oracle-linux-5-5$ PROMPT_DIRTRIM=1


and after 
medya@arch-chef-001:~/.../oracle-linux-5-5$


Wednesday, May 28, 2014

Stop vim from tabbing your pasted clipboard

to stop vim from auto-format auto-indent your pasted clip board,
:set paste
if you wanted to go back to how it was before
:set nopaste
This is specially useful when you paste stuff from windows into ssh putty of a linux machine,
since it is windows every linefeed is \n and it indents every new like with a tab, makes the pasted text really ugly !

Sunday, March 30, 2014

Make Eclipse highlight every instance of the selected text

I love the way notepad++ highlights every instance of the selected keyword, something eclipse doesnt do it automatically, to make it do it first select the text then, ALT+SHIFT+O

Thursday, March 27, 2014

Final Array vs Final Variable in Java

Final in java means you can not change it after been initialized, but ever noticed , you can change values of a final array but not values of a final variable ?

public class UF {
private final int[] nodes;
private final int something=0;
public UF(int n) {
nodes = new int[n];  // perfectly fine
                nodes[0]=-1;     // perfectly fine
                nodes[0]=13;     // perfectly fine
                something=-1;  // ERRR IT IS NOT OKAY
}


Why java is okay with final int[] array to be changed but not final int ? the final for Array means , you can not change the reference of the array to another array, but the content of array could be anything, since arrays are passed by reference not by value.but for variable, it is passed by value and u can not change the value .

For example the following example for array will make the compiler yell at us :
public class UF {
private final int[] nodes;
public UF(int n) {
nodes = new int[n];
int[] test = new int [n];
nodes=test; // ERRRR compiler not happy !!! you are trying to change a final reference to another reference
}
but How to make the array values final ? the answer is using umodifiable collections of java
for example :
int[] arr= new arr[5];
List items = Collections.unmodifiableList(Arrays.asList(arr));

Thursday, March 20, 2014

Arbitrary Number of Arguments in Java

Today I learn a cool tip, three dots in java mean Arbitrary Number of Arguments
for example ,

public SchemeUser(String name, AccessPermission... permArgs) {
//
}

means any number of AccessPermission arguments could be passed.

Sunday, January 26, 2014

The weirdest dual boot problem ever ! booting to Ubuntu causes audio problem on Windows!

For the past few months I have been cursing myself for installing windows 8.1 (don't judge me, I had to install it to try out the new Visual Studio which apparently works only with windows 8)

I had lots of driver issues with windows 8, pretty much everything stopped working, wifi, Audio,keyboard (yes I had to use virtual keyboard to do anything) which is ... not surprising for me, that's pretty much what we expect from a windows but one problem surprised me the most !!!

The Audio jack for headphone on my realtek audio card would stop working randomly, and I kept doing what Microsoft support and Toshiba support said, (same old things we have been doing since windows 95, going to device manager and uninstalling the driver and installing it again, and if didn't work go to safe mode and do same thing)

None of those solutions solved my problem, till today I found out the reason !!! I noticed anytime I boot to Ubuntu and then restart to windows 8, the audio doesn't work,which is REALLY weird, cause they are the two different partitions, how could they possibility cause error on each other ?

The solution to my problem was pretty primitive too, I had to unplug my computer from the power for 1 minute and then restart back to windows 8.1 to have any audio,  I am still trying to figure out what is exactly going on with this weird problem, but my guesses are, the Audiocard has some flags on it which can be set, and it wont be cleared unless you shut down the computer and unplug it from the power !

Saturday, January 18, 2014

Easy way to find the path of VIMRC in Windows, Mac and Linux

Vim is favorite code editor for many, and vimrc is the config file for vim, I earlier posted about modifying vimrc to highlight syntaxs and show line numbers and auto indent for python and other languages,

if you are using linux you can always find your .vimrc file in the home folder (~) but what about in windows, command line or mac os ? it becomes more confusing when some windows filesystems dont like dot and you have to change it to _

Here is the solution, ask Vim itself where is the path, simply inside vim type :
:e $MYVIMRC

if you are using graphical vim
:e $MYVIMRC

Saturday, January 4, 2014

Adding undetected resolutions to ubuntu 13.10 (& Gnome 3.10) usind xrandr

Old days of editing xorg.conf is over, nowadays you gotta use xrandr, and cvt to add new resolutions to your undetected monitor like mine,which is an old Del 2001FP monitor.  for full details ubuntu wiki
but here are the setps I did to get most quality out of my monitor.

1-first step is to figure out the supported resolution on your monitor, I found out by pressing menu button on my Dell Monitor Panel, where it says,
optimum resolution : 1600x1200 60Hz
you can alternatively login to windows or other and see the supported resolutions

2-Next step is to calculate the Coordinated Video Timing, it old times you had to go through forums and ask for nice geeks people to do it for you, now there is an app for it.

Enter in terminal (ofcourse change the numbers to the resolutions in step 1, if you don't have a frequency choose 60 which works most of the times):
cvt 1600 1200 60
3- in previous step it gave you an output like this:
# 1600x1200 59.87 Hz (CVT 1.92M3) hsync: 74.54 kHz; pclk: 161.00 MHz
Modeline "1600x1200_60.00"  161.00  1600 1712 1880 2160  1200 1203 1207 1245 -hsync +vsync
copy the part after Modeline (the part I marked in red) and put it after xrandr--newmode
so it would look like something like this:
xrandr --newmode "1600x1200_60.00"  161.00  1600 1712 1880 2160  1200 1203 1207 1245 -hsync +vsync


4- in step four, pick the monitor name you wanna add the resolution too, in case you have two monitors, you can figure out the name of your monitor using
sudo xrandr -q
the output will be like
VGA1 connected primary 1600x1200+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
....
...
..
in my case VGA1 is the name of my monitor, so I need to add the created resolution mode to it,
so I run this command replace the red part with your own mode name (generated in step 3)
sudo xrandr --addmode VGA1 1600x1200_60.00

5- Finally to make it active, enter the following (again replace the red with your own mode name)

 xrandr --output VGA1 --mode 1600x1200_60.00
6- To make it permanent add the commands above to ~./xprofile file so it will be run everytime X session starts.
here is how my ~/.xprofile  file looks like:
xrandr --newmode "1600x1200_60.00"  161.00  1600 1712 1880 2160  1200 1203 1207 1245 -hsync +vsync
xrandr --addmode VGA1 1600x1200_60.00
xrandr --output VGA1 --mode 1600x1200_60.00
For full details read here :
https://wiki.ubuntu.com/X/Config/Resolution/#Adding_undetected_resolutions

Related

Labels

computer (48) ubuntu (46) linux (28) tutorial (20) opinion (17) programming (14) software overview (13) terminal (12) troubleshooting (8) life (7) literature (7) poem (7) human languages (6) vim (6) bash (5) google (5) python (5) android (4) cars (4) phpBB (4) suggestion (4) tips (4) 12.04 (3) Chef (3) extension and addons (3) firefox (3) java (3) personal (3) russian (3) shell (3) windows (3) 64bit (2) Calligraphy (2) Chicago (2) Vagrant (2) apple (2) backup (2) bug (2) code (2) eclipse (2) funny (2) google chrome (2) idea (2) monitor (2) php (2) phpBB3 (2) shorter prompt (2) ssh (2) virtualbox (2) $_SERVER['REQUEST_URI'] (1) 2.7 (1) ALT+Backspace (1) AVR (1) Alt-Printscreen-K (1) AutoRotate (1) CTRL+ALT+DELETE (1) DRM (1) Debugging (1) Gimp (1) Gimp 2.8 (1) Microcontroler (1) Restart X (1) UML (1) Ventra (1) adsense (1) amazon (1) audio (1) aws (1) background process (1) battery (1) bing (1) blank (1) blogging (1) bmw (1) boot (1) business review (1) car (1) cd (1) chrome (1) comcast (1) computer kubuntu (1) conference (1) cookie (1) cron (1) database (1) date (1) display (1) domain name (1) download manager (1) dual boot (1) dual monitor (1) extensions (1) feature request (1) file (1) folder (1) freeze (1) gimp single window (1) git (1) gnome 3.10 (1) google docs (1) google plust (1) google+ (1) grep (1) icon (1) install (1) iterator (1) links (1) linu (1) linux links (1) list (1) mac os (1) media server (1) microsoft (1) moonlight (1) music (1) mysql (1) name (1) nautilus (1) netflix (1) notepad++ (1) parking (1) permission (1) philosophy (1) photo (1) prompt (1) protest (1) ps3mediaserver (1) putty (1) read from file (1) realtek (1) resolution (1) roku (1) samsung (1) scala (1) screenshot (1) security (1) selinux (1) server (1) skype (1) space (1) spam (1) spambot (1) sql (1) suspension (1) system monitor (1) tar (1) task manager (1) template design (1) th23 domain (1) thinking (1) ubuntu 13.10 (1) unity (1) vimrc (1) virtual machine (1) weblogic (1) wget (1) with space (1) xorg (1) xrand (1)