Saturday, October 7, 2017

Change MySQL Data Dir on Centus 7 with SELINUX

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Managing_Confined_Services/sect-Managing_Confined_Services-MySQL-Configuration_Examples.html 

Monday, November 17, 2014

TeamViewer Log Files on Mac

So I wanted to check the log files and the connections file of teamviewer because I've seen some strange activities going on! But I couldn't find them. The support website only says: "TeamViewer QuickSupport. Click on the tool kit symbol in the upper right corner". I didn't see any TeamViewer QuickSupport or any right corner that has such a button. So, I (my mac) wasted a lot of time finding the file. It is here (X is your version of teamviewer):

./Library/Logs/TeamViewer/TeamViewerX_Logfile.log
./Library/Logs/TeamViewer/Connections.txt

I still cannot find the source of the strange activity tho! The log files didn't show anything strange. But someone was controlling my mouse and I could see it! It is a shared computer and one other person has teamviewer on his account but it is not running. So, I'm wondering what might have gone wrong. I'll change my password, but please let me know if you think there is a way I can figure this out.

Thursday, April 25, 2013

Installing and Running MongoDB on Mac

So, I think that mongoDB instructions are not complete enough to install it on Mac. Here is what I did to install mongoDB:

  • Download it from http://www.mongodb.org/downloads
  • Move the files to where you like it to be installed:    mv -n mongodb-osx-[platform]-[version]/ /PATH/TO/NEW/LOCATION/
  • Decompress the files: tar -zxvf mongodb.tgz
  • Make a data directory: sudo mkdir -p /PATH/TO/DATA/FOLDER/db
  • Allow mongoDB to access this directory: sudo chown `id -u` /PATH/TO/DATA/FOLDER/db
  • Create a log directory: sudo mkdir -p /PATH/TO/DATA/FOLDER/db
  • Create a config file for it in the /etc folder: sudo vi /PATH/TO/LOG/FOLDER/mongod.log
  • Fill in the configurations: 
#mongod config file
#replica setreplSet=replA
#start mongod in shardsvr modeshardsvr=true
#where to loglogpath=/PATH/TO/LOG/FOLDER/mongod.log
#log overwritten or appended tologappend=true
#fork and run in backgroundfork=true
#override portport=27018
#path to data filesdbpath=/PATH/TO/DATA/FOLDER/data/db
  • Configure: mongod --config /etc/mongod.conf
  • Run the server: /PATH/TO/MongoDB/BinFolder/mongod
  • Run the client: /PATH/TO/MongoDB/BinFolder/mongo
That's it! Of course you can add the bin folder to $PATH to make it easier for you to access and run mongoDB. Have fun creating cool databases! 

P.S. I have Mountain Lion and mongoDB 2.4.1

Wednesday, January 30, 2013

Loading a file into Jena

Ok, so I got so many exceptions like:

com.hp.hpl.jena.shared.DoesNotExistException
com.hp.hpl.jena.shared.JenaException: java.net.UnknownHostException:
com.hp.hpl.jena.shared.JenaException: java.net.MalformedURLException: no protocol

First of all, you need to give a URL of file, not a path to file, to Jena. Second, at some cases, like mine, just adding the string "file:" or "file://" to the beginning of your file address doesn't work. BUT, getting the file's URI and converting it to String works perfectly, even though it returns the same string as if you have appended the file address with "file:".

So, if you're struggling over reading some files into Jena, as I did, give this a try:

String url = new File(fileAddr).toURI().toString();
TDBLoader.loadModel(model, url, true);

Sunday, January 20, 2013

MSE of Non-Zero Elements in Matlab


Suppose you have a predicted matrix and a ground truth matrix. You want to find MSE (Mean Squared Error) of only non-zero elements in your prediction. Here is what you do:

[i j k]= find(truth);

f = (sparse(i,j,k)-sparse(i,j,predicted(find(truth)))).^2;

MSE=sum(f,2)./sum(f~=0,2);



The following counts (size of) the nonzero entries in each row of a matrix without loop:

c = sum(f~=0,2);


spconvert does the reverse of full command :)

Tuesday, January 8, 2013

Setting Group Permission of a Folder in Linux


make sure user is in the group:
sudo usermod -a -G <group-_name> <some_user>

set the correct permissions on group:
sudo chgrp -R <group-_name> <folder>
sudo chmod -R g+w <folder>

make sure all new files and directories created under <folder> are owned by the group:
sudo find <folder> -type d -exec chmod 2775 {} \;  


Find all files in <folder> and add read and write permission for owner and group:



sudo find <folder> -type f -exec chmod ug+rw {} \;

Wednesday, November 7, 2012

Remote Connection to Matlab on a Linux Server from your Mac

Here comes the instructions:

  1. Type "xhost +" at the command line
  2. Enter "ssh -Y {username}@{server address}" replacing {username} and  {server address} with the appropriate handle
  3. Type "matlab"


Simple & easy :)