Skip to content

Instantly share code, notes, and snippets.

View drusepth's full-sized avatar
💭
hacking away on notebook.ai

Andrew Brown drusepth

💭
hacking away on notebook.ai
View GitHub Profile
@drusepth
drusepth / voice2code.output
Created July 18, 2012 04:29
voice2code demo
Loading voice2code.js ... No errors!
process_speech_input("loop from 1 to 10")
=> Processing: loop from 1 to 10
spoken_code
=> ["loop from 1 to 10"]
generated_code
=> ["for (gpNqkpKMvWYH = 1; gpNqkpKMvWYH <= 10; gpNqkpKMvWYH++) { {{loop_body}} }"]
@drusepth
drusepth / gist:5369782
Created April 12, 2013 05:59
C++ Integer Digit Permutations. Coded this up when I thought I was working with permutable primes rather than circular primes. Thought I'd salvage my time and share it for anyone looking for something similar in the future.
vector<int> digitPermutationsOf(int n) {
vector<int> permutations;
// Convert integer to char array of digits
char digits[16]; // Max 16 digits allowed for ints
int size = sprintf(digits, "%d", n);
// Iterate through the digit array and save each permutation
std::sort(digits, digits + size);
do {
@drusepth
drusepth / bot.rb
Created June 21, 2013 06:30
Ruby markov bot
#!/usr/bin/ruby
require 'cinch' # IRC framework
require 'marky_markov' # Markov chains
# Create persistent markov dictionary to read from
markov = MarkyMarkov::Dictionary.new('thunked', 3)
# Create IRC bot to feed data into markov dictionary
bot = Cinch::Bot.new do
@drusepth
drusepth / output
Created July 6, 2013 06:42
Non-iterative prisoner's dilemma simulated with a basic genetic algorithm
Generation 1
Alice: 0.5
Bob: 0.5
Generation 2
Alice: 0.9136221749087309
Bob: 0.9048452243325479
Generation 3
Alice: 0.7525407199758025
Bob: 0.7001147600768378
Generation 4
## Author: Andrew Brown
## Created: 2014-02-11
## Estimates cos using a Maclaurin series
function void = cosapprox (xrad, acceptable_error)
# Get true cos(xrad) value for error analysis
true_value = cos(xrad);
# Estimate value with Maclaurin series
term_index = 1;
## Author: Andrew Brown
## Created: 2014-02-11
## Estimates ln(x) with Taylor series
function void = taylor_log (x)
# Estimate value with Taylor series
approx = x - 1
tic
for term_index = 1 : 100
approx += ((-1)^term_index)*((x-1)^(term_index+1))/(term_index+1);
@drusepth
drusepth / reader.js
Created March 7, 2014 05:11
sleepsort in disguise
// Create staggered JS events to handle the reading automagically
$.each(words, function (word_index, word) {
setTimeout(function () {
display_word(word, {
'left': left,
'pivot': center,
'right': right
});
}, word_index * WORD_VISIBLE_TIME);
});
@drusepth
drusepth / reader.html
Created March 7, 2014 08:32
Lets you read fluid text at 2-3x your normal speed using ORPs
<html>
<head>
<title>FaS Reader</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Fast as Sanic Reader
var left = $('<span />').attr('id', 'left'),
@drusepth
drusepth / clock.html
Created April 23, 2014 06:14
Pokemon Clock for Chromecast
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
function show_time() {
$('.clock').html('');
$('.clock').css('text-align', 'center');
$('body').css('overflow', 'hidden');
var date = new Date();
eval("