Skip to content

Instantly share code, notes, and snippets.

View ParthDesai's full-sized avatar
🏠
Working from home

Parth ParthDesai

🏠
Working from home
View GitHub Profile
@ParthDesai
ParthDesai / net_download
Last active August 29, 2015 14:13
Download http data to file
package main
import (
"bufio"
"net/http"
"os"
"fmt"
)
type Url struct {
package models
type Channel struct {
UserID string `json:"user_id" bson:"user_id"`
OrganizationID string `json:"org_id" bson:"org_id"`
ApplicationID string `json:"app_id" bson:"app_id"`
ChannelData interface{} `json:"channel_data" bson:"channel_data"`
Ident string `json:"ident" bson:"ident"`
}
@ParthDesai
ParthDesai / funcProgramming.go
Last active September 8, 2015 15:51
Functional programming in go
package main
import "fmt"
type predicate func(int) bool
func main() {
r := filter([]int{1, 2, 3, 4}, func(x int) bool {
return x%2 == 0
})
@ParthDesai
ParthDesai / Mocha test demo
Created September 21, 2015 04:22
A sample test using mocha and chai. To execute, add it into your directory and make sure file name contains a string "test".
'use strict';
var chai = require('chai');
var expect = chai.expect;
describe('Array', function() {
describe('#indexOf()', function () {
it('should return -1 when the value is not present', function () {
expect([1,2,3].indexOf(5)).to.equal(-1);
package shared
type Args struct {
A, B int
}
type Quotient struct {
Quo, Rem int
}
package shared
type Arith interface {
Multiply(args *Args, reply *int) error
Divide(args *Args, quo *Quotient) error
}
package main
import (
"shared" //Path to the package contains shared struct
)
// Every method that we want to export must have
// (1) the method has two arguments, both exported (or builtin) types
// (2) the method's second argument is a pointer
// (3) the method has return type error
package main
import (
"errors"
"log"
"net"
"net/http"
"net/rpc"
"shared" //Path to the package contains shared struct
package main
import (
"errors"
"log"
"net"
"net/rpc"
"shared" //Path to the package contains shared struct
)
package main
import (
"fmt"
"log"
"net/rpc"
"shared" //Path to the package contains shared struct
)