Skip to content

Instantly share code, notes, and snippets.

View mattpolito's full-sized avatar

Matt Polito mattpolito

View GitHub Profile
@mattpolito
mattpolito / update-ffmpeg-rpi.sh
Last active August 21, 2022 01:28 — forked from enzanki-ars/update-ffmpeg-rpi.sh
Install/Update FFmpeg with hardware acceleration on the Raspberry Pi
#!/bin/bash
# Compile and install/update (or install via Apt) FFmpeg Codecs
# Compile and install/update FFmpeg suite
# Compile with hardware acceleration
# Modified from https://retroresolution.com/compiling-ffmpeg-from-source-code-all-in-one-script/
echo "Begining Installation of FFmpeg Suite"
#Update APT Repository
echo "Updating the APT repository information"
@mattpolito
mattpolito / gist:908483
Created April 7, 2011 19:18 — forked from sparkertime/gist:868498
Senor CrankyPants
/* MrCrankyPants - block users and images from Propane!
* to use, place it in ~/Library/Application Support/Propane/unsupported/caveatPatchor.js (yes, it must be that file name)
*
* Created by ripping code off of https://gist.github.com/825404 and https://gist.github.com/310162
*/
Campfire.MrCrankyPants = Class.create({
options: {
blockedUsers: ['Abe L.', 'George W.'],
usersDisallowedToPostImages: ['Theodore R.'],
class Comment
include MongoMapper::EmbeddedDocument
include Gravatarable
key :name, String
key :email, String
key :url, String
key :body, String
key :created_at, Time
# Delete unnecessary files
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/images/rails.png"
run "rm public/javascripts/prototype.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/controls.js"
# Copy database.yml for distribution use
#!/usr/bin/env ruby
puts "looking for the gems to upgrade..."
gem_info = Struct.new(:name, :version)
to_reinstall = []
Dir.glob('/Library/Ruby/Gems/**/*.bundle').map do |path|
path =~ /.*1.8\/gems\/(.*)-(.*?)\/.*/
name, version = $1, $2
bundle_info = `file path`
to_reinstall << gem_info.new(name, version) unless bundle_info =~ /bundle x86_64/
end
// only outputs if console available and does each argument on its own line
function log() {
if (window && window.console && window.console.log) {
var i, len;
for (i=0, len=arguments.length; i<len; i++) {
console.log(arguments[i]);
}
}
}
# download, from_repo, and commit_state methods swiped from
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
task :routes => :environment do
all_routes = ENV['CONTROLLER'] ? ActionController::Routing::Routes.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : ActionController::Routing::Routes.routes
routes = all_routes.collect do |route|
name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s
verb = route.conditions[:method].to_s.upcase
segs = route.segments.inject("") { |str,s| str << s.to_s }
segs.chop! if segs.length > 1
reqs = route.requirements.empty? ? "" : route.requirements.inspect
{:name => name, :verb => verb, :segs => segs, :reqs => reqs}
# download and git methods swiped from http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
exit!
# When a spammer wants to attack your site, they'll likely send an automated bot
# that will blindly fill out any forms it encounters. The idea of a "honeypot" is that
# you place a hidden field in a form. That's the honeypot. If this field is filled in, then
# it's almost certain to be a spammer (since a normal user wouldn't have even seen the
# field), and the contents of the form can safely be discarded.
# Normally, you would implement a "honeypot" in a Rails app with some combination of a
# special field in a particular form, and then some logic in the corresponding controller that
# would check for content in the "honeypot" field. This is somewhat of an inefficient
# approach, because it requires special code (not DRY), and bots are still going through an