Skip to content

Instantly share code, notes, and snippets.

@abarringer
abarringer / xmpp_auth.rb
Created December 5, 2011 14:54
xmpp_auth
#!/usr/bin/env ruby
require 'logger'
require 'rest_client'
$stdout.sync = true
$stdin.sync = true
path = "/var/log/ejabberd/auth.log"
file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
@abarringer
abarringer / create_foriegn_keys.sql
Created September 8, 2011 17:34
create indexes and foriegn keys on mysql db that uses the rails naming method
#drop all indexes in current db that are not primary keys
select distinct concat('drop index ', index_name, ' ON ', table_name, ';')
from information_schema.statistics
where table_schema=DATABASE()
and index_name != 'PRIMARY'
and column_name like '%_id';
#create indexes
select concat('create index idx_',column_name, ' on ', table_name,'(',column_name,');')
from information_schema.columns
@abarringer
abarringer / ejabberd_auth.rb
Created July 15, 2011 18:16 — forked from abloom/ejabberd_auth.rb
ejabberd external authentication in ruby
#!/usr/bin/env ruby
require 'logger'
require 'rest_client'
$stdout.sync = true
$stdin.sync = true
path = "/usr/local/var/log/ejabberd/auth.log"
file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
@abarringer
abarringer / move_sql_users.sql
Created June 8, 2011 20:55
Move MySQL Users with Permissions to New Server
#!/bin/bash
mygrants()
{
mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
'SHOW GRANTS FOR ''', user, '''@''', host, ''';'
) AS query FROM mysql.user" | \
mysql $@ | \
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
}
@abarringer
abarringer / rvm_install.sh
Created June 4, 2011 14:32
RVM Ubuntu Install
#!/bin/bash
#Based on http://railsapps.github.com/installing-rails-3-1.html
cd ~
sudo apt-get -y install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev curl git-core
bash < <(curl -sk https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
@abarringer
abarringer / gist:846621
Created February 27, 2011 22:24
Convert XML to SQLite
require 'rubygems'
require 'sqlite3'
require 'rexml/document'
include REXML
xml =<<XML
<records>
<entry><name>abc</name><qty>3</qty></entry>
<entry><name>def</name><qty>5</qty></entry>
<entry><name>ghi</name><qty>2</qty></entry>
@abarringer
abarringer / Install RVM on Ubuntu
Created November 29, 2010 21:57
This installs all the junk you need to actually get RVM going on ubuntu
sudo apt-get update
#install lot-o-junk
sudo apt-get -y install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev autoconf subversion
#git rvm
curl -L https://get.rvm.io | bash -s stable --ruby
#load rvm
source ~/.rvm/scripts/rvm
@abarringer
abarringer / policy_file_server_tester.rb
Created October 13, 2010 15:24
Policy File Server Checker
#simple adobe policy file checker.
require 'socket'
class PolicyFileServerTester
def self.send_request(ip, port=843, query="<policy-file-request/>\000")
myserver = TCPSocket.open(ip, port)
myserver.send(query, 0)
a = myserver.recv(1000)
myserver.close
#I wanted to do stuff like myserver.plugins.overview.cpu_last_minute this lets me do that.
#Haven't tested the refresh to make sure it works.
#Example
# @server = ScoutServer.new("MyServer")
# puts @server.plugins.overview.disk_capacity
# puts @server.plugins.overview.mem_used
# puts @server.plugins.overview.cpu_last_five_minutes
require 'scout_scout'
How to increase file handles on ubuntu
/etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
#notice bottom line