Skip to content

Instantly share code, notes, and snippets.

View spritle's full-sized avatar

Spritle Software spritle

View GitHub Profile
@spritle
spritle / parallel_fetch.rb
Last active December 15, 2015 12:39
Fetch data in parallel using Typhoeus Typhoeus took 0.99148906 seconds Httparty took 3.370132528 seconds
require "json"
# option 1
require "typhoeus"
#option 2
require "httparty"
$url1 = "https://api.twitter.com/1/statuses/user_timeline.json?screen_name=dchelimsky&count=2"
download open ssl for windows: http://www.openssl.org/source/
Reference :
http://www.neilstuff.com/apache/apache2-ssl-windows.htm (for installation)
http://www.napcsweb.com/howto/rails/deployment/RailsWithApacheAndMongrel.pdf (for httpd.conf and ssl.conf & proxy fix)
Sample openssl confi (required to create key file)
# for more info: https://gist.github.com/1120938
@spritle
spritle / mobile_app_sample_code.rb
Created April 26, 2013 17:08
mobile_app_sample_code.rb
require 'rho/rhocontroller'
require 'lib/flow/login_flow'
require 'lib/flow/new_trip_flow'
require 'lib/flow/transfer_detail_flow'
module UHS
# Base controller providing commonly used functionality
class BaseController < Rho::RhoController
end
class UhsController < BaseController
#!/usr/bin/env ruby
# Mails a file using GMail's SMTP Server.
# For illustrative purposes; error checking and testing intentionally omitted for brevity.
#
# Requirements:
# 1) the 'mail' gem must be installed
# 2) a file named 'pw.txt' containing the Google password must be present
# in the current directory.
#
# Ruby versions: tested on 1.9.3, 1.8.7, JRuby

Setting up Ruby, Rails, Nginx, Passenger, PostgreSQL 9 on Ubuntu 12.04 LTS for Windows Azure

Last updated: 12/31/2013

Fix the locale issue

  • Edit /etc/default/locale as sudo.
  • Append LC_ALL="en_US.UTF-8" at the end of the file, save and quit.
  • sudo locale-gen en_US en_US.UTF-8
  • sudo dpkg-reconfigure locales

Install the necessary packages to install rbenv and build Ruby

@spritle
spritle / mail.sh
Created January 24, 2014 12:00
Set mail or mailx from address
echo "Site Down" | mail -r from@foo.com -s "Site Down" to@foo.com
@spritle
spritle / ismysql-alive.sh
Last active January 4, 2016 08:29
MySQL Server Status Monitor
netstat -na | grep LISTEN | grep MYSQL_PORT
if [ $? != 0 ]; then
sudo service mysql start
#send email
fi
#Make the script executable
# $ chmod +x isalive.sh
#Add it to crontab (say every 10 minutes)
undef: 2312 times
user [preauth]: 76 times
ftpuser [preauth]: 74 times
guest [preauth]: 73 times
webmaster [preauth]: 68 times
admin [preauth]: 67 times
oracle [preauth]: 65 times
test [preauth]: 54 times
master [preauth]: 52 times
ftp [preauth]: 51 times
@spritle
spritle / sidekiq-monitor.sh
Created January 18, 2017 10:18
Monitor Sidekiq up or down with Shell Script.
process='sidekiq' # process name, you can use this to monitor any process
project_path="/home/ubuntu/apps/demo/" # This is the one you got to change on your side for your server.
#change it based on your configs.
start_service="bundle exec sidekiq -d -C /home/ubuntu/apps/demo/config/sidekiq.yml -i 0 -P /home/ubuntu/apps/demo/tmp/pids/sidekiq.pid -L /home/ubuntu/apps/demo/log/sidekiq.log"
# Method to simply store last run time in monitor.log file.
function update_last_run() {
current_time=$(date +'%d/%m/%Y %H:%M:%S')