Skip to content

Instantly share code, notes, and snippets.

View t0nylombardi's full-sized avatar
🌮
Eating Tacos and Coding

Anthony Lombardi t0nylombardi

🌮
Eating Tacos and Coding
View GitHub Profile
@t0nylombardi
t0nylombardi / Multiple_file.md
Created September 22, 2017 16:15
Multiple File attachment

Models

Lessons Model

class Lesson < ApplicationRecord
  belongs_to :user
  has_many :attachments, dependent: :destroy
  accepts_nested_attributes_for :attachments
end
@t0nylombardi
t0nylombardi / site-sight.rb
Created July 27, 2017 15:12
Core code for site-sight
class SiteCheckWorker
include Sidekiq::Worker
include Sidetiq::Schedulable
@@max_retries = 3
@@times_retried = 0
@@timeout_interval = 0.5
recurrence { hourly.minute_of_hour(0,5,10,15,20,25,30,35,40,45,50,55) }
def perform
get_sites.each do |site|
begin
@t0nylombardi
t0nylombardi / tmp_6.rb
Created April 19, 2017 14:16
Pixel_fragment
rails g model Pixel ip_address, campaign, content_type, created_at:date ,city, state, user_agent, referral, banner_size
@t0nylombardi
t0nylombardi / tmp_5.rb
Created April 19, 2017 13:23
pixel_frafgment.rb
class Pixel < ActiveRecord::Base
validates_presence_of :ip_address
end
@t0nylombardi
t0nylombardi / tmp_4.rb
Created April 19, 2017 13:22
pixel_fragment_4
# lib/services/locations.rb
module Services
class Locations
require 'net/http'
def self.lookup(ip)
ip_address = ip
url = "http://freegeoip.net/json/#{ip_address}"
@t0nylombardi
t0nylombardi / tmp_3.rb
Created April 19, 2017 13:11
pixel_fragment_3
# lib/services/params.rb
module Services
class Params
require 'active_support/all'
def self.deploy(obj)
@url_obj = obj
if obj.class == ActionController::Parameters
return_new_hash @url_obj
@t0nylombardi
t0nylombardi / tmp_2.rb
Created April 19, 2017 13:08
pixel_fragment.rb
# app/lib/tracker/rack.rb
module Tracker
class Rack
def initialize(app)
@app = app
end
def call(env)
@t0nylombardi
t0nylombardi / tmp.rb
Created April 19, 2017 13:06
pixel_fragment_1
rails g model Pixel ip_address, campaign, content_type, created_at:date ,city, state, user_agent, referral, banner_size
@t0nylombardi
t0nylombardi / Ruby_mailer.md
Last active February 27, 2017 01:04
Ruby Mailer for newbies
  # app/mailers/support_mailer.rb
  
  #
  # The Main Support Emailer
  #
  class SupportMailer < ApplicationMailer
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# aliases
alias zshconfig="atom ~/.zshrc"
alias ohmyzsh="atom ~/.oh-my-zsh"
#reload shell
alias reshell="source ~/.zshrc"
alias g\?="git status"