This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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?" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LocationRequest mLocationRequest; | |
protected void stopLocationUpdates(){ | |
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this); | |
} | |
protected void createLocationRequest(){ | |
mLocationRequest = new LocationRequest(); | |
mLocationRequest.setInterval(10000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
OlderNewer