Skip to content

Instantly share code, notes, and snippets.

View dvdasari's full-sized avatar

DV Dasari dvdasari

View GitHub Profile
lib/tasks/act_celluloid.rake
namespace :act_celluloid do
task :crawl => :environment do
app_ids = get_items
supervisor = Celluloid::SupervisionGroup.run!
supervisor.pool(AppActor, as: :app_actors, size: 10)
futures = []
@dvdasari
dvdasari / gist:7c4662583761baf11001
Created September 9, 2014 02:34
vlad config/deploy.rb
require 'vlad/sidekiq'
task "vlad:deploy" => %w[
vlad:update
vlad:bundle:install
vlad:migrate
vlad:assets:precompile
vlad:sidekiq:restart
vlad:start_app
vlad:cleanup
@dvdasari
dvdasari / gist:6e1ea0e69d0050581fb8
Last active August 29, 2015 14:06
config/initializers/sidekiq.rb
if Rails.env.production?
Sidekiq.configure_server do |config|
config.redis = { :url => 'redis://10.0.WX.YZ:6379/12', :namespace => 'sidekiq' }
end
Sidekiq.configure_client do |config|
config.redis = { :url => 'redis://10.0.WX.YZ:6379/12', :namespace => 'sidekiq' }
end
end
# /etc/init/workers.conf - manage a set of Sidekiqs
# This example config should work with Ubuntu 12.04+. It
# allows you to manage multiple Sidekiq instances with
# Upstart, Ubuntu's native service management tool.
#
# See sidekiq.conf for how to manage a single Sidekiq instance.
#
# Use "stop workers" to stop all Sidekiq instances.
# Use "start workers" to start all instances.
# /etc/init/sidekiq.conf - Sidekiq config
# This example config should work with Ubuntu 12.04+. It
# allows you to manage multiple Sidekiq instances with
# Upstart, Ubuntu's native service management tool.
#
# See workers.conf for how to manage all Sidekiq instances at once.
#
# Save this config as /etc/init/sidekiq.conf then mange sidekiq with:
# sudo start sidekiq index=0
# rails g model Book name:string:index isbn:string:uniq description:text user:references content:string{30}
class CreateBooks < ActiveRecord::Migration
def change
create_table :books do |t|
t.string :name
t.string :isbn
t.text :description
t.references :user, index: true
t.string :content, limit: 30
# rails g model Book name:string:index description:text ‘cost:decimal{5,2}’
class CreateBooks < ActiveRecord::Migration
def change
create_table :books do |t|
t.string :name
t.text :description
t.decimal :cost, precision: 5, scale: 2
t.timestamps
end
# ruby gitsearch.rb
search_term = "elasticsearch"
file_types = "*.rb"
`echo "\n############################" >> search_results.txt`
`echo "Search Term: #{search_term}" >> search_results.txt`
`echo "File Types: #{file_types}" >> search_results.txt`
`echo "############################\n" >> search_results.txt`
<h3>Display Coordinates</h3>
<p id="geo_loc"></p>
<script>
function success(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
output.innerHTML = '<p>Latitude is ' + latitude + '<br>Longitude is ' + longitude + '</p>';
};
@dvdasari
dvdasari / gist:439ce7c1814c2392c3bf
Last active March 23, 2020 12:05
docker commands
1. Create new container
a) docker run -i -t ubuntu /bin/bash
b) docker run --name rails_dev_container -i -t ubuntu ubuntu /bin/bash
The command line flags - i -t provide an interactive shell in the new container
2. Show running docker containers ==> docker ps
3. Show list of current containers ==>
a) docker ps -a (Show all containers, both stopped and running)
b) docker ps -n x (shows the last x containers, running or stopped, ex: docker ps -n 5)