Skip to content

Instantly share code, notes, and snippets.

View tejainece's full-sized avatar

Ravi Teja Gudapati tejainece

View GitHub Profile
@tejainece
tejainece / marshall_slice_map_in_struct.go
Last active November 12, 2021 10:05
Marshall slice and map members of a struct into JSON in Golang.
package main
import (
"fmt"
"encoding/json"
)
type Data struct {
IntF int
StringF string
@tejainece
tejainece / xbee_send.pde
Created February 16, 2014 18:56
Waspmote v1.1: Broadcast a message using XBee S1 through 802.15.4 protocol.
char* data="Please work! :P";
packetXBee* paq_sent;
uint8_t PANID[2] = {0x33, 0x32};
uint8_t dest_addr[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF};
int i = 0;
void setup() {
xbee802.init(XBEE_802_15_4, FREQ2_4G, NORMAL);
@tejainece
tejainece / embedding_polymorphism.go
Last active August 29, 2015 13:57
Golang: embedding pointer anonymous members
package main
import (
"fmt"
)
type Mammal struct {
Lung string
}
@tejainece
tejainece / Makefile
Last active August 29, 2015 13:57
TinyOS broadcast 802.15.4 compliant messages using non-beacon enabled direct transmission.
COMPONENT=Send_BC_D_N154C
CFLAGS += -I$(shell pwd)/..
# To use the TKN15.4 MAC instead of a platform's default MAC protocol first
# include the TinyOS "Makerules" file as usual ...
include $(MAKERULES)
# ... and then include the TKN15.4 "Makefile.include" file. That's all.
# Hint: type "make <platform> verbose" to see the aggregate include path.
include $(TOSDIR)/lib/mac/tkn154/Makefile.include
@tejainece
tejainece / Makefile
Created March 14, 2014 06:09
TinyOS send point2point 802.15.4 compliant message using non-beacon enabled direct transmission
COMPONENT=Send_p2p_D_N154C
CFLAGS += -I$(shell pwd)/..
# To use the TKN15.4 MAC instead of a platform's default MAC protocol first
# include the TinyOS "Makerules" file as usual ...
include $(MAKERULES)
# ... and then include the TKN15.4 "Makefile.include" file. That's all.
# Hint: type "make <platform> verbose" to see the aggregate include path.
include $(TOSDIR)/lib/mac/tkn154/Makefile.include
@tejainece
tejainece / Makefile
Created March 14, 2014 06:11
TinyOS: Receive 802.15.4 compliant messages that are sent using non-beacon direct transmission.
COMPONENT=Receive_D_N154C
CFLAGS += -I$(shell pwd)/..
# To use the TKN15.4 MAC instead of a platform's default MAC protocol first
# include the TinyOS "Makerules" file as usual ...
include $(MAKERULES)
# ... and then include the TKN15.4 "Makefile.include" file. That's all.
# Hint: type "make <platform> verbose" to see the aggregate include path.
include $(TOSDIR)/lib/mac/tkn154/Makefile.include
@tejainece
tejainece / build_seriallisten15-4.sh
Created March 14, 2014 06:22
TinyOS: Build seriallisten15-4
#!/bin/sh
#build libmote.a
cd ${TOSROOT}/support/sdk/c/sf/
./bootstrap
./configure
make
#build seriallisten15-4.c
cd ${TOSROOT}/apps/BaseStation15.4
@tejainece
tejainece / StreamToString.go
Created April 2, 2014 18:29
Golang: io.Reader stream to string or byte slice
import "bytes"
func StreamToByte(stream io.Reader) []byte {
buf := new(bytes.Buffer)
buf.ReadFrom(stream)
return buf.Bytes()
}
func StreamToString(stream io.Reader) string {
buf := new(bytes.Buffer)
@tejainece
tejainece / CountNotifier.dart
Created April 12, 2014 13:59
Polymer.dart bindings without custom element. In this example, we will only bind using binding delegates.
class CountNotifier extends ChangeNotifier {
int _count = 0;
int get count => _count;
set count(int count) {
_count = notifyPropertyChange(#count, _count, count);
}
}
@tejainece
tejainece / CountNotifier.dart
Created April 12, 2014 14:18
Polymer.dart binding without custom elements. In this example, we will use models.
class CountNotifier extends ChangeNotifier {
int _count = 0;
int get count => _count;
set count(int count) {
_count = notifyPropertyChange(#count, _count, count);
}
}