<commit_before>package main

import (
	"bytes"
	"fmt"
	"log"
	"os"
	"net/http"
	"encoding/json"
)

type LampState struct {
	On					bool		`json:"on"`
	Brightness	int			`json:"bri"`
	Alert				string	`json:"alert"`
	Reachable		bool		`json:"reachable"`
}

type Lamp struct {
	State	LampState	`json:"state"`
}

func baseUrl() (baseUrl string) {
	token := os.Getenv("HUE_TOKEN")
	address := os.Getenv("HUE_ADDRESS")

	return fmt.Sprintf("http://%s/api/%s", address, token)
}

func getLamp(lampId int) (lamp *Lamp, err error) {
	url := fmt.Sprintf("%s/lights/%d", baseUrl(), lampId)
	response, err := http.Get(url)

	if err != nil {
		return
	}

	defer response.Body.Close()

	lamp = new(Lamp)
	err = json.NewDecoder(response.Body).Decode(lamp)

	return
}

func putLamp(lampId int, lamp *Lamp) (err error) {
	url := fmt.Sprintf("%s/lights/%d/state", baseUrl(), lampId)

	marshal, err := json.Marshal(lamp)

	if err != nil {
		return
	}

	request, err := http.NewRequest(http.MethodPut, url, bytes.NewBuffer(marshal))

	if err != nil {
		return
	}

	client := &http.Client{}

	_, err = client.Do(request)

	return
}

func main() {
	lampId := 1

	lamp, err := getLamp(lampId)

	if err != nil {
		log.Fatal(err)
		return
	}

	lamp.State.On = !lamp.State.On

	err = putLamp(lampId, lamp)

	if err != nil {
		log.Fatal(err)
	}
}
<commit_msg>Set token and address on build<commit_after>package main

import (
	"bytes"
	"fmt"
	"log"
	"net/http"
	"encoding/json"
)

var address string
var token   string

type LampState struct {
	On					bool		`json:"on"`
	Brightness	int			`json:"bri"`
	Alert				string	`json:"alert"`
	Reachable		bool		`json:"reachable"`
}

type Lamp struct {
	State	LampState	`json:"state"`
}

func baseUrl() (baseUrl string) {
	return fmt.Sprintf("http://%s/api/%s", address, token)
}

func getLamp(lampId int) (lamp *Lamp, err error) {
	url := fmt.Sprintf("%s/lights/%d", baseUrl(), lampId)
	response, err := http.Get(url)

	if err != nil {
		return
	}

	defer response.Body.Close()

	lamp = new(Lamp)
	err = json.NewDecoder(response.Body).Decode(lamp)

	return
}

func putLamp(lampId int, lamp *Lamp) (err error) {
	url := fmt.Sprintf("%s/lights/%d/state", baseUrl(), lampId)

	marshal, err := json.Marshal(lamp)

	if err != nil {
		return
	}

	request, err := http.NewRequest(http.MethodPut, url, bytes.NewBuffer(marshal))

	if err != nil {
		return
	}

	client := &http.Client{}

	_, err = client.Do(request)

	return
}

func main() {
	lampId := 1

	lamp, err := getLamp(lampId)

	if err != nil {
		log.Fatal(err)
		return
	}

	lamp.State.On = !lamp.State.On

	err = putLamp(lampId, lamp)

	if err != nil {
		log.Fatal(err)
	}
}

{'fraction_non_alphanumeric': 0.1653394008342814, 'fraction_numerical': 0.0007584376185058779, 'mean_word_length': 3.579861111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4058639', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1069, 'n_words': 246}