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
## 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("
@drusepth
drusepth / hellolleh.rb
Created February 26, 2015 03:00
palindromic hello world
def method_missing x; "Hello World"; end; puts stup; dne; "dlroW olleH"; x gnissim_dohtem fed
def method_missing x
"Hello World"
end
puts stup
dne
"dlroW olleH"
x gnissim_dohtem fed
@drusepth
drusepth / a2a.js
Created March 1, 2015 01:36
automatically a2a everyone with a free a2a price
$('div.answer_count_row.light_gray').filter(function (index, row) {
return $(row).text().split("•")[1].trim() == "Free to Ask";
}).map(function (index, row) {
return $(row).closest('div.WantedAnswerSuggestionRow').find('a.ask_to_answer')[0];
}).click();
@drusepth
drusepth / names.rb
Last active August 29, 2015 14:17
rhyming-renamer
nicks = %w{
lm aji brodes cbgbt dru ek horm ianweller jruby khwain
montgc narada rd reed suroi suscd woodrufb
}
d = File.readlines('dictionary.txt').to_a
puts nicks.map {|nick|
o = nick.downcase!.dup
while (results = d.select{|line| line.chomp.end_with?(nick)}).length == 0 && nick.length > 0
nick = nick[1, nick.length]
end
expected = %w{1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz};
seed = 0;
begin
puts "trying seed #{seed}"
r = Random.new(seed)
throw :nope unless (0..11).to_a.all? {|i| [i+1, "Fizz", "Buzz", "FizzBuzz"][r.rand(4)] == expected[i] }
puts "drusepth: Seed #{seed} will do the job just fine"
rescue
seed += 1