Skip to content

Instantly share code, notes, and snippets.

View chetangiridhar's full-sized avatar

Chetan Giridhar chetangiridhar

View GitHub Profile
@chetangiridhar
chetangiridhar / main.go
Last active March 5, 2019 04:56
Using Golang plugin
package main
import (
"fmt"
"path/filepath"
"plugin"
)
func main() {
// Glob - Gets the plugin to be loaded
package main
import "fmt"
// Add two integers
func Add(a int, b int) int {
fmt.Printf("\nAdding a=%d and b=%d", a, b)
return a + b
}
@chetangiridhar
chetangiridhar / hal_osdi.go
Last active June 7, 2017 12:48
HAL Implemenetation in Go
package main
import (
"github.com/pmoule/go2hal/hal"
"net/http"
"github.com/gorilla/mux"
"github.com/gorilla/handlers"
"os"
"fmt"
"github.com/auth0/go-jwt-middleware"
@chetangiridhar
chetangiridhar / MainActivity.java
Created November 17, 2016 09:48
Example of instantiating custom asynchronous task to make network calls
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Instantiate Async task
MyAsync myTask = new MyAsync(this);
//Run the task in an asynchronous way
myTask.execute("https://api.callhub.io/v2/conference/");
@chetangiridhar
chetangiridhar / MyAsync.java
Created November 17, 2016 09:47
Example of AsyncTask in Android
public class MyAsync extends AsyncTask {
private Context mContext;
public MyAsync(Context context) {
//Relevant Context should be provided to newly created components (whether application context or activity context)
//getApplicationContext() - Returns the context for all activities running in application
mContext = context.getApplicationContext();
}
@chetangiridhar
chetangiridhar / get_phonebooks.py
Last active December 11, 2015 05:19
CallHub API: Get list of Phonebooks
import requests
url = "https://api.callhub.io/v1/phonebooks/"
headers = {"Authorization": "Token <YOUR_API_KEY>"}
r = requests.get(url, headers=headers)
print r,r.text
@chetangiridhar
chetangiridhar / create_contact_to_phonebook.py
Created December 10, 2015 17:10
CallHub API: Add Contact to given Phonebook
import requests
url = "https://api.callhub.io/v1/contacts/"
data = {"contact":"+11234567891","phonebook":"https://api.callhub.io/v1/phonebooks/123456/", "first_name":"Chetan"}
headers = {"Authorization": "Token <YOUR_API_KEY>"}
r = requests.post(url, data=data, headers=headers)
print r, r.text
@chetangiridhar
chetangiridhar / get_contacts.py
Created December 10, 2015 17:07
CallHub API: Get Contacts
import requests
url = "https://api.callhub.io/v1/contacts/"
headers = {"Authorization": "Token <YOUR_API_KEY>"}
r = requests.get(url, headers=headers)
print r, r.text