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 / remove_new_lines.rb
Created Jan 16, 2012
Remove newlines from files
View remove_new_lines.rb
out_file = File.new("/Users/username/column_names-new.csv", "w")
File.open("/Users/username/column_names.csv", "r") do |in_file|
while line = in_file.gets
out_file.write line.tr("\n","")
end
end
View modal_window.js
var modal = {
modalWindow : $('#modalWindow'),
windowMask : $('#mask'),
config: {
// maskEffect : 'fadeToggle',
// maskSpeed : 'fast',
// modalEffect : 'fadeToggle',
// modalSpeed : 'fast'
},
init: function(config) {
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
@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
@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 / 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 / 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$/ }
View get_links.rb
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))
@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
You can’t perform that action at this time.