Skip to content

Instantly share code, notes, and snippets.

@benzittlau
benzittlau / monkey_patch.rb
Created June 2, 2011 19:39
Monkey patch for using default_url_options from the application controller in cucumber tests
#monkey patch to fix the fact that ActionDispatch::Integration::Session blows
#away the ApplicationController default_url_options which are necessary
#for the locale scope to work
module ActionDispatch
module Integration
class Session
def default_url_options
{ :host => host, :protocol => https? ? "https" : "http" }.merge!(ApplicationController.new.default_url_options)
end
end
@softr8
softr8 / gist:1035981
Created June 20, 2011 16:53
Mocking methods at instance level
class Una
def get
"Esta es una prueba"
end
end
dos = Class.new(Una) do
def get
"desde aca"
end
module ActionController
class Base
def self.protect_from_forgery; end
def self.before_filter(args); end
def self.layout(args); end
end
end
RSpec.configure do |config|
config.mock_with :rr
@wrburgess
wrburgess / README.md
Created January 28, 2013 21:41
Spree: Skipping delivery step, but adding back default shipping method and tax calculation

Objective: Skip the delivery step in the Checkout state machine and bring back the ability to add a default shipping method and tax calculation

Approach: Add decorators to the Checkout controller and the Order model (see attached files)

Note: This approach might be better managed by overriding the self.define_state_machine! method of the Checkout model located at app/models/spree/order/checkout.rb. However, this model is rather unstable in the Spree upgrade path and overriding the above classes seems to be simpler to adjust.

@chischaschos
chischaschos / shortest_path_spec.rb
Created October 29, 2013 22:26
dijkstra shortest path in ruby
require 'spec_helper'
SP = ->(graph, from_node, to_node, nodes = Hash.new(0), visited = [], i = 0) {
return nodes[from_node] if from_node == to_node
neighbours = graph[from_node].reject {|k, v| visited.include?(k) }
neighbours.each do |k, v|
if nodes[k] == 0 || nodes[from_node] + v < nodes[k]
nodes[k] = nodes[from_node] + v
@softr8
softr8 / gist:2955680
Created June 19, 2012 18:13
Rails cache wrapper
module MyApp
# See ActiveSupport::Cache::Store for documentation.
module Cache
class << self
def fetch(key, options = {}, &block)
if block_given?
if ActionController::Base.perform_caching && options && options[:expires_in].to_i > 0
Rails.cache.fetch(key, options, &block)
else
yield
@netmute
netmute / Molokai.itermcolors
Created December 2, 2011 16:44
iTerm Molokai Colorscheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.48771023750305176</real>
<key>Green Component</key>
<real>0.48781105875968933</real>
@mattmccray
mattmccray / backbone_helper.coffee
Created October 14, 2010 08:44
Use Backbone.js classes as native CoffeeScript classes
# Backbone CoffeeScript Helpers by M@ McCray.
# Source: http://gist.github.com/625893
#
# Use Backbone classes as native CoffeeScript classes:
#
# class TaskController extends Events
#
# class TaskView extends View
# tagName: 'li'
# @SRC: '<div class="icon">!</div><div class="name"><%= name %></div>'
@loceee
loceee / AdwareExt.py
Last active September 29, 2016 05:20
AdwareRemover - thanks shea
#!/usr/bin/python
"""Identify or remove files known to be involved in Adware/Malware
infection.
Most of the code applies to building a list of malware files. Thus,
both extension attribute and removal handling are included.
Cleans files as a Casper script policy; thus, it expects four total
arguments, the first three of which it doesn't use, followed by
--remove
@zlargon
zlargon / remove_malware.sh
Last active February 15, 2017 15:08
Remove unwanted adware that displays pop-up ads and graphics on your Mac. https://support.apple.com/en-us/HT203987
#!/bin/bash
echo "Remove unwanted adware that displays pop-up ads and graphics on your Mac"
echo "https://support.apple.com/en-us/HT203987"
echo ""
# 1. Downlite, VSearch, Conduit, Trovi, MyBrand, Search Protect, Buca Apps
echo "1. Remove Downlite, VSearch, Conduit, Trovi, MyBrand, Search Protect, Buca Apps"
echo ""
malware[0]="/System/Library/Frameworks/v.framework"
malware[1]="/System/Library/Frameworks/VSearch.framework"