Showing posts with label path. Show all posts
Showing posts with label path. Show all posts

Tuesday, October 25, 2016

NodeJS permission issues troubleshooting path

NodeJS permission issues troubleshooting path


It was such a terrifying experience to have node and especially yeoman not work because of weird permission issues. I fixed the issues finally and kind of think theres pattern to it. This is not a full and final cookbook type of thingy but you might wanna check this method out in case you are stuck with the same issues. First of all
1. If the problem is not in your project directory then it must me in your ~/.config and ~/.npm directories. As you may have seen many newbies of node opt to the sudo method of installing things. But this causes problem regarding permission when yeoman comes in as some of the commands need access to areas where root is not permitted and if you do not use sudo before yo, you get errors about some of the errors where you need root. This mess up is simply caused by sometimes using sudo and sometimes not. Which you have to do because you do not own the ~/.npm directory. Just own it using

sudo chown -R `whoami` ~/.npm
2. If the problem still persists, check your project directories node_modules directory if it has any subdirectory or file deep inside where access is needed it has root privileges required. So you can use the same owning method there too

sudo chown -R `whoami` ~/.npm
3. Always try to install non globally. This will save you a lot of trouble.

Credits: Stackoverflow [ http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo ]

Go to link download

Read more »

Sunday, October 9, 2016

Running your first PHP application in Google App Engine Fix for the php executable path flag issue

Running your first PHP application in Google App Engine Fix for the php executable path flag issue


As I may (or may not) have mentioned before, I mostly blog here for the purpose of note-keeping for myself. In most of the cases I dont really care about how good the tutorials (not so much) are coming out. So, please do your homework if you are following any of my tutorials at all. This is gonna be a disclaimer somewhere, but see? I cant give a damn here. Thanks.
I was trying my hands on the Google App Engine. My system is Linux so I downloaded, followed the linux part of things from their official how-to-first-time page here [ https://developers.google.com/appengine/docs/php/gettingstarted/installing ]
As you can see from that page (yeah, thats a dependency) you
1. Download the PHP SDK
2. Extract it some nice place
3. Write a "hello world!" PHP script
4. Execute the python script (dev_appserver.py) in the the "google_appengine" (if you havent done it otherwise) folder.
BUT ! I got stuck here for sometime, and looked up for the fix.
Source of the problem:

_PHPBinaryError: The path specified with the --php_executable_path flag () does not exist.
Which naturally implied 2 things

1. The PHP installation was NOT as the app engine wants it to be
2. God doent want me to code anymore
I naturally believe God loves it when Im busy with my favourite thing so number 2 was obsolete. I looked up on Google for some solutions and a sudden SO page suggested that executing the appserver executable like

./dev_appserver.py --php_executable_path="...path..to..the..php-cgi..executable..." helloworld
will solve the problem.
Following this trail I came to notice that my ignorance toward the tutorials PHP installation paid of here. The problem was actually my PHP installtion was a CLI version. While the app engine essentially wants a CGI version. For doing so, the tutorial has very good instructions, and yes, php-cgi is NOT available in Ubuntu repos. So I did

sudo apt-get install gcc libmysqlclient-dev libxml2-dev
wget --trust-server-names http://us2.php.net/get/php-5.4.15.tar.bz2/from/us1.php.net/mirror
tar xjf php-5.4.15.tar.bz2
cd php-5.4.15
./configure --prefix=$PWD/installdir --enable-bcmath --with-mysql
make install
cd -
And afterwards executed

./dev_appserver.py --php_executable_path="...path..to..the..php-cgi..executable..." helloworld
And it went smooth. :) By the way, the above method will NOT harm you normal PHP installation.

Go to link download

Read more »

Wednesday, August 31, 2016

The Dijkstra Algorithm for Single Source Shortest Path

The Dijkstra Algorithm for Single Source Shortest Path


Currently the code is still under development. This is just to have the track of docs that Im using to write it
Theory : [ http://en.wikipedia.org/wiki/Dijkstras_algorithm ]
Priority queue (STL) : [ http://comsci.liu.edu/~jrodriguez/cs631sp08/c++priorityqueue.html ]
[ http://www.technical-recipes.com/2011/priority-queues-and-min-priority-queues-in-c/ ]
Till now it feels like thats all you need, I dont know for sure though. Lets see
Update : Heres a full code of a problem that I solved using this algorithm [UVA 10986]

#include <iostream>
#include <list>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

// based on TopCoder tutorial

#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define INF 200000010

list<ii> G[30000];

int djk( int s, int t, int n ) {
vi D(n, INF);

set<ii> q;
D[s] = 0;
q.insert(ii(0,s));

while (!q.empty()) {


ii top = *q.begin();
q.erase(q.begin());
int v = top.second, d = top.first;

tr(G[v], it) {
int v2 = it->second, cost = it->first;
if (D[v2] > D[v] + cost) {
if (D[v2] != INF) {
q.erase(q.find(ii(D[v2],v2)));
}
D[v2] = D[v] + cost;
q.insert(ii(D[v2],v2));
}

}
}
return D[t];
}


int main( void ) {
int test, n, m, s, t, x, y, v, kase=1;
scanf("%d",&test);
while (test--) {
scanf("%d %d %d %d",&n,&m,&s,&t);
for (int i=0 ; i<=n ; i++) {
G[i].clear();
}
for (int i=0 ; i<m ; i++) {
scanf("%d %d %d",&x,&y,&v);
G[x].push_back(ii(v,y));
G[y].push_back(ii(v,x));
}
int res = djk(s,t,n);

printf("Case #%d: ",kase++);
if (res == INF) printf("unreachable ");
else printf("%d ",res);
}

return 0;
}


Go to link download

Read more »