Skip to content

Instantly share code, notes, and snippets.

View shurru's full-sized avatar

Shruthi shurru

  • Oakland, California
View GitHub Profile
@shurru
shurru / ex33 tweak
Last active December 26, 2015 23:09
numbers= []
def loopy(i):
while i<6:
print "at the top of i is %d" %i
numbers.append(i)
i = i+1
print "Numbers now", numbers
print "at the bottom of i is %d" %i
@shurru
shurru / ex35
Last active December 26, 2015 23:18
from sys import exit
def goldroom():
print "this room is full of gold. How much do you take?"
next= raw_input(">")
if "0" in next or "1" in next: #need to find easier way to be selective. range?
how_much= int(next)
else:
@shurru
shurru / ex43
Created October 31, 2013 08:36
Text based game
from sys import exit
from random import randint
class Scene (object): #common things that all the scenes will do
def enter (self):
print "This scene ain't configured yet. Subclass it and implement enter()"
exit (1) #exit when there's problems implementing
class Engine (object):
@shurru
shurru / happynumber
Created November 7, 2013 15:34
If sum of the squares of the digits is 1, it is a happy number, else it's an unhappy number
#Happy Numbers Project
def happynum(num):
b=0
while b!=1:
b= sum(int (i)**2 for i in str(num))
if b==1:
count= 1
else:
count=0
@shurru
shurru / gist:7578087
Created November 21, 2013 08:50
FFT on Arduino
#include <math.h>
int Voice = A0; // select the input pin for the potentiometer
int sensorValue=0;
void setup() {
Serial.begin(115200);
pinMode(Voice, INPUT);
}
import xively
import datetime
import sys
import time
import xml.etree.ElementTree as etree
import numpy
XIVELY_API_KEY= "OXrsK9MwFkcLIJvMRlAouni0TBSYPbT2ZU3tuPpP2uqTZfxi"
XIVELY_FEED_ID= 146826075
def plotSomething():
if epoc.newRecord == False or epoc.fftcheck == True or epoc.plot_check == False or epoc.stop==True:
return
xs = numpy.arange(0, 511)
c.setData(xs, epoc.ys)
uiplot.qwtPlot.replot()
update= epoc.ys[508]
up2= numpy.int32(update)
curl http://127.0.0.1:8000/snippets/
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="robots" content="NONE,NOARCHIVE">
<title>SyntaxError at /snippets/</title>
<style type="text/css">
html * { padding:0; margin:0; }
def savecsv(self):
self.O1save.append(self.ys[508])
self.O1save.append(self.ys[509])
self.O1save.append(self.ys[510])
self.O1save.append(self.ys[511])
self.O2save.append(self.ys2[508])
self.O2save.append(self.ys2[509])
self.O2save.append(self.ys2[510])
self.O2save.append(self.ys2[511])
self.ffto1.append(self.pwr)
def mongoupdate(self):
client= MongoClient('localhost')
# client= MongoClient('128.199.248.15',27017)
db=client.emosis
for i in xrange(0,len(self.O1save)):
post= {"date": self.date[i/4],
"O1": self.O1save[i],
"O2": self.O2save[i],
"fftO1":self.ffto1[i/4],