Skip to content

Instantly share code, notes, and snippets.


antarr antarr

View GitHub Profile
antarr / script.sql
Last active Oct 26, 2021
Fix PrimayKey with existing Refrences
View script.sql
-- Extend timeout for really large datasets
SET statement_timeout = 10000;
SET session_replication_role='replica';
UPDATE legiscan_model_states SET id=43 WHERE abbr='TX';
UPDATE voter_records SET state_id=43 WHERE state_id=54;
SET session_replication_role='original';
antarr /
Created Apr 30, 2020
install ruby
# Install Ruby2.6 from Brightbox APT repository
config.vm.provision "shell", inline: <<-SHELL
apt-get -y install software-properties-common
apt-add-repository -y ppa:brightbox/ruby-ng
apt-get update
apt-get -y install ruby-switch ruby-bundler ruby2.3 ruby2.3-dev
sudo gem install bundler -v 1.16.6
antarr / Vagrantfile
Created Feb 28, 2020
migrate mysql to pg
View Vagrantfile
# frozen_string_literal: true
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config| = 'ubuntu/xenial64' 'forwarded_port', guest: 80, host: 80, auto_correct: true 'forwarded_port', guest: 443, host: 443, auto_correct: true
antarr / expressions.rb
Created Feb 23, 2020
Replacement Regular Expressions
View expressions.rb
# replace double quotes with single quotes as well
# needs to be updated to exclude interopolated strings
antarr / activeadmin.rb
Last active Jul 31, 2019
Active Admin Version Panel
View activeadmin.rb
# lib/ext/activeadmin.rb
module ActiveAdminPaperTrailDetails
def versions
panel 'Versions', class: 'versions' do
table_for resource.versions.order :created_at do
column(:whodunnit) { |v| auto_link User.find_by(id: v.whodunnit) }
column :event
column 'When', :created_at
column 'Changes' do |v|
attributes_table_for v.changeset.to_a do
antarr / Sum of Integer
Created Nov 7, 2014
Write a program to determine the largest sum of contiguous integers in a list.
View Sum of Integer
def largestSum(ns: List[Int]): Int ={
def sum(numbers: List[Int]) = numbers.foldLeft(0)((a,b) => a+ b)
@tailrec def loop(numbers: List[Int], large: Int): Int = numbers match{
case Nil => large
case _ => {
val thisSum = sum(numbers)
if(thisSum > large)
loop(numbers.tail, thisSum)