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 / 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 / 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;
View dm_test.rb
#! ruby
require 'sinatra'
require 'data_mapper'
require 'haml'
require 'sinatra/reloader'
debug = true
if debug
@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 .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 / 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])
@mshock
mshock / move_by_size.gs
Last active Aug 29, 2015
backup and delete original files by size in target directory - cleanup reddit wallpaper stash populated by IFTTT
View move_by_size.gs
function wallpaper_cleanup() {
var folder = DriveApp.getFoldersByName("wallpapers").next();
var small_folder = DriveApp.getFoldersByName("small_wallpapers").next();
var files = folder.getFiles();
while (files.hasNext()) {
var file = files.next();
if (file.getSize() < 200000) {
file.makeCopy(small_folder);
file.setTrashed(true);
Logger.log(file.getName() + file.getSize());
@mshock
mshock / default.rb
Last active Aug 29, 2015
chef recipe for basic apache install
View default.rb
package "apache2" do
action :install
end
service "apache2" do
action [ :enable, :start ]
end
execute "mv /etc/apache2/sites-enabled/default-000.conf /etc/apache2/sites-available/default-000.conf.disabled" do
only_if do
View iperf.sh
#!/bin/bash
if ! [ -x "$(type -P iperf)" ]; then
echo "ERROR: script requires iperf"
echo "For Debian and friends get it with 'apt-get install iperf'"
echo "If you have it, perhaps you don't have permissions to run it, try 'sudo $(basename $0)'"
exit 1
fi
if [ "$#" -ne "2" ]; then
You can’t perform that action at this time.