Skip to content

Instantly share code, notes, and snippets.

View gautamrege's full-sized avatar

Gautam Rege gautamrege

View GitHub Profile
@gautamrege
gautamrege / hangman.go
Created April 13, 2020 05:11
Hangman - Part 3 struct and receiver methods
package main
import (
"bufio"
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
"net/http"
@gautamrege
gautamrege / hangman.go
Last active April 13, 2020 05:16
Hangman - Part 4 - interfaces and testing
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"strings"
@gautamrege
gautamrege / hangman.go
Created April 4, 2020 05:55
Hangman Part-2 (get random word)
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"strings"
)
@gautamrege
gautamrege / hangman.go
Last active April 4, 2020 05:55
Hangman - Part 1 (working basic)
package main
import (
"fmt"
"strings"
)
func main() {
word := "elephant"
@gautamrege
gautamrege / sphero.go
Created July 10, 2015 22:38
Gophercon 2015 #hackday - demo with Sphere - make it move to keyboard arrow keys.
package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/keyboard"
"github.com/hybridgroup/gobot/platforms/sphero"
)
@gautamrege
gautamrege / Gemfile.diff
Last active December 28, 2015 22:09
Rails 3 to Rails 4 upgrade explained.
diff --git a/Gemfile b/Gemfile
index 084537c..0a99d96 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,12 +1,12 @@
source 'http://rubygems.org'
-gem 'rails', '3.2.8'
+gem 'rails', '4.0.1'
gem 'sqlite3'
@gautamrege
gautamrege / address.rb
Created October 31, 2013 02:51
Saving Embedded document with :name option
class Address
include Mongoid::Document
field :street, type: String
field :city, type: String
field :state, type: String
field :zipcode, type: String
field :country, type: String
embedded_in :author, name: :permanent_address
@gautamrege
gautamrege / general_entity.rb
Created July 30, 2013 06:25
Mongodb Text index search
class GeneralEntity
include Mongoid::Document
extend Moped::Search # to enable facetted text index search
field :org_name, type: String
# other fields
embeds_one :contact, as: :contactable
index({"contact.state" => 1, # filter with text index
@gautamrege
gautamrege / map_rereduce.js
Last active December 15, 2015 13:39
Map ReReduce and join example
map = function() {
if (this.is_cancelled == false) {
data = { bookings: [ this._id ],
booking_amount: this.booking_amount,
amt_received: 0,
cancellations: 0
}
} else {
data = { bookings: [],
booking_amount: 0,
@gautamrege
gautamrege / mapreduce
Created March 26, 2013 18:03
Map Re-reduce
Started POST "/reports/distributor" for 127.0.0.1 at 2013-03-19 20:28:49 +0530
Processing by ReportsController#distributor as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"0auleqI26KHq7LL373WpzslaGJWy45LMhnPeEpWedoc=", "search"=>{"project_id"=>"5139f91fb9b67dbe3a000004", "distributor_id"=>"", "start_date"=>"07/03/2013 - 00:00 AM", "end_date"=>"19/03/2013 - 23:59 PM"}, "commit"=>"Search"}
MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} (0.7286ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=users selector={"$query"=>{"_id"=>"513f0f9db9b67d884a000002"}, "$orderby"=>{:_id=>1}} flags=[] limit=-1 skip=0 batch_size=nil fields=nil (0.5398ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=organisations selector={"$query"=>{"_id"=>"5139f184b9b67d8e73000001"}, "$orderby"=>{:_id=>1}} flags=[] limit=-1 skip=0 batch_size=nil fields=nil (0.4199ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collectio