Skip to content

Instantly share code, notes, and snippets.

View kylecorry31's full-sized avatar

Kyle Corry kylecorry31

View GitHub Profile
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/iconsets/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<polymer-element name="my-element">
<template>
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-pages/core-pages.html">
<polymer-element name="my-element">
<template>
<style>
import urllib.request, urllib.parse, json
def getWeatherInfo(zipcode):
"""Takes a zipcode (str) that is passed to Yahoo Weather API and returns
an array of dictionaries and a string in this format:
[current_weather (dict), forecasts (dict), title (str)].
Keys include: day, date, high, low, text, temp.
"""
baseurl = "https://query.yahooapis.com/v1/public/yql?"
import time
import cProfile
def timedcall(fn, *args):
t0 = time.clock()
result = fn(*args)
t1 = time.clock()
return t1-t0, result
def timedcalls(n, fn, *args):
import scala.io._
import scala.xml._
def getWeatherInfo(id: String) = {
val url = "http://weather.yahooapis.com/forecastrss?w=" + id + "&u=f"
val response = io.Source.fromURL(url).mkString
var xmlResponse = XML.loadString(response)
println(xmlResponse \\ "location" \\ "@city", xmlResponse \\ "condition" \\ "@temp", xmlResponse \\ "condition" \\ "@text")
}
# Ask user to think of number between 0 and 100
# Ask if number is n, user enters more or less
# Keep dividing set by 2 until single number left
def guess_number(guess_num, n=10):
numbers = list(range(n+1))
tries = 0
while True:
half = len(numbers)//2
guess = numbers[half]
/*
* Paste into Android project
*/
/**
* Input -> y and z GForce (raw accelerometer data / 9.81)
* Output -> Degrees of rotation around x axis
*/
public double beta(double y, double z){
if(z >= 0){
@kylecorry31
kylecorry31 / LocationDetection.java
Last active August 29, 2015 14:22
Location with Google Play Services for Android.
LocationRequest mLocationRequest;
protected void stopLocationUpdates(){
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}
protected void createLocationRequest(){
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(10000);
@kylecorry31
kylecorry31 / marble_sorter.c
Last active August 29, 2015 14:22
Marble Sorter
#pragma config(Sensor, in1, light, sensorReflection)
#pragma config(Sensor, dgtl1, led, sensorLEDtoVCC)
#pragma config(Motor, port4, hopper, tmotorServoStandard, openLoop)
#pragma config(Motor, port5, sorter, tmotorServoStandard, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
// Good luck reading this....just kidding!!!
#define CLEAR 127
#define WHITE 0
@kylecorry31
kylecorry31 / Robot.java
Last active August 29, 2015 14:22
PID rotation controller for FRC 5112
// Can be called during auto periodic
private boolean rotateToDegrees(int degrees, RobotDrive myRobot, Gyro gyro) {
double rotation = 0;
if (Math.abs(crosstrackError) >= 0.5) {
diffCrosstrackError = ((gyro.getAngle() - degrees) - crosstrackError) / 0.02;
crosstrackError = (gyro.getAngle() - degrees);
intCrosstrackError += crosstrackError * 0.02;
rotation = -kP * crosstrackError - kD * diffCrosstrackError - kI
* intCrosstrackError;
if (rotation > 1)