Skip to content

Instantly share code, notes, and snippets.

View rioleo's full-sized avatar

Rio Akasaka rioleo

View GitHub Profile
@rioleo
rioleo / gist:1241011
Created September 25, 2011 19:25
Accordion
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>
<script>
@rioleo
rioleo / 221-ex1
Created October 13, 2011 18:55
221-ex1
def observe(self, observation, gameState):
"""
Updates beliefs based on the distance observation and Pacman's position.
The noisyDistance is the estimated manhattan distance to the ghost you are tracking.
The emissionModel below stores the probability of the noisyDistance for any true
distance you supply. That is, it stores P(noisyDistance | TrueDistance).
self.legalPositions is a list of the possible ghost positions (you
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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>