Skip to content

Instantly share code, notes, and snippets.

Matt Weppler mweppler

Block or report user

Report or block mweppler

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
@mweppler
mweppler / fsmsim.rb
Last active Dec 15, 2015
Fsm Simulator from Udacity CS262 implemented in ruby...
View fsmsim.rb
# FSM Simulation
edges = {
[1, 'a'] => 2,
[2, 'a'] => 2,
[2, '1'] => 3,
[3, '1'] => 3
}
accepting = [3]
@mweppler
mweppler / site-manager.rb
Last active Dec 13, 2015
THIS IS STILL A WORK IN PROGRESS... If this is the first time running site-manager use the --setup switch I got tired of manually setting up a new site that I have to work on. I use Pow for RoR, rack/sinatra apps, static html sites, and proxy to apache via port 81 for anything else. This script makes a few assumptions about your environment, and…
View site-manager.rb
#!/usr/bin/env ruby
###############################################################################
# Required Application Libraries #
###############################################################################
%w{ rubygems optparse ostruct socket yaml }.each { |lib| require lib }
###############################################################################
@mweppler
mweppler / drop_tables.sh
Created Nov 29, 2012
Drop mysql tables in given database
View drop_tables.sh
#!/bin/bash
USER="$1"
PASS="$2"
DB="$3"
if [ $# -ne 3 ]
then
echo "Usage: $0 {MySQL-User-Name} {MySQL-User-Password} {MySQL-Database-Name}"
echo "Drops all tables from a MySQL"
exit 1
View doesTableHaveField.php
<?php
$field = "field";
$hasField = false;
$table = "table";
$connect = @mysql_connect("host","username","password");
if (!$connect) echo "Server error: CONN";
$select_db = mysql_select_db("database");
if (!$select_db) echo "Server error: DB";
$result = mysql_query("SHOW COLUMNS FROM $table");
while ($row = mysql_fetch_array($result))
View get_links.rb
@mweppler
mweppler / rm_svn_dirs.rb
Created Oct 6, 2012
Recursively remove .svn directories for given path
View rm_svn_dirs.rb
#!/usr/bin/env ruby
%w{fileutils}.each { |lib| require lib }
Dir.glob((ARGV[0][-1] == '/') ? ARGV[0] + '**/*' : ARGV[0] + '/**/*', File::FNM_DOTMATCH) { |node| FileUtils.rm_rf node if File.directory?(node) && File.basename(node) =~ /\.svn$/ }
@mweppler
mweppler / mv_videos_and_source.rb
Created Oct 4, 2012
Move files sorted by video/source into same directory
View mv_videos_and_source.rb
#!/usr/bin/env ruby
require 'fileutils'
Dir.glob('/Volumes/Share/Media/Videos/Software\ Training/video/*').each do |file|
fn = File.basename file, File.extname(file)
sd = File.dirname(file) + '/../' + 'source/'
sf = sd + fn + '.zip'
nd = File.dirname(file) + '/../' + fn
(File.exists? nd) ? next : Dir.mkdir(nd)
@mweppler
mweppler / emailer.rb
Created Sep 14, 2012
A ruby emailer
View emailer.rb
# http://ruby-doc.org/stdlib-1.9.3/libdoc/net/smtp/rdoc/Net/SMTP.html
require 'digest/md5'
require 'mime/types'
require 'net/smtp'
require 'optparse'
require 'ostruct'
require 'yaml'
class Emailer
@mweppler
mweppler / flat_file.rb
Created Sep 12, 2012
Incomplete implementation of a flat file storage system.
View flat_file.rb
module FlatFileProperties
def properties(*attributes)
@file_properties = attributes
end
def file_properties
@file_properties
end
end
View crawler.rb
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
def get_anchors_from_html_doc html_doc
# Returns a Nokogiri::XML::NodeSet
html_doc.css('a')
end
You can’t perform that action at this time.