Skip to content

Instantly share code, notes, and snippets.

View RyanSnodgrass's full-sized avatar

Ryan Snodgrass RyanSnodgrass

View GitHub Profile
@RyanSnodgrass
RyanSnodgrass / csv_generation_with_each_row.rb
Last active August 11, 2016 14:10
local machine test run for memory allocation. using sequel gem
def compile_csv
report = MemoryProfiler.report do
execute_as_user do
CSV.open("dataset_exports/full_export_script_#{@rand}.csv", 'wb') do |csv|
csv << @db.fetch(@query).first.keys
@db.fetch(@query).each do |row|
csv << row.values
end
end
end
@RyanSnodgrass
RyanSnodgrass / resque_in_the_console.rb
Last active August 11, 2016 15:51
Using resque, sequel, and redis - build several jobs that process a csv only 1 at a time in a queue
require 'resque'
class Archive
@queue = :default
def self.perform
puts 'Working will sleep for 5 seconds'
sleep 5
end
end
class AnotherArchive
@db = Sequel.tinytds user: ENV["SQL_SERVER_USERNAME"],
password: ENV["SQL_SERVER_PASSWORD"],
port: ENV["SQL_SERVER_PORT"],
host: ENV["SQL_SERVER_HOST"],
database: ENV["SQL_SERVER_DB"],
timeout: 20
def execute_as_user
user_string = "EXECUTE AS USER='ADND\\rsnodgra';"
@db.synchronize do |conn|
@RyanSnodgrass
RyanSnodgrass / Feedback CGI
Last active August 29, 2015 14:26
Ruby script that accepts web form submissions and sends an email with the parsed params
#!/usr/bin/ruby
# http://ruby.sites.nd.edu/cgi-bin/test.cgi?q=ryan&add=123main&$mandatory=q,add
# WHEN PUSHING TO CGI, UNCOMMENT BEGIN AND THE RESCUE AT BOTTOM OF FILE
# begin
require 'net/smtp'
require 'cgi'
puts "Content-type: text/html\n\n"
# list of starting variables
COLONIAL_GALACTIC_INTERCEPTOR = CGI.new

A couple things

Make sure to include the ruby version of atleast 2.2 in the gemfile and in your development environment for a performance boost. stackoverflow neo4j-rb-slow-queries


Whitelist the 10.0.2.2 network space or you'll get 'cannot render console' error logs

@RyanSnodgrass
RyanSnodgrass / neo.rb
Last active August 29, 2015 14:20
Neo4j install ruby script for a Centos Vagrant machine
neo_download_root = "http://dist.neo4j.org"
neo_edition = "community"
neo_version = "2.2.1"
neo_install_path = "/neo4j"
puts 'installing java sdk 1.7.0'
`sudo yum install java-1.7.0-openjdk -y`
puts 'done installing javasdk'
puts 'Now installing lsof'
`sudo yum install lsof -y`
puts 'changing permissions and directories'
@RyanSnodgrass
RyanSnodgrass / my_install.sh
Last active August 29, 2015 14:19
Vagrant install file for clean post `vagrant up`
echo 'I am running the script in Vagrantfile'
echo 'updating all installed yum packages'
sudo yum -y update
echo 'installing curl if not already'
sudo yum -y install curl
echo 'installing rvm if not already'
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable --rails --autolibs=enable
source /home/vagrant/.rvm/scripts/rvm
@RyanSnodgrass
RyanSnodgrass / Vagrantfile
Last active August 29, 2015 14:15
Ryan's Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@RyanSnodgrass
RyanSnodgrass / guide.js
Last active August 29, 2015 14:09
rough javascript for Huginn
$(document).ready(
function() {
executeFilter()
bindFilterToggleBehavior()
bindTypeaheadSearchBehavior()
// When the user clicks on the banner, redirects to root
$('.dddm-header').click( function() {