<commit_before>package sysfs

/*
#include <fcntl.h>
#include <poll.h>
#include <stdlib.h>
#include <stdio.h>

// stolen from https://developer.ridgerun.com/wiki/index.php?title=Gpio-int-test.c
#define MAX_BUF 64

struct interrupt {
  int result;
  int value;
};

// https://www.kernel.org/doc/Documentation/gpio/sysfs.txt

// when timeout_ms is -1 wait forever
// returns 1 on an event 0 on timeout -1 on error (like poll)
struct interrupt interrupt_poll(int fd, int timeout_ms) {
  struct pollfd fds[1];
  struct interrupt i[1];

  fds[0].fd = fd;
  fds[0].events = POLLPRI;

  i[0].result = poll(fds, 1, timeout_ms);
  if (fds[0].revents & POLLPRI) {
    char buf[MAX_BUF];
    lseek(fd, 0, SEEK_SET);
    read(fd, &buf, MAX_BUF);
    i[0].value = atoi(buf);
    printf("\nPoll result: %d, Read val: %d\n", i[0].result, i[0].value); // leaving this in until rangefinder is fixe
    // also this will need to make it to github
  }

  return i[0];
}

int c_read(int fd) {
  char *buf[MAX_BUF];
  read(fd, buf, MAX_BUF);
}
*/
import "C"

import (
	"fmt"
	"github.com/fraburnham/gpio"
	"os"
	"time"
)

func validEdge(edge string) bool {
	validEdges := map[string]bool{
		"rising":  true,<commit_msg>Drop debugging<commit_after>package sysfs

/*
#include <fcntl.h>
#include <poll.h>
#include <stdlib.h>
#include <stdio.h>

// stolen from https://developer.ridgerun.com/wiki/index.php?title=Gpio-int-test.c
#define MAX_BUF 64

struct interrupt {
  int result;
  int value;
};

// https://www.kernel.org/doc/Documentation/gpio/sysfs.txt

// when timeout_ms is -1 wait forever
// returns 1 on an event 0 on timeout -1 on error (like poll)
struct interrupt interrupt_poll(int fd, int timeout_ms) {
  struct pollfd fds[1];
  struct interrupt i[1];

  fds[0].fd = fd;
  fds[0].events = POLLPRI;

  i[0].result = poll(fds, 1, timeout_ms);
  if (fds[0].revents & POLLPRI) {
    char buf[MAX_BUF];
    lseek(fd, 0, SEEK_SET);
    read(fd, &buf, MAX_BUF);
    i[0].value = atoi(buf);
  }

  return i[0];
}

int c_read(int fd) {
  char *buf[MAX_BUF];
  read(fd, buf, MAX_BUF);
}
*/
import "C"

import (
	"fmt"
	"github.com/fraburnham/gpio"
	"os"
	"time"
)

func validEdge(edge string) bool {
	validEdges := map[string]bool{
		"rising":  true,
{'fraction_non_alphanumeric': 0.15978456014362658, 'fraction_numerical': 0.01526032315978456, 'mean_word_length': 3.5304878048780486, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '5663673', 'n_tokens_mistral': 928, 'n_tokens_neox': 897, 'n_words': 224}