Skip to content

Instantly share code, notes, and snippets.

antarr antarr

Block or report user

Report or block antarr

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
@antarr
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
View measurements_controller.rb
class Api::MeasurementsController < ApplicationController
skip_forgery_protection
def index
measurements = Measurement.all
render json: measurements
end
def create
if measurement = Measurement.create measurement_params
@antarr
antarr / error.txt
Last active Nov 8, 2018
using factory_bot traits
View error.txt
FactoryBot::AssociationDefinitionError: Self-referencing association 'notification_eventable' in 'property'
View prepare.sh
chef gem install knife-solo
knife solo init sonar && cd sonar
knife solo prepare antarrbyrd@35.185.84.6
knife solo bootstrap antarrbyrd@35.185.84.6
knife solo cook antarrbyrd@35.185.84.6
@antarr
antarr / gist:108cc0f083a6b8648fe0d0dcfcaeec44
Last active Mar 14, 2017
Installing SonarQube + Mysql + Caddy
View gist:108cc0f083a6b8648fe0d0dcfcaeec44
# Install MySql then Sonar
https://gist.github.com/rasheedamir/11460beef67bc6b58d61
sudo apt-get -y update
sudo apt-get install mysql-server
# Connect to MySql
mysql -u root -p
@antarr
antarr / application_controller.rb
Last active Feb 9, 2017
has_secure_token example
View application_controller.rb
# app/controllers/application_controller.rb
class ApplicationController < ActionController::API
before_action :authenticate
protected
def render_unauthorized(status: 401, message: 'Unauthorized')
render json: { errors: Array.wrap(message).map { |msg| { status: status, title: msg } } }, status: status
end
@antarr
antarr / Dockerfile
Last active Nov 23, 2015
CentOS 6.6 with Ruby 2.2.3
View Dockerfile
FROM centos:6.6
RUN yum update -y
RUN yum install git openssl-devel openssh-server sudo openssl readline-devel readline zlib-devel zlib libxml2-devel libxml2 libxslt-devel libxslt nginx tar gcc libaio libaio-devel -y
RUN rpm -Uvh https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-12.5.1-1.el6.x86_64.rpm
RUN sed -i -e "s/Defaults requiretty.*/ #Defaults requiretty/g" /etc/sudoers
RUN mkdir -p /var/run/sshd
RUN useradd -m -u 1000 -G wheel deploy && echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/wheel
@antarr
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)
else
View MainWindow.xaml
<Window x:Class="TicTacToe.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Tic-Tac-Toe" Height="378.388" Width="476.493">
<Grid VerticalAlignment="Top" ShowGridLines="True" Height="336" Margin="10,10,2,-20">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
View MainWindow.xaml.cs
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace TicTacToe
{
/// <summary>
/// Author: Antarr Byrd
/// When: Fall 2012
/// Where: Texas Southern Univeristy
You can’t perform that action at this time.