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
#!/usr/bin/ruby
# Dear jruby,
#
# May you never have woes about rounding numbers again.
#
# Sincerely,
# Me
# Constants
@drusepth
drusepth / msn.pl
Created June 27, 2015 20:32
msn poc
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
use LWP::UserAgent;
my ($msn_username, $msn_password) = ('xjessicaxfieryx@hotmail.com', '');
my ($msn_server, $msn_port) = ('messenger.hotmail.com', 1863);
#!/usr/bin/perl
use strict;
use warnings;
use googlescraper;
open TOPICS, "topics.txt";
my @topics = <TOPICS>;
close TOPICS;
my @urls;
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
use LWP::UserAgent;
use LWP::Simple;
my (%_PROGRAM, %_SETTINGS, %_SYSTEM, %_DUMMY);
#
# Usage: ruby score_subreddit.rb <list of subreddits>
#
# Computes the Flesch-Kincaid grade level of the last 25 comments of the given subreddits.
#
# For example:
# > ruby score_subreddit.rb science worldnews funny
# science: 8.33
# worldnews: 9.71
# funny: 5.32
template<class T>
Quaternion<T>::Quaternion()
{
T buffer[C_SIZE] = {0,0,0,0};
memcpy( m_values, buffer, (sizeof(T)*C_SIZE) );
}
template<class T>
Quaternion<T>::Quaternion( const T a, const T b, const T c, const T d )
{
#!/usr/bin/perl
# randinfo.pl
# by Drusepth 10/05/2007
# Purpose:
# When using random numbers in programs, sometimes you want them to be
# actually random. But other times, (for example, if you were coding a
# lottery machine) you would want to know the probability a user would
# hit a jackpot (three consecutive 7s). This program calculates the
@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