Skip to content

Instantly share code, notes, and snippets.

View antarr's full-sized avatar
💭
🤷🏾‍♂️

antarr antarr

💭
🤷🏾‍♂️
View GitHub Profile
@antarr
antarr / script.sql
Last active October 26, 2021 23:46
Fix PrimayKey with existing Refrences
BEGIN;
-- 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';
COMMIT;
@antarr
antarr / ruby.sh
Created April 30, 2020 03:22
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
SHELL
@antarr
antarr / Vagrantfile
Created February 28, 2020 14:29
migrate mysql to pg
# frozen_string_literal: true
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/xenial64'
config.vm.network 'forwarded_port', guest: 80, host: 80, auto_correct: true
config.vm.network 'forwarded_port', guest: 443, host: 443, auto_correct: true
@antarr
antarr / expressions.rb
Created February 23, 2020 19:04
Replacement Regular Expressions
# replace double quotes with single quotes as well
# needs to be updated to exclude interopolated strings
=(\s)?["|'](.*)?["|]
=$1'$2
@antarr
antarr / activeadmin.rb
Last active July 31, 2019 17:55
Active Admin Version Panel
# 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
antarr / Sum of Integer
Created November 7, 2014 21:00
Write a program to determine the largest sum of contiguous integers in a list.
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)
else