Skip to content

Instantly share code, notes, and snippets.

View mmcclimon's full-sized avatar

Michael McClimon mmcclimon

View GitHub Profile
@mmcclimon
mmcclimon / primeSieve.pl
Created August 9, 2012 13:59
A Perl implementation of the Sieve of Eratosthenes to find primes
sub sieve {
my $limit = shift || 1000;
my @list = map {$_ = 1} 0..$limit;
for my $i (2..sqrt($limit)) {
if ($list[$i]) {
for (my $j = $i**2; $j < @list; $j += $i) {
$list[$j] = 0;
}
}
}
@mmcclimon
mmcclimon / grasshoppers.pl
Created February 24, 2013 17:47
An esoteric program.
eval eval '"'.
('['^'+').("\["^
( ')')).('`'|')').("\`"| (
( '.'))).('['^'/').('{'^'[') .
( '\\').'"'.('`'|'-').('`'|'/'). (
( '[')^'(').('['^'/').('{'^"\[").( (
( '`'))|'/').('`'|'&').('{'^('[')).( (
( '['))^'/').('`'|'(').('`'|('%')).( (
( '`'))|'-').'\\'.'\\'.('`'|'.').('['^ (
@mmcclimon
mmcclimon / bash_prompt
Created April 26, 2013 13:19
Git info in my bash prompt
# variables for git info in prompt
bGIT_PROMPT_OPEN=''
bGIT_PROMPT_MIDDLE=''
bGIT_PROMPT_CLOSE=''
bGIT_CURRENT_BRANCH=''
bGIT_CURRENT_SHA1=''
bGIT_CURRENT_STATUS=''
set_ps1_vars() {
local gitdir=`git rev-parse --git-dir 2> /dev/null`
@mmcclimon
mmcclimon / Euler5.py
Last active December 19, 2015 08:49
This file runs in both Ruby and Python...I didn't realize they were quite so similar!
#!/usr/bin/env python
#!/usr/bin/env ruby
# take your pick!
def gcd(a, b):
# greatest common divisor...Euclidian algorithm
while b != 0:
tmp = b
b = a % tmp
a = tmp
@mmcclimon
mmcclimon / mklatex
Created November 4, 2013 23:56
Automatically converts Pandoc Markdown to PDF with live preview, via latexmk.
#!/bin/bash
############################
# CONFIG: Change these as necessary
############################
# pandoc
PANDOC_CMD="pandoc"
PANDOC_OPTS="-s --latex-engine=xelatex"
# latexmk
@mmcclimon
mmcclimon / tweetHighlightedText.html
Created December 10, 2013 20:36
Quick jQuery script to tweet the highlighted text on a page.
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
</head>
<body>
<p>This is the text. You'll need to make sure jQuery is loaded. When
you highlight some text we use some JavaScript to grab it and update
the tweet button.</p>
@mmcclimon
mmcclimon / truthy.rb
Created December 17, 2013 15:56
Port Perl's truthy values to Ruby.
#!/usr/bin/env ruby
class Object
# The following are falsy: false, nil, 0, "", and empty arrays/hashes.
# Anything else falls is truthy. This emulates Perl's truthiness.
def truthy?
if self.nil?
return false
elsif self.is_a? Fixnum
return self != 0
@mmcclimon
mmcclimon / keybase.md
Created July 15, 2015 22:14
Keybase verification

Keybase proof

I hereby claim:

  • I am mmcclimon on github.
  • I am mmcclimon (https://keybase.io/mmcclimon) on keybase.
  • I have a public key whose fingerprint is 0E5B F7AB D4E2 E18C 2E97 724A 2AD7 BC42 D5DC 1BA7

To claim this, I am signing this object:

@mmcclimon
mmcclimon / blank-cv.tex
Created October 3, 2015 20:12
CV template
\documentclass[12pt]{article}
\usepackage[margin=1in,headheight=.5in]{geometry}
\usepackage{fontspec}
\usepackage{titlesec}
\usepackage{array}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchUppercase,%
SmallCapsFeatures={LetterSpace=5.0,Letters = SmallCaps}}
\setmainfont[Numbers={OldStyle}]{Minion Pro}
\titleformat*{\section}{\large}
@mmcclimon
mmcclimon / mto.vim
Created March 2, 2020 00:55
MTO nonsense
let b:mto_open_tag = "<?php "
let b:mto_close_tag = "?>"
" Stolen from https://stackoverflow.com/a/1534347/1824895
function! s:get_visual_selection()
normal! gv"zy
return @z
endfunction
function! s:_one_arg(prompt, php_func_name, add_dollar=0)