Skip to content

Instantly share code, notes, and snippets.

@mshock
mshock / carlton.R
Created September 2, 2014 21:16
product pipeline algorithm
products=read.csv('stable.csv',header=TRUE)
products = cbind(products, rep(0, dim(products)[1]))
colnames(products)[dim(products)[2]] = 'Unavailable?'
pipeline=read.csv('pipeline.csv', header=TRUE)
pipeline=pipeline[,1:7]
fillLaunchWeeks = function(pipeline){
for(row in c(1:dim(pipeline)[1])){
row.niche = toString(pipeline[,1][row])
row.productType = toString(pipeline[,2][row])
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSICOLORS=ExFxBxDxCxegedabagacad
export PATH=/usr/local/bin:$PATH
export PATH=$PATH:/Users/mshock/AWS/eb/macosx/python2.7
@mshock
mshock / delete_app_versions.pl
Last active August 29, 2015 14:05
Delete all non-running application versions from a specific application in AWS Elastic Beanstalk. (Despite the doc's claim, currently running app versions CAN be deleted so a check is necessary)
#! perl -w
use strict;
use feature 'say';
my $application = $ARGV[0] || 'massdrop-production';
my @app_versions_lines = split /\n/, `/usr/local/bin/aws elasticbeanstalk describe-application-versions --application-name $application`;
my @environment_lines = split /\n/, `/usr/local/bin/aws elasticbeanstalk describe-environments`;
my %running;
for (@environment_lines) {
@mshock
mshock / dm_test.rb
Created May 27, 2014 18:20
sinatra + DM
#! ruby
require 'sinatra'
require 'data_mapper'
require 'haml'
require 'sinatra/reloader'
debug = true
if debug
@mshock
mshock / codereview.pl
Created April 22, 2014 15:50
recent code review - problems solved: Ackermann function, integer to roman numeral, atoi, palindrome detection
#! perl -w
#######################################################################
#
# Matt Shockley - 3/31/2014
# all work original
#
#######################################################################
use strict;
@mshock
mshock / startpage.html
Created April 22, 2014 15:49
bspwm start page
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>start</title>
<link rel="shortcut icon" type="image/png" href="" />
<style type="text/css">
*, * * {
font-family: termsyn !important;
@mshock
mshock / dirclean.ps1
Created March 27, 2014 14:45
recursively retrieve file list and delete files older than 60 days (TODO: add CLI args for age and dirs)
function cleandir($dir) {
$a = Get-ChildItem $dir -filter *.* -recurs
foreach($x in $a)
{
$y = ((Get-Date) - $x.CreationTime).Days
if ($y -gt 60 -and $x.PsISContainer -ne $True)
{$x.Delete()}
}
}
@mshock
mshock / sleepseconds.pl
Created November 22, 2013 16:38
get number of seconds to sleep for once a day scheduling by hour
sub getsleep {
my ($thour) = @_;
return 0 unless $thour;
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst )
= localtime(time);
my $dif = $thour - $hour - $min / 60 - $sec / 3600;
if ( $dif >= 0 ) {
return $dif * 3600;
@mshock
mshock / gdate.pl
Created August 21, 2013 17:55
Julian date number (JDN) to Gregorian calendar date Source: http://aa.usno.navy.mil/faq/docs/JD_Formula.php
sub gdate {
my $jdn = shift;
my $l= $jdn+68569;
my $n= int(4*$l/146097);
$l= int($l-(146097*$n+3)/4);
my $i = int(4000*($l+1)/1461001);
$l= int($l-1461*$i/4+31);
my $j = int(80*$l/2447);
my $k = int( $l - 2447 * $j/80);
$l = int($j/11);
@mshock
mshock / pascal.pl
Last active December 18, 2015 12:19
golf - Pascal's Triangle (34 rows) - 61 chars
$z='1';
$r=$z;
for(0..32){
@d=split' ',$z;
unshift@d,0;
@n=();
while($#d!=-1){
push@n,($d[0]||0)+($d[1]||0);
shift@d
}