How does collabedit work? - session

When you enter the Collabedit online editor it gives you a url with a random session name so you can send to friends to join. How does that work?
How does the session name get created and added to the URL .i.e the y3y2c part
in http://collabedit.com/y3y2c
If there is any tutorials you can link, please do.
Thanks.

Related

How to read a Google People api response object [updated]

I'm new to Google's API and I'm having trouble reading the content of a People contact.
To get the details of a particular contact, references show this code should work [Edit: I updated the personfields]:
profile = service.people().get(resourceName='people/c63810788897573286', personFields='names')
The resourceName is the ID of a particular contact (that ID will only work for someone with access to my account). The server grabs it correctly and returns this:
<googleapiclient.discovery.Resource object at 0x10fd183c8>
How do I read the content of this object? I can't figure out from the documentation
I want to print out the Name. I'm pretty new to APIs, so maybe there is a standard way to read an HTTP object or maybe it's something unique to Google's API. Thanks for any advice
I found an answer in another somewhat related StackOverflow. I needed to the add .execute() to the call
profile = service.people().get(resourceName='people/c63810788897573286', personFields='names').execute()

File ID different from the URL File ID - Google Drive API

I'm trying to access a file in a Google Drive directory but linking to it using the File Id provided by the API it says that i don't have permission. What i saw is that the File Id in the URL is different from the one who returns from the API. Why?
Using the test page of the Google Api it returns a "Not Found" error(404) and not the "No Permissions" error. Anybody knows how to get this ID(same of the url) that links to the file instead of the File's ID
Edit: Found that the File Resource has a property called "webViewLink" is it the link to the file instead of using the ID?
When you are trying the Drive API, you can set using fields property what values you want to return from your call as it is shown in this image:
webViewLink will return you the link that's shown when you open the file in your browser.
id will return you the ID of the file.
I specified some values, but you can see HERE all the values you could use and if you put "*" you will return all of them. Also, I didn't show in the image the id of the file to not share that info.
HERE you can see why you are getting that error. Surely, you don't have enough permitions because you have already checked that it exists for what I understood in your question.

How can I show user's first name to the user after the user logged in

I am using Ion_Auth and I have a problem. I have looked for the solution but there is no progress yet.
As an example, there is a user and his name is Alex.
When Alex is logged in the portal, He should see his name Alex and then if he clicked his name, he will go to his user settings to edit his details. The problem is I can't show the first_name when a user have logged in.
How can I do that? I don't know what codes I can publish for this situation. Tell me what you need as code, I can publish if you need.
Having never used Ion_Auth, I decided to have a look at the repository on GitHub. You could use the user_id and pass this to a model method to get the first name (like umefarooq has suggested).
However, I would pull the first name from the database and store it in the session when the user logs in. This means you don't have to go back to the database just to get their name.
You can see in the Ion_auth model, this line;
$query = $this->db->select($this->identity_column . ', username, email, id, password, active, last_login')
https://github.com/benedmunds/CodeIgniter-Ion-Auth/blob/2/models/ion_auth_model.php#L985
You could just add the first name row to this query, and it will be added to the session when the user logs in.
You can then access it by:
$this->session->userdata('FirstName');
Hope this helps.
The easiest way is:
$user = $this->ion_auth->user()->row();
echo $user->first_name;
When the user logged in successfully, store his/her first name into the session variable.
then call the specific session variable on where you want to display.

how to write queries in Hive Web Interface

I was playing around with hwi, I got it started.Now I can see the different schemas which are present. But I don't know how to query them. I tried to check hive wiki (https://cwiki.apache.org/confluence/display/Hive/HiveWebInterface) but they dont seem to have much information put over there. There seems to be a Running a query section in Walk through but it says image not found.
Anybody who has used HWI to query please suggest a way to use it.
Try these steps :
Open HWI : http://localhost:9999/hwi/index.jsp
Click on Authorize in the left pane. This will open the Change User Info section. Enter the username and hit submit to complete the authorization process. Upon successful authorization you'll see Authorization is complete at the top of your page.
Now click on Create Session, enter some session name and hit Submit.
Once you submit the session name you'll get the Manage Session screen. This is the place where all the action will take place. Come down to the Session Details section and enter a file name, say /Users/tariq/res.txt, in the Result File box. This is the file where the result of your query will get stored. If you expect your result to be very huge you can just enter /dev/null over there. Remember the result file is local to the web server. Similarly enter the error file if you wish.
Now come down to the Query box and write the query you want to execute.
Come down further to the Start Query drop down list, click on it and elect YES and hit Submit.
You should be able to see the file /Users/tariq/res.txt by now containing the result of your query. You can also view the result by clicking on View File option which will appear next to the Result File box upon the successful completion of your query.
HTH
Take a look at Hue - http://cloudera.github.io/hue/
This project is bundled with the Cloudera installation and seems to work rather well.
Best,
Sukrit

DocsList findFolder() issue

This is a google spreadsheet script question.
I have a GUI setup in order to search for "SouthWest" and then find a "test" sheet. This is the code I am using.
var file = DocsList.getFolder("SouthWest").find("test");
This works just fine when I run it under my account (as I have this folder and file setup correctly) but when another user is logged into google docs it will attempt to search for this folder/file under the new user instead of the owner of the document. Is there a way to have it just search the DocsList of the owner of the spreadsheet that is currently open? The error that I get under the new user is "Error encountered: Cannot find folder SouthWest." Thanks.
If you always want to access the same file, you can use the getFileById method and address it directly instead of searching every time:
https://developers.google.com/apps-script/class_docslist#getFileById
Of course, you should make sure that all users are allowed to access that file.

Resources