Skip to content

Instantly share code, notes, and snippets.

@movstox
movstox / index.sh
Last active October 31, 2021 16:57
beeple scale
awsctl ps:scale adecco-be-gateway-dev -n 0 -a clock
awsctl ps:scale adecco-be-gateway-dev -n 1 -a clock
awsctl ps:scale $1 -n 0 -a clock
awsctl ps:scale $1 -n 1 -a clock
awsctl ps $1
awsctl ps:scale adecco-be-gateway-prod -n 0 -a clock
awsctl ps:scale adecco-be-gateway-prod -n 1 -a clock
awsctl ps adecco-be-gateway-prod
@movstox
movstox / investigate.rb
Last active August 13, 2021 14:41
BAPP-13560
# params: AV w/o piece (destroy)
{
"utf8"=>"✓",
"_method"=>"patch",
"mode"=>"cal",
"start_date"=>"2021-08-17",
"ovrd"=>"0",
"dr"=>"0",
"volunteers_availability"=>{
"is_approved"=>"true",
@movstox
movstox / README.md
Created April 14, 2021 20:36 — forked from exupero/README.md
Alias a domain to a local port (Mac)

I run a lot of web servers for different projects, all of them on different ports. Generally I start with port 8000 and increment from there as I spin up new servers, but it became tiresome to remember what projects were running on which ports and what the next available port was.

/etc/hosts won't let you specify a port, but a combination of aliasing 127.0.0.1 to 127.0.0.X, forwarding ports from 8000 to 80, and adding the 127.0.0.X IP under an alias in /etc/hosts did work.

This script finds the next available value of X, aliases it with ifconfig, forwards the given port to port 80 with ipfw, and adds a new entry to /etc/hosts that aliases the IP to the domain you want.

Now I can add a server alias with sudo domain-alias funproject 8000, run the web server at 127.0.0.X:8000, and load up http://funproject/ in my browser.

(Because I needed it to work on a Mac, I couldn't use iptables. ipfw seems to work, though its manpage claims it's deprecated and pfctl is the way to go. I wasn't able to figure

@movstox
movstox / irb.rb
Created November 4, 2020 17:37 — forked from joshuapinter/irb.rb
Activate Authlogic in Console
if defined?(ActiveRecord::Base) && defined?(Authlogic)
controller = ApplicationController.new
require 'action_controller/test_case'
controller.instance_variable_set(:@_request, ActionController::TestRequest.new)
controller.instance_variable_set(:@_response, ActionController::TestResponse.new)
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(controller)
end
UserSession.new( User.first )
@movstox
movstox / jquery-ui-datepicker-rails-part3.html.haml
Created September 9, 2020 21:13 — forked from mvilrokx/jquery-ui-datepicker-rails-part3.html.haml
Adding jquery-ui datepicker to rails view with Alternate Field and format
# in your view (HAML + simple_form, simplified for easier reading)
= simple_form_for @bp_reading do |f|
= f.input :recorded_at, :as => :string, :input_html => { :class => 'jquery-ui-date', :value => @bp_reading.try(:recorded_at).try(:strftime,'%m/%d/%Y')}
= f.input :recorded_at, :as => :hidden, :input_html => { :id => 'recorded-at-alt'}
= f.button :submit, :disable_with => "Saving...", :value => "Save"
# in your javascript (coffeescript)
$ ->
$(".jquery-ui-date").datepicker(
altField: "#recorded-at-alt",
@movstox
movstox / config.yml
Created May 7, 2020 20:47 — forked from osulyanov/config.yml
Circle CI workflows config to test and deploy Ruby on Rails application with PostgreSQL database. Test with Rspec, precompile assets then deploy with Capistrano.
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/ruby:2.4.1-node-browsers
environment:
@movstox
movstox / metronom.rb
Created November 19, 2019 02:05
Metronom: evoke smth on
def with_scheduled_ticks(collection, start_in: 0, interval: 1, &block)
return unless block_given?
collection.each.with_index do |el, idx|
yield(el, start_in + idx*interval)
end
end
jobs = %w[job1 job2 job3]
@movstox
movstox / tail_rails_log.rb
Last active November 15, 2019 21:38
Naive log watcher for Rails
# ruby tail_rails_log.rb log/development.log
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'file-tail'
end
puts 'Watching for errors: ' + ARGV[0]
lines_to_catch = 0
@movstox
movstox / app_name_from_heroku.sh
Last active October 20, 2019 21:08
bash: app name from heroku
export APP_NAME=`heroku info | grep Web | grep -Eo 'https://(.+).herokuapp.com' | awk -F[/:] '{split($4,a,"."); print a[1]}'`
@movstox
movstox / fb_group_first_post_stats.rb
Last active November 1, 2019 22:20
scraping public fb group - first post stats
# frozen_string_literal: true
require 'selenium-webdriver'
def look_into(fb_group_url)
return unless block_given?
options = Selenium::WebDriver::Chrome::Options.new(args: ['headless', 'disable-gpu', '--window-size=750,1080'])
driver = Selenium::WebDriver.for :chrome, options: options
driver.get(fb_group_url)