Skip to content

Instantly share code, notes, and snippets.

View rioleo's full-sized avatar

Rio Akasaka rioleo

View GitHub Profile
@rioleo
rioleo / oraldescription.py
Created November 15, 2011 19:08
oraldescription.py
# Last modified November 15, 2011
# Returns the oral description of a set of numbers
def oralDescription(string):
firstchar = string[0]
for i in range(0, len(string), 2):
print "There are", string[i], "of", string[i+1]
oralDescription("112111")
@rioleo
rioleo / eulav-Iterations-Tnega
Created November 8, 2011 02:13
eulav-Iterations-Tnega
# valueIterationAgents.py
# -----------------------
# Licensing Information: Please do not distribute or publish solutions to this
# project. You are free to use and extend these projects for educational
# purposes. The Pacman AI projects were developed at UC Berkeley, primarily by
# John DeNero (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu).
# For more info, see http://inst.eecs.berkeley.edu/~cs188/sp09/pacman.html
import mdp, util
@rioleo
rioleo / calendar
Created October 28, 2011 20:54
Calendar and Slider
<script>
//reset type=date inputs to text
$( document ).bind( "mobileinit", function(){
$.mobile.page.prototype.options.degradeInputs.date = true;
});
</script>
<link rel="stylesheet" href="datepicker/jquery.ui.datepicker.mobile.css" />
<script src="datepicker/jQuery.ui.datepicker.js"></script>
<script src="datepicker/jquery.ui.datepicker.mobile.js"></script>
@rioleo
rioleo / cssmania
Created October 28, 2011 20:36
CSS Mania
#example1 {
-moz-border-radius: 15px;
border-radius: 15px;
}
#example1 {
border-radius: 5px 10px 5px 10px / 10px 5px 10px 5px;
}
#example1 {
@rioleo
rioleo / orientation
Created October 28, 2011 18:22
Orientation
function updateOrientation() {
var contentType = "show_";
switch(window.orientation){
case 0:
contentType += "normal";
break;
case -90:
contentType += "right";
break;
@rioleo
rioleo / titanium-camera
Created October 27, 2011 19:24
Titanium-Camera
win.addEventListener('focus', function(e) {
Titanium.Media.showCamera({
success:function(event)
{
var cropRect = event.cropRect;
var image = event.media;
var data_to_send = {
"file": event.media,
"name": 'camera_photo.png'
@rioleo
rioleo / html5-ls
Created October 27, 2011 19:00
HTML5 Local Storage
<script>
if (!localStorage.pageCounter) { localStorage.setItem('pageCounter',0); }
localStorage.setItem('pageCounter',parseInt(localStorage.pageCounter)+1);
document.write(localStorage.pageCounter);
</script>
@rioleo
rioleo / geolocation-map
Created October 27, 2011 18:49
Geolocation Map
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<article>
<p>Finding your location: <span id="status">checking...</span></p>
</article>
<script>
function success(position) {
var s = document.querySelector('#status');
@rioleo
rioleo / geolocation-alert
Created October 27, 2011 18:43
Simple Geolocation Alert
<script>
function success(position) {
alert(position.coords.latitude);
alert(position.coords.longitude);
}
function error(msg) {
@rioleo
rioleo / Q3
Created October 18, 2011 18:44
Q3
# Add this to the chooseAction in bustersAgent
pacmanPosition = gameState.getPacmanPosition()
legal = [a for a in gameState.getLegalPacmanActions()]
livingGhosts = gameState.getLivingGhosts()
livingGhostPositionDistributions = [beliefs for i,beliefs
in enumerate(self.ghostBeliefs)
if livingGhosts[i+1]]
likelyghostPosition = max(livingGhostPositionDistributions[0].iteritems(), key=operator.itemgetter(1))[0]
minDist = 999