Skip to content

Instantly share code, notes, and snippets.

View csuhta's full-sized avatar
🔮
Afloat in the multiverse

Corey Csuhta csuhta

🔮
Afloat in the multiverse
View GitHub Profile
module VarAccessor
Sass::Script::Functions.send :include, self
def self.variables
@variables ||= {}
end
def self.set(values = {})
variables.merge! values
end
@passcod
passcod / markup.html
Created April 30, 2011 04:35
Another way to hide emails from robots
<span id="email">@</span>
@agraves
agraves / application_controller.rb
Created January 26, 2012 07:21
Trace redirects
# Source: http://jkfill.com/2011/05/13/log-which-line-called-redirect_to/
#
# Toss this in ApplicationController and all redirects will generate a log statement
unless Rails.env.production?
def redirect_to(options = {}, response_status = {})
::Rails.logger.error("Redirected by #{caller(1).first rescue "unknown"}")
super(options, response_status)
end
end

Researchers investigating the Rails parameter parsing vulnerability discovered that the same or similar vulnerable code had made its way into multiple other libraries. If your application uses these libraries to process untrusted data, it may still be vulnerable even if you have upgraded Rails. Check your Gemfile and Gemfile.lock for vulnerable versions of the following libraries.

Directly vulnerable libraries

rails

Vulnerable: <= 3.2.10, <= 3.1.9, <= 3.0.18, <= 2.3.14

Fixed: 3.2.11, 3.1.10, 3.0.19, 2.3.15

multi_xml

@0xabad1dea
0xabad1dea / banned.h
Last active December 27, 2015 19:46
banning macros
/* include this file AFTER your standard includes */
/* clang -Weverything -Wno-unused-macros */
/* SIGNED ARITHMETIC IS THE ENEMY. (use "signed" for main, etc.) */
#define int BANNED
/* THESE OTHER THINGS ARE ALSO THE ENEMY. */
#ifdef strcpy
#undef strcpy
#endif
#define strcpy BANNED
#!/usr/bin/env ruby
# Takes a directory and turns music in it to mp3s; deleting originals.
require 'find'
require 'fileutils'
# Find files
files = []
Find.find(ARGV.first) do |file|
@will
will / postgres_types.rb
Created February 17, 2016 18:31
proper postgres types for rails
# config/initializers/postgres_types.rb
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES.tap do |t|
t[:primary_key] = "bigserial primary key"
t[:datetime] = "timestamptz"
t[:timestamp] = "timestamptz"
t[:string] = "text"
end
@danielpunkass
danielpunkass / spamhaus-check.py
Created December 14, 2012 18:18
Spamhaus periodically places some IP addresses back on their "PBL" which leads certain mail exchanges to treat mail originating from the IP address as suspicious. If you run a mail server that ends up on this PBL you'll probably just notice that certain mail stops making it all the way to recipients. This python script checks the block status fo…
#!/usr/bin/python
import os
import sys
import urllib
# Change this to match your mail server's REVERSE static IP address
staticIPAddress = "1.0.0.127"
# Change this to an email address you don't mind sending to and from for the notice alert delivery
@gregbell
gregbell / active_admin.rb
Created February 23, 2012 18:11
Example of changing the utility navigation in the layout (Top right of nav bar)
# This assumes you are using that you are using Active Admin from master.
# You can do this with 0.4.2 but you would need to override the HeaderRenderer instead
# config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
# View a list of all the elements you can override
# https://github.com/gregbell/active_admin/blob/master/lib/active_admin/view_factory.rb
config.view_factory.utility_navigation = MyCustomUtilityNav
@iiska
iiska / db_fixtures_dump.rake
Created December 28, 2011 13:17
Dump Rails db to fixtures
# Original from http://snippets.dzone.com/posts/show/4468 by MichaelBoutros
#
# Optimized version which uses to_yaml for content creation and checks
# that models are ActiveRecord::Base models before trying to fetch
# them from database.
namespace :db do
namespace :fixtures do
desc 'Dumps all models into fixtures.'
task :dump => :environment do
models = Dir.glob(RAILS_ROOT + '/app/models/**.rb').map do |s|