Skip to content

Instantly share code, notes, and snippets.

@mike1011
mike1011 / toy robot on a table.rb
Last active June 7, 2017 15:57
toy robot on a table created by mike1011 - https://repl.it/Iafm/11
##DIRECTION
class A
def initialize(sym, dx, dy, left, right)
@name, @dx, @dy, @left, @right = sym.to_s, dx, dy, left, right
end
def to_s
@name
end
@mike1011
mike1011 / 00.md
Created September 9, 2017 19:52 — forked from maxivak/00.md
ActiveAdmin custom action

ActiveAdmin custom action

@mike1011
mike1011 / description.markdown
Created March 3, 2018 23:01 — forked from runemadsen/description.markdown
Reverse polymorphic associations in Rails

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

@mike1011
mike1011 / imagemagick-install-steps
Created October 13, 2018 13:10 — forked from rodleviton/imagemagick-install-steps
Installing Image Magick on Ubuntu 14.04
sudo -i
cd
apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y
wget http://www.imagemagick.org/download/ImageMagick-6.8.7-7.tar.gz
tar xzvf ImageMagick-6.8.9-1.tar.gz
cd ImageMagick-6.8.9-1/
./configure --prefix=/opt/imagemagick-6.8 && make
checkinstall
@mike1011
mike1011 / README.md
Created December 9, 2018 00:13 — forked from brunogaspar/README.md
Install wkhtmltopdf on Ubuntu (14.04 64-bit) or (16.04 64-bit)

Install wkhtmltopdf on Ubuntu

This was tested on:

  • Ubuntu 14.04 x64
  • Ubuntu 16.04 x64

Installation

@mike1011
mike1011 / encoding-video.md
Created February 2, 2019 22:54 — forked from Vestride/encoding-video.md
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@mike1011
mike1011 / verify_s3_file.rb
Created February 7, 2019 23:11 — forked from hartfordfive/verify_s3_file.rb
Check if file exists in S3 bucket with Ruby aws-sdk gem
require 'aws-sdk'
s3 = Aws::S3::Resource.new(
region: 'us-east-1',
credentials: Aws::InstanceProfileCredentials.new()
)
bucket = s3.bucket('my-daily-backups')
file = (DateTime.now).strftime("%Y.%m.%d-backup")
if bucket.object(file).exists?
@mike1011
mike1011 / gist:50c0209c4183302e71735197977b64be
Created March 10, 2019 19:19 — forked from mrilikecoding/gist:9520502
RVM Workflow for creating a new Rails Project with Postgres, ready for Heroku
#Make sure heroku toolbelt and rvm are installed
#heroku toolbelt available to download on their site, rvm available via curl
\curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm use "2.1.1"
rvm use --create 2.1.1@project
gem install rails
#if using postgres (good for heroku) pass argument to 'rails new'
rails new project --database=postgresql
@mike1011
mike1011 / sidekiq_monitoring
Created April 10, 2019 22:56 — forked from ngsmrk/sidekiq_monitoring
Sidekiq queue checking via rails console
stats = Sidekiq::Stats.new
stats.queues
stats.enqueued
stats.processed
stats.failed
@mike1011
mike1011 / puma.monitrc
Created June 8, 2019 00:48 — forked from sudara/puma.monitrc
Example config needed to use monit with puma, monitoring workers for mem.
# this monit config goes in /etc/monit/conf.d
check process puma_master
with pidfile /data/myapp/current/tmp/puma.pid
start program = "/etc/monit/scripts/puma start"
stop program = "/etc/monit/scripts/puma stop"
group myapp
check process puma_worker_0
with pidfile /data/myapp/current/tmp/puma_worker_0.pid