Skip to content

Instantly share code, notes, and snippets.

View JVero's full-sized avatar

JVero

View GitHub Profile
@JVero
JVero / dfa.py
Last active April 25, 2018 16:28
import numpy as np
from math import sqrt, log10
from scipy.io import loadmat
from sklearn.linear_model import LinearRegression
from matplotlib import pyplot as plt
import seaborn as sns
"""
This code can be found on GitHub using the link below
https://git.io/vH2um
natures = {
"Adamant":
{"increased": "Attack",
"decreased": "Sp. Atk"},
"Bashful":
{"increased": None,
"decreased": None},
"Bold":
{"increased": "Defense",
"decreased": "Attack"},
package main
import (
"bytes"
"fmt"
"strconv"
"sync"
)
type Matrix struct {
package matrix
import "math"
func Pad(m Matrix) Matrix {
println("old width", m.width)
newDim := int(math.Pow(2, float64(int(math.Log2(float64(m.width-1))+1))))
println(newDim, "dab")
retMat := Empty(newDim, newDim)
for i := range retMat.values {
package main
import "fmt"
func main() {
fmt.Println("This is some sample code")
}
package main
import(
"fmt"
"log"
"golang.org/x/crypto/ssh/terminal"
"bufio"
"os"
"bytes"
)
#include<iostream>
struct GameOfLife {
static const int xdim = 10, ydim = 10;
bool grid[xdim][ydim];
int turns;
int getNeighbors(int x, int y) {
if (x == 0) { // Left edge
if (y == 0) // Top Left Corner
return grid[0][1] + grid[1][1] + grid[1][0];
if (y > 0 && y < ydim-1) // Left Edge
@JVero
JVero / client_test.go
Last active August 2, 2018 18:40
very basic UDP server and client with test. net.Dial creates different addresses even though I set the port to 9000
package client
import (
"fmt"
"testing"
a "../go_server"
)
func TestPort(t *testing.T) {
func TestPort(t *testing.T) {
s := a.CreateServer("9000")
defer s.Close()
go func() {
for {
var buf [512]byte
_, addr, _ := s.ReadFromUDP(buf[0:])
s.WriteToUDP([]byte{1, 3, 3, 4, 5, 6, 4, 65, 4, 6, 4, 6, 4, 6, 3, 5, 3, 5, 5}, addr)
}
}()
import numpy as np
from matplotlib import pyplot as plt
def generate_generic_kernel(bandwidth, kernel_type):
def u(x): return x/bandwidth - 1 # u normalizes the range of the kernel supports between [-1, 1]
kernels = {
'epanechnikov': lambda x: 3/4 * (1 - u(x)**2),
'triangular': lambda x: 1 - np.abs(u(x)),
'knn': lambda x: 1/2
}