Skip to content

Instantly share code, notes, and snippets.

View manchicken's full-sized avatar
🦀
I pinch.

Mike Stemle manchicken

🦀
I pinch.
View GitHub Profile
@manchicken
manchicken / Results.txt
Last active October 20, 2015 14:16
Inspired by https://gist.github.com/loganlinn/2165297, I want to see just `strtolower()` in an if though, and I wanted to see the results for larger values of `n`
mstemle@mstemle901:~/Desktop$ ./runtests.sh
String length: 512
************************
* if + strtolower *
************************
Time: 0.001159
Memory: 1904
************************
* strcasecmp *
************************
@manchicken
manchicken / stemle_perl.h
Last active December 14, 2015 01:59
Just some C macros for working with Perl internals.
#define SV_STRING(VALUE) newSVpv(VALUE,strlen(VALUE))
#define SV_CARRAY(VALUE,SIZE) newSVpvn(VALUE,SIZE)
#define SV_UINT(VALUE) newSVuv(VALUE)
#define SV_INT(VALUE) newSViv(VALUE)
#define SV_DECIMAL(VALUE) newSVnv(VALUE)
#define SV_UNDEF_VAL newSV(0)
#define SV_UNDEF_REF &PL_sv_undef
#define HASH_STORE_UINT(HASH,KEY,VALUE) hv_store(HASH,KEY,strlen(KEY),SV_UINT(VALUE),0)
#define HASH_STORE_INT(HASH,KEY,VALUE) hv_store(HASH,KEY,strlen(KEY),SV_INT(VALUE),0)
@manchicken
manchicken / study_of_sorting_algorithms.pl
Created August 6, 2013 20:20
This is just a quick little study I did on merge sorting and bubble sorting.
#!/usr/bin/env perl
use strict;use warnings;
use Data::Dumper;
our $copies = 0;
our $compares = 0;
sub merge_sort {
my ($compare, @input) = @_;
@manchicken
manchicken / ends_in_four.pl
Created August 7, 2013 16:03
Was asked this question, it seems like something we should know how to do.
#!/usr/bin/env perl
use strict; use warnings;
if (scalar(@ARGV) != 1) {
die "Usage: $0 INTEGER";
}
my $in = $ARGV[0];
if ($in !~ m/^-?[0-9]+$/) {
die "Usage: $0 INTEGER (and it really must be an integer)";
@manchicken
manchicken / binary_search.pl
Created August 8, 2013 04:29
This is just a simple binary search algorithm with proof.
#!/usr/bin/env perl
use strict;use warnings;
use POSIX qw/ceil/;
use Test::More tests => 15;
sub find_last_name {
my ($needle, @haystack) = @_;
# ASSUMING SORTED!
@manchicken
manchicken / stock_prices_in_time.pl
Created August 8, 2013 22:04
Here's a simple little algorithm I found in a piece of practice homework from some college course.
#!/usr/bin/env perl
use strict; use warnings;
use Test::More tests => 6;
my @prices = qw/2 3 3 4 3 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1/;
# Rules:
# 1. @prices' indices are seconds
# 2. @prices' values are dollars for a stock
@manchicken
manchicken / simple_binary_tree.pl
Created August 12, 2013 17:17
Binary tree with balance method
#!/usr/bin/env perl
use strict;use warnings;
use Test::More tests => 4;
use Data::Dumper;
{
package Node;
sub compare {
@manchicken
manchicken / tag_cloud.html
Created August 15, 2013 22:29
A very simple tag cloud generator
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Word Cloud</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Felipa);
body {
margin: 0px;
@manchicken
manchicken / Koding.pm
Created August 19, 2013 21:16
PLEASE NOTE: koding.com VMs are now able to install more sane environments. This is just a way of demonstrating now I used to do it way back upon launch: http://goo.gl/wqi0B3
# ~/Sites/WEBSITENAME/website/lib/Koding.pm
use strict;use warnings;
package Koding;
{
package KodingPaths;
use FindBin ('$Bin');
sub _koding_get_home {
@manchicken
manchicken / configure_perl.sh
Last active December 21, 2015 07:49
PLEASE NOTE: koding.com VMs are now able to install more sane environments. This is just a way of demonstrating now I used to do it way back upon launch. http://goo.gl/Ox6KXw
#!env sh
# Make the local folder
mkdir $HOME/local
# Set up your PERL5LIB
echo 'export PERL5LIB="$HOME/local/lib64/perl5:$HOME/local/share/perl5"' >> $HOME/.bash_profile
echo -e "o conf makepl_arg PREFIX=$HOME/local\no conf make_install_arg PREFIX=$HOME/local\no conf commit\nexit\n" |
cpan