Skip to content

Instantly share code, notes, and snippets.

View AbhinavMadahar's full-sized avatar

Abhinav Madahar AbhinavMadahar

View GitHub Profile
@AbhinavMadahar
AbhinavMadahar / 19hz.js
Created January 9, 2022 11:39
19hz shows library
import { parse } from 'node-html-parser';
import fetch from 'node-fetch';
export default async (location) => {
try {
const page = await fetch(`https://19hz.info/eventlisting_${location}.php`);
const parsed = parse(await page.text());
const rows = parsed.querySelector('tbody').childNodes.slice(1).map(tr => tr.childNodes);
const shows = rows
.map(row => row.map(td => td.childNodes.reduce((prev, curr) => prev + curr.rawText, '')))
// You can set the strictness of the test suite by passing "loose", "normal",
// or "severe" as the first command-line argument to this Test class.
// If no level is passed, it defaults to NORMAL.
//
// LOOSE => always warn i.e. don't throw an exception to stop testing on first error
// NORMAL => throw an exception when a requirement is failed and a warning when a suggestion is found
// SEVERE => always throw an exception, treating warnings as errors
enum Strictness {
LOOSE, NORMAL, SEVERE
}
import tensorflow as tf
weights = tf.Variable([1., 2., 3.],tf.float32)
biases = tf.Variable([4., 5., 6.], tf.float32)
x = tf.placeholder(tf.float32)
sess = tf.Session()
linear_model = weights * x + biases
import numpy as np
from random import shuffle
from math import sqrt
sigmoid = lambda z: 1 / (1 + np.exp(-z))
sigmoidprime = lambda z: sigmoid(z) * (1 - sigmoid(z)) # derivate of sigmoid function
def chunk(array, n):
chunks = []
for i in xrange(0, len(array), n):
@AbhinavMadahar
AbhinavMadahar / regress.py
Last active February 5, 2017 03:33
A simple Regression AI
from collections import namedtuple
Point = namedtuple("Point", ["x", "y"]) # Point(1, 2).x == 1 and Point(1, 2).y == 2
mean = lambda values: sum(values) / len(values)
class Regression(object):
def __init__(self, points):
self.slope = 0 # we'll use gradient descent to find this
self.point = Point(0, 0) # we'll use that stat fact to recalculate this
self.learn_from_data_set(points)
// Array with all gpas
const gradeNodes = [document.getElementById('grade1')];
const grades = [];
// Create click event listeners for each gpa
gradeNodes.forEach((gradeNode, i) => {
gradeNode.addEventListener("click", () => {
gradeNodes[i].innerHTML = `<input value="${grades[i]}" id="${i}" />`
});
});
#!/usr/local/bin/python3
# can run a regresion on a set of points
from collections import namedtuple
from random import random, choice
identity = lambda x: x
average = lambda values, key=identity: sum(key(value) for value in values) / len(values)
median = lambda values, key=identity: sorted(values, key=key)[len(values) // 2] # close enough
# import modules needed to send emails
import smtplib
from getpass import getpass
# sends a message to the recipient_email
def send(recipient_email, message):
if not ("@" in recipient_email):
raise Exception("Must have an @ in an email address")
try:

Stalk vibrates when your stocks fall too fast

var Horseman = require('node-horseman');
var request = require("request");
var horseman = new Horseman();
var timesHit = 0;
var title = "Shrek";
var url = "https://en.wikiquote.org/w/api.php?action=parse&page=" + title + "&format=json"
request(url, function(error, responseCode, body) {