Skip to content

Instantly share code, notes, and snippets.

View narath's full-sized avatar

Narath Carlile narath

View GitHub Profile
@narath
narath / README.md
Created September 29, 2022 12:24
Mac Utility: Prevent Citrix Workspace from launching at startup

I only use Citrix occasionally on my Mac. I did not like having it launch at startup. Here's how I stop it from starting at launch time. Derived from this helpful forum post

cd /Library/LaunchAgents
sudo rm com.citrix.*
cd /Library/LaunchDaemons
sudo rm com.citrix.ctx*
@narath
narath / migration.rb
Created September 27, 2021 20:11
Rails Migration to add a default value to created_at and updated_at so COPY_FROM can work
class ChangeRawDiagnosesCreatedAtAndUpdatedAt < ActiveRecord::Migration[5.1]
def change
change_column_default :raw_diagnoses, :created_at, from: nil, to: -> { 'CURRENT_TIMESTAMP' }
change_column_default :raw_diagnoses, :updated_at, from: nil, to: -> { 'CURRENT_TIMESTAMP' }
end
end
@narath
narath / readme.md
Created July 8, 2021 10:35
Deploying Sidekiq to Ubuntu as a systemctl service using capistrano-sidekiq

I struggled to deploy sidekiq to an Ubuntu 20.04 server using the capistrano-sidekiq gem. Here are the steps I took to get it to work

Add to your Gemfile

gem 'sidekiq', '~> 6.2'

Add to the development group of your gemfile

@narath
narath / application.js
Last active February 16, 2021 20:41 — forked from bkeepers/application.js
Get timezone offset from the browser and use it for timezones in Rails
// jquery-cookies retired, moved this to js-cookie which no longer requires jQuery
import Cookies from 'js-cookie'
Cookies.set('tz', (new Date()).getTimezoneOffset());
# quickly commit your obsidian wiki to git
cd ~/Google\ Drive/wiki
git add .
git commit -m "Update"
exit
# It is better to use date_trunc which is supported in Postgresql
volume.experiences %>%
mutate(monthyear = date_trunc("month",date_of_experience)) %>%
group_by(monthyear) %>%
summarize(count=sum(count)) %>%
ggplot(aes(x=monthyear, y = as.integer(count))) +
geom_area(fill="lightblue", color="black") +
labs(x = "Date", y = "# of experiences")
@narath
narath / .aptible.yml
Last active June 13, 2020 16:47
Running Rails on Aptible
before_release:
- bundle exec rake db:migrate
@narath
narath / Capfile
Last active May 3, 2020 22:23
Digital Ocean Rails Droplet deployment with Rails 6 and Capistrano. See https://dev.narath.io/2020/04/19/deploying-rails-6-using-capistrano-to-a-digital-ocean-rails-droplet.html for instructions.
require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require "capistrano/rails"
require "capistrano/bundler"
require "capistrano/rvm"
require "capistrano/puma"
### Keybase proof
I hereby claim:
* I am narath on github.
* I am narath (https://keybase.io/narath) on keybase.
* I have a public key ASCV2IYSNSJtU20wXHEULDadD1EPFt21sJp9ovywBkQfJQo
To claim this, I am signing this object:
@narath
narath / r_create_2x2_table_manually.md
Created July 30, 2019 19:15
R: Create 2x2 table manually
make_2x2 <- function(exp_yes, exp_no, notexp_yes, notexp_no, exposure) {
  as.table(matrix(c(exp_yes, exp_no, notexp_yes, notexp_no), nrow = 2, byrow = TRUE, dimnames = list(c(exposure, paste("No",exposure)), c("Yes","No"))))
}
chisq.test(make_2x2(10,990,100,9900,"Risk"))