Skip to content

Instantly share code, notes, and snippets.

mshock

  • San Francisco, CA
Block or report user

Report or block mshock

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mshock
mshock / carlton.R
Created Sep 2, 2014
product pipeline algorithm
View carlton.R
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])
View .bash_profile
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 Aug 29, 2015
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)
View delete_app_versions.pl
#! 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) {
View dm_test.rb
#! ruby
require 'sinatra'
require 'data_mapper'
require 'haml'
require 'sinatra/reloader'
debug = true
if debug
@mshock
mshock / codereview.pl
Created Apr 22, 2014
recent code review - problems solved: Ackermann function, integer to roman numeral, atoi, palindrome detection
View codereview.pl
#! perl -w
#######################################################################
#
# Matt Shockley - 3/31/2014
# all work original
#
#######################################################################
use strict;
@mshock
mshock / startpage.html
Created Apr 22, 2014
bspwm start page
View startpage.html
<!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 Mar 27, 2014
recursively retrieve file list and delete files older than 60 days (TODO: add CLI args for age and dirs)
View dirclean.ps1
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 Nov 22, 2013
get number of seconds to sleep for once a day scheduling by hour
View sleepseconds.pl
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 Aug 21, 2013
Julian date number (JDN) to Gregorian calendar date Source: http://aa.usno.navy.mil/faq/docs/JD_Formula.php
View gdate.pl
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 Dec 18, 2015
golf - Pascal's Triangle (34 rows) - 61 chars
View pascal.pl
$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
}
You can’t perform that action at this time.