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
@sergejmueller
sergejmueller / ttf2woff2.md
Last active March 9, 2024 13:37
WOFF 2.0 – Learn more about the next generation Web Font Format and convert TTF to WOFF2
@jberkus
jberkus / gist:6b1bcaf7724dfc2a54f3
Last active January 7, 2024 21:26
Finding Unused Indexes
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
@robmathers
robmathers / readinglisturls.py
Last active November 16, 2023 21:18
Prints out URLs of items in Safari’s Reading List
#!/usr/bin/env python
import plistlib
from shutil import copy
import subprocess
import os
from tempfile import gettempdir
import sys
import atexit
BOOKMARKS_PLIST = '~/Library/Safari/Bookmarks.plist'
@ttscoff
ttscoff / downunder.rb
Created February 12, 2013 21:21
Possibly the dumbest script ever. Why make this gist public? Why not, I ask you, why not?
#!/usr/bin/ruby
input = STDIN.read
subs = {
" " => " ",
"a" => "ɐ",
"b" => "q",
"c" => "ɔ",
"d" => "p",

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

@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
@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
@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|
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end