Skip to content

Instantly share code, notes, and snippets.

View strzibny's full-sized avatar
🏠
Working from home

Josef Strzibny strzibny

🏠
Working from home
View GitHub Profile
#!/usr/bin/ruby
#
# This scipt is designed to work with mock 1.2.0+
require 'uri'
require 'shellwords'
class Mock
attr_reader :root
@Ramblurr
Ramblurr / sudoers-vagrant
Created February 18, 2015 15:35
Vagrant sudo permissions for NFS in Fedora.
## drop this in the new file /etc/sudoers.d/sudoers-vagrant
## add add your user to the vagrant group
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD_CHECK = /usr/bin/systemctl status nfs-server
Cmnd_Alias VAGRANT_NFSD_START = /usr/bin/systemctl start nfs-server
Cmnd_Alias VAGRANT_NFSD_APPLY = /usr/sbin/exportfs -ar
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -r -e * d -ibak /etc/exports
%vagrant ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY, VAGRANT_EXPORTS_REMOVE
@samnang
samnang / authlogic_to_devise.rb
Created February 21, 2012 09:17
Migrate Authlogic to Devise
# Change devise encryption strategy to match your existing authentication
# https://github.com/plataformatec/devise/tree/master/lib/devise/encryptors
class MigrateUsers < ActiveRecord::Migration
def self.up
rename_column :users, :crypted_password, :encrypted_password
add_column :users, :confirmation_token, :string, :limit => 255
add_column :users, :confirmed_at, :timestamp
add_column :users, :confirmation_sent_at, :timestamp
@skyebook
skyebook / backup_postgres.sh
Last active April 16, 2016 13:20
Backup OpenShift PostgreSQL Database
#!/bin/bash
# Backs up the OpenShift PostgreSQL database for this application
# by Skye Book <skye.book@gmail.com>
NOW="$(date +"%Y-%m-%d")"
FILENAME="$OPENSHIFT_DATA_DIR/$OPENSHIFT_APP_NAME.$NOW.backup.sql.gz"
pg_dump $OPENSHIFT_APP_NAME | gzip > $FILENAME
@kpiwko
kpiwko / scl_sudo
Created May 7, 2015 06:43
Red Hat SCL Sudo wrapper
#! /bin/sh
# TODO: parse & pass-through sudo options from $@
sudo_options="-E"
scls=$X_SCLS
#available_scls="`scl --list | tr '\n' ' ' | sed 's/ $//'`"
for arg in "$@"
do
case "$arg" in
*\'*)
@paneq
paneq / bench.rb
Last active December 11, 2016 13:00
cost of using exceptions for control flow compared to one SQL statement (ruby 2.1.4, rails 4.1.7, sqlite) for rails-refactoring.com . Development mode executed in rails console.
require 'benchmark'
ActiveRecord::Base.logger = nil
Benchmark.bmbm do |bench|
bench.report("SQL query") do
1000.times { Whatever.count }
end
bench.report("exception hit") do
@francolaiuppa
francolaiuppa / gist:40147b4bc92f576cb09d
Created August 11, 2014 20:17
Amazon S3 CORS Configuration (DANGER: DEVELOPMENT ONLY, NOT MEANT FOR PRODUCTION ENVIRONMENTS)
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
@mattgaidica
mattgaidica / compare.rb
Created June 7, 2012 22:11
Comparing two files via MD5 hash on Amazon S3 using Ruby
require 'digest/md5'
require 'aws/s3'
#set your AWS credentials
AWS::S3::Base.establish_connection!(
:access_key_id => 'XXX',
:secret_access_key => 'XXX'
)
#get the S3 file (object)
@mattgaidica
mattgaidica / status.rb
Created August 9, 2012 21:46
Simple Status Ticker for API Endpoints
require 'HTTParty'
require 'terminal-display-colors'
require 'json'
# set your endpoints!
endpoints = {
"Google" => "http://google.com",
"Twitter" => "http://twitter.com"
}
# seconds to sleep between pings
##
# Parallel test Runner for Rails
#
# This is a spike implementation for multi-process parallel testing with Rails.
# Only works with SQLite3 right now, and doesn't clean up.
#
# Here is an example of how to use it:
#
# ```ruby
# require 'forking_executor'