Skip to content

Instantly share code, notes, and snippets.

View rioleo's full-sized avatar

Rio Akasaka rioleo

View GitHub Profile
@rioleo
rioleo / wrist.pde
Created November 4, 2012 21:03
Wrist-based input
import processing.serial.*;
import ddf.minim.*;
Minim minim;
AudioOutput out;
PluckedString string;
// The fundamental frequency of the string (in Hz)
// Setting this very low (e.g. 2.0) results in
@rioleo
rioleo / index.php
Created October 23, 2012 07:43
index.php
<form action="login.php" method="post">
<label for="foo">Username:</label>
<input type="text" name="username" id="foo">
<label for="bar">Password:</label>
<input type="password" name="password" id="bar">
<input type="submit" value="Login">
</form>
@rioleo
rioleo / login.php
Created October 23, 2012 07:43
login.php
<?php
// A malicious user would be hard-pressed to compromise
// a user's password with crypt because crypt is a one-way
// function, and the malicious user would also need to guess
// the salt, which can be set on an individual-user basis.
$salt = "kr";
// This saved_password would be saved in the database.
$saved_password = crypt('mypassword', $salt);
echo "<p>The saved password is: ".$saved_password."</p>";
@rioleo
rioleo / processeingcamera.pde
Created October 20, 2012 22:03
ProcessingCamera
/**
* oscP5broadcastClient by andreas schlegel
* an osc broadcast client.
* an example for broadcast server is located in the oscP5broadcaster exmaple.
* oscP5 website at http://www.sojamo.de/oscP5
* FINAL FINAL FINAL
*/
import oscP5.*;
import netP5.*;
@rioleo
rioleo / ProcessingForClient
Created October 20, 2012 20:32
ArduinoForClient
/**
* oscP5broadcastClient by andreas schlegel
* an osc broadcast client.
* an example for broadcast server is located in the oscP5broadcaster exmaple.
* oscP5 website at http://www.sojamo.de/oscP5
* FINAL FINAL FINAL
*/
import oscP5.*;
import netP5.*;
@rioleo
rioleo / email_func.php
Created October 10, 2012 03:03
Email Script
function sendmail($email, $name, $title)
{
$to = $email;
$subject = 'Maya Order Confirmation';
$message = 'Hello '.$name.',<br /><br />This email is to confirm your order for the following book from Maya:<br /><br /><strong>'.$title.'</strong><br /><br />Please wait for the next update email which will contain shipping information.';
$headers = 'From: Maya Book Service <info@mayabooks.com>' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'Reply-To: Maya Book Service <mayabooks@mayabooks.com>' . "\r\n" .
@rioleo
rioleo / index.html
Created March 8, 2012 10:07
Furling of pie chart
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<style type="text/css">
svg {
font-size: 14px;
}
@rioleo
rioleo / lexicographic.py
Created November 16, 2011 16:39
lexicographic
def lexicographic(word):
word = list(word)
for i in range(len(word) - 1):
if (ord(word[i]) < ord(word[i + 1])):
k = i
for l in range(len(word)):
if (ord(word[l]) > ord(word[k])):
j = l
word[k], word[l] = word[l], word[k]
@rioleo
rioleo / lexicographic-permutations.py
Created November 16, 2011 16:36
lexicographic-permutations
def permutations(li):
""" Return all permutations of a given list. This function
assumes every element of the list is unique. """
if len(li) <= 1:
yield li
else:
for el in li:
for p in permutations([e for e in li if e != el]):
yield [el] + p
@rioleo
rioleo / permutate.py
Created November 15, 2011 19:26
permutate.py
def permutate(word):
returnList = []
if len(word) == 1:
returnList.append(word)
for pos in range(len(word)):
# Recursively find permutations of the word
# that does not contain the letter in position
permuteList = permutate(word[0:pos] + word[pos+1:len(word)])
# For each of those permutations, add