Skip to content

Instantly share code, notes, and snippets.

View rominirani's full-sized avatar

Romin Irani rominirani

  • Mumbai
View GitHub Profile
<servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.mindstorm.api.MyEndpoint, com.mindstorm.api.QuoteEndpoint</param-value>
</init-param>
</servlet>
package com.mindstorm.api;
import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.google.api.server.spi.response.CollectionResponse;
import com.google.api.server.spi.response.NotFoundException;
import com.google.appengine.api.datastore.Cursor;
import com.google.appengine.api.datastore.QueryResultIterator;
import com.googlecode.objectify.ObjectifyService;
@rominirani
rominirani / modify_filecontents.go
Created July 17, 2015 11:05
Go Course : Exercise 17
/*
Manipulate a text file.Search for 'word' in this text file and replace it with 'inserted word'. Write the contents
back into the original file
*/
package main
import (
"bytes"
"fmt"
"io/ioutil"
@rominirani
rominirani / analyze_mp3.go
Created July 17, 2015 10:46
GoCourse - Exercise18
package main
import (
"fmt"
"log"
"os"
)
func check(e error) {
if e != nil {
@rominirani
rominirani / gocourse - Week 3 Exercise solutions
Created July 10, 2015 12:46
gocourse - Week 3 Exercise solutions
Exercise 15 : http://play.golang.org/p/0qhgQmSVBR
Exercise 16 : http://play.golang.org/p/YYdFELAke8
@rominirani
rominirani / gocourse - Week 2 Exercise solutions
Created June 30, 2015 12:02
Week 2 Exercise Solutions from Go Course (http://gocourse.slack.com)
Exercise 11 : Line #5 and Line #6 have errors since you cannot have a pointer to a constant value.
Exercise 12 : The pointer is not initialized to anything (nil). As a result,any operation on this is going to be problematic (Null Pointer Exception). On running the program, it shows panic: runtime error: invalid memory address or nil pointer dereference.
Exercise 13 : a() is invoked first and this prints the value of the global variable i (10), which was initialized to 10 at the start of the program. The next function invoked is b() and this initializes a local variable i to 20. Hence the output is 20. This is a local variable within the scope of the function and does not affect the global variable i, which still has the value of 10. Hence the last function a() invocation simply prints the value of the global variable i that is still 10.
Exercise 14 : main() creates a localized variable i and hence the first output is 20. Then b() is invoked, which also creates a localized variable i, whose value is 40. An
@rominirani
rominirani / gocourse - Week 1 Exercise Solutions
Created June 28, 2015 08:56
Week 1 Exercise Solutions from Go Course (http://gocourse.slack.com)
Week 1 Exercises from Go Course (http://gocourse.slack.com).
Exercise 1 :
/tmp/sandbox760491916/main.go:6: syntax error: unexpected semicolon or newline before {
Needed to push the start parenthesis to the line contain main(). After that it gave the obvious errors i.e.
- package "os" is imported but not used
- println - cannot refer to unexported name fmt.println
package com.mindstorm.famousquotesandroid;
import android.accounts.AccountManager;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<!DOCTYPE html>
<html>
<head>
<title>Famous Quotes</title>
</head>
<body>
<div id="login">
<input id="loginButton" type="button" value="Login"/>
</div>