Skip to content

Instantly share code, notes, and snippets.

View sicktastic's full-sized avatar
:octocat:
I may be slow to respond.

Anthony Lee sicktastic

:octocat:
I may be slow to respond.
View GitHub Profile
@sicktastic
sicktastic / Vagrantfile
Created June 18, 2014 15:36
Vagrantfile example for Thrive
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "192.168.33.21"
class Animal
def run
puts 'running'
end
end
Animal.new.run #=> running
class Wolf < Animal
def follow_pack
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@sicktastic
sicktastic / slack_delete.rb
Created December 28, 2015 03:15 — forked from jamescmartinez/slack_delete.rb
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@sicktastic
sicktastic / factories.rb
Last active August 11, 2016 21:58
Simple feature spec where User creates student record
FactoryGirl.define do
factory :student do
first_name "Doctor"
last_name "Who"
story "Doctor Who is a British science-fiction television programme produced by the BBC since 1963."
end
end
@sicktastic
sicktastic / donation_controller.rb
Created May 11, 2016 06:08
Donation controller and payment model that accepts one time or recurring donations through Stripe.
class DonationsController < ApplicationController
def create
@customer = Customer.find_or_create_by_email(params[:stripeEmail], params[:stripeToken], params[:stripeName])
new_payment
if @payment.save && @payment.charge
@payment.delay_until(1.minutes.from_now).email_payer
redirect_to page_path('thanks')
end
rescue Stripe::CardError => e
flash[:error] = e.message
@sicktastic
sicktastic / salesforce.rb
Created May 11, 2016 06:22
Using Restforce Gem to connect Rails with Salesforce platform.
class Salesforce
include Singleton
def restforce
@client ||= \
Restforce.new :oauth_token => ENV['SALESFORCE_OAUTH'],
:refresh_token => ENV['SALESFORCE_REFRESH_TOKEN'],
:instance_url => ENV['SALESFORCE_INSTANCE_URL'],
:client_id => ENV['SALESFORCE_CLIENT_ID'],
:client_secret => ENV['SALESFORCE_SECRET']
@sicktastic
sicktastic / font_awesome_link.html.erb
Created May 12, 2016 15:04
Getting tired of forgetting this in memory.
@sicktastic
sicktastic / good_rspec.rb
Created May 14, 2016 02:24
Sources from Good RSpec
# correct
describe User do
let (:user) { User.new }
context "when name is empty" do
it "should not be valid" do
expect(user.valid?).to be_false
end
it "should not save" do
@sicktastic
sicktastic / localization.py
Last active May 23, 2016 03:08
Localization calculation
def localize(colors,measurements,motions,sensor_right,p_move):
# initializes p to a uniform distribution over a grid of the same dimensions as colors
def sense(p, colors, measurement):
aux = [[ 0.0 for row in range(len(p[0]))] for col in range(len(p))]
s = 0.0
for i in range(len(p)):
for j in range(len(p[i])):