Skip to content

Instantly share code, notes, and snippets.

Kevin Pheasey kpheasey

Block or report user

Report or block kpheasey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kpheasey
kpheasey / setup.md
Last active Jul 20, 2019
WSL, RVM & RubyMine; ubuntu on windows, bash on windows
View setup.md

Add inbound firewall rule for TCP 2222

  • Windows 10 has 2 new services, SSH Server Proxy and SSH Server Broker which will already be bound to port 22
  • Do not allow public connection on this rule, WSL is not proven safe

ConEmu

Add as cmd startup with bash.exe --login

Install the SSH server and some Rails essentials libraries in bash

sudo apt-get update && sudo apt-get upgrade -y
@kpheasey
kpheasey / iam-policy.json
Created Apr 10, 2018
Rails S3 IAM Policy - manage objects in S3
View iam-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::kp-software"
@kpheasey
kpheasey / 0000_packages.config
Last active Feb 24, 2018 — forked from gcarrion-gfrmedia/0000_packages.config
AWS Elastic Beanstalk Ruby 2.2 Puma Sidekiq
View 0000_packages.config
packages:
yum:
git: []
htop: []
@kpheasey
kpheasey / ark_instance.sh
Last active Jan 31, 2018
DO Ubuntu 14.04 Droplet to ARK Server
View ark_instance.sh
#!/bin/bash
# Updating Ubunut
echo "updating ubunutu... please be patient"
apt-get update && apt-get upgrade -y
echo "installing required packages... please be patient"
apt-get install htop lib32gcc1 -y
# Create steam user if needed
@kpheasey
kpheasey / dropdown.html
Created Nov 13, 2017
ace dropdown widget
View dropdown.html
<li id="download_basket"><a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="ace-icon fa fa-download"></i>
<span class="badge">1</span>
</a>
<ul class="dropdown-menu-right dropdown-navbar dropdown-menu dropdown-caret dropdown-close ui-sortable" id="sortable" style="">
<li class="dropdown-header">
<i class="ace-icon fa fa-file-text-o"></i>
<span class="count">1</span>
Reports in the basket
</li>
@kpheasey
kpheasey / delete_sidekiq_batch.rb
Created Apr 1, 2017
Delete All Sidekiq Batches
View delete_sidekiq_batch.rb
Sidekiq::BatchSet.new.each { |batch| Sidekiq::Batch::Status.new(batch.bid).delete }
@kpheasey
kpheasey / calculate#calculate!.rb
Created Mar 3, 2017
worker method that freezes
View calculate#calculate!.rb
def calculate!
self.with_lock do
Octopus.using(:replica) do
self.class::CALCULATION_METHODS.each { |method| send(method) }
end
self.updated_at = self.calculated_at = Time.now
self.is_calculated = true
self.save!(touch: false)
end
@kpheasey
kpheasey / worker1-process2.txt
Last active Mar 3, 2017
gdb output sidekiq frozen process
View worker1-process2.txt
Thread 22 (Thread 0x7f7e882e2700 (LWP 24112)):
#0 0x00007f7e878f1fdd in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007f7e87dcbd9b in timer_thread_sleep (gvl=0x1ebcf28) at thread_pthread.c:1455
#2 thread_timer (p=0x1ebcf28) at thread_pthread.c:1563
#3 0x00007f7e875ef184 in start_thread (arg=0x7f7e882e2700) at pthread_create.c:312
#4 0x00007f7e878ff37d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
Thread 21 (Thread 0x7f7e7bbf7700 (LWP 24116)):
#0 0x00007f7e878f6c53 in select () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007f7e87dd3c7b in rb_fd_select (n=<optimized out>, readfds=<optimized out>, writefds=<optimized out>,
@kpheasey
kpheasey / gdb_output.txt
Created Jan 31, 2017
sidekiq process freeze
View gdb_output.txt
Thread 22 (Thread 0x7fa34f0b0700 (LWP 12916)):
#0 0x00007fa34e72afdd in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007fa34eba6fbc in ?? () from /usr/lib/x86_64-linux-gnu/libruby-2.3.so.2.3
#2 0x00007fa34e428184 in start_thread (arg=0x7fa34f0b0700) at pthread_create.c:312
#3 0x00007fa34e73837d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
Thread 21 (Thread 0x7fa346635700 (LWP 12937)):
#0 0x00007fa34e72fc53 in select () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007fa34eba67d0 in rb_thread_fd_select () from /usr/lib/x86_64-linux-gnu/libruby-2.3.so.2.3
#2 0x00007fa34ea9edaf in ?? () from /usr/lib/x86_64-linux-gnu/libruby-2.3.so.2.3
View models.rb
class Order < ApplicationRecord
belongs_to :customer
def totals_by_customer
Order.all.pluck(:customer).distinct.map do |customer|
[customer, customer.orders.sum(:total))]
end
end
end
You can’t perform that action at this time.