Skip to content

Instantly share code, notes, and snippets.

View yaronsumel's full-sized avatar

Yaron Sumel yaronsumel

View GitHub Profile
--- TLP 1.1 --------------------------------------------
+++ Configured Settings: /etc/default/tlp
TLP_ENABLE=1
TLP_DEFAULT_MODE=AC
TLP_PERSISTENT_DEFAULT=0
DISK_IDLE_SECS_ON_AC=0
DISK_IDLE_SECS_ON_BAT=2
MAX_LOST_WORK_SECS_ON_AC=15
MAX_LOST_WORK_SECS_ON_BAT=15
--- TLP 1.1 --------------------------------------------
+++ Configured Settings: /etc/default/tlp
TLP_ENABLE=1
TLP_DEFAULT_MODE=AC
TLP_PERSISTENT_DEFAULT=0
DISK_IDLE_SECS_ON_AC=0
DISK_IDLE_SECS_ON_BAT=2
MAX_LOST_WORK_SECS_ON_AC=15
MAX_LOST_WORK_SECS_ON_BAT=15
@yaronsumel
yaronsumel / mongoJoin.go
Created March 8, 2017 13:38
mongoJoin left + right golang
type TreeModel struct {
//Comment is the left one
Comment commentModel `bson:",inline"`
User userModel `bson:"user"`
}
func FindPiped(pipes *[]bson.M, tree documents.DocumentTreesInterface) error {
s := mgoSession.Clone()
defer s.Close()
iter := s.DB(db).C(collection).Pipe(*pipes).Iter()
@yaronsumel
yaronsumel / main.go
Created March 2, 2017 17:25
listen for new collection data in mongo + golang
package main
import (
"gopkg.in/mgo.v2/bson"
"time"
"gopkg.in/mgo.v2"
"log"
)
/**
@yaronsumel
yaronsumel / func.go
Last active March 2, 2017 17:25
Listen for new data in mongo + golang
func main(){
model := SomeModel{}
// listen and wait for changes
// block till new data arrived
err := mongo.ListenForNewData(bson.ObjectIdHex("58b84ea573e0b074e4e7a837"),&model)
// free
// do something with the model
}
func ListenForNewData(lastId bson.ObjectId,doc interface{}) error {