Skip to content

Instantly share code, notes, and snippets.

View roberto's full-sized avatar
🍊

Roberto Soares roberto

🍊
View GitHub Profile
# Rails developers have long had bad experiences with fixtures for
# several reasons, including misuse.
#
# Misuse of fixtures is characterized by having a huge number of them,
# requiring the developer to maintain a lot of data and creating dependencies
# between tests. In my experience working (and rescuing) many applications, 80%
# of fixtures are only used by 20% of tests.
#
# An example of such tests is one assuring that a given SQL query with
# GROUP BY and ORDER BY conditions returns the correct result set. As expected,
@hoverlover
hoverlover / active_admin_heroku.rb
Created June 7, 2011 16:35
Rails initializer for using ActiveAdmin with Sass on Heroku
if Rails.env.production?
require 'fileutils'
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets", "admin"))
template_path_one = "#{Gem.loaded_specs['activeadmin'].full_gem_path}/app/assets/stylesheets"
template_path_two = "#{Gem.loaded_specs['activeadmin'].full_gem_path}/lib/active_admin/sass"
old_compile_path = "#{Rails.root}/public/stylesheets/admin"
new_compile_path = "#{Rails.root}/tmp/stylesheets/admin"
Sass::Plugin::remove_template_location template_path_one
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@ordinaryzelig
ordinaryzelig / minitest_spec_expectations.md
Last active December 10, 2022 13:34
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
@MandarinConLaBarba
MandarinConLaBarba / gist:4533303
Last active December 31, 2021 22:24
How to spy on node's require() w/ sinon.js
//If you need to spy or stub the global require function in node.js, don't try to spy on the require function itself..you aren't going //to be successful.
//Instead, spy on the require.extensions object like so:
var spies = {};
spies.require = sinon.spy(require.extensions, '.js');
//Then when you need to assert you can do stuff like:
spies.require.firstCall.args[1].should.include("path/to/some/module");
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 17, 2024 02:53
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@fsouza
fsouza / str.go
Last active December 20, 2015 10:31
package str
func Reverse(input string) string {
return ""
}
@brianloveswords
brianloveswords / git-obliterate
Last active January 24, 2024 12:28
git-obliterate: for removing sensitive files you may have committed from the entire history of the project.
#!/bin/bash
file=$1
test -z $file && echo "file required." 1>&2 && exit 1
git filter-branch -f --index-filter "git rm -r --cached $file --ignore-unmatch" --prune-empty --tag-name-filter cat -- --all
git ignore $file
git add .gitignore
git commit -m "Add $file to .gitignore"
@KidkArolis
KidkArolis / webpack.config.js
Last active October 16, 2023 04:00
Webpack for AMD projects
/**
* Example webpack.config.js for an AMD project (or AMD + CJS mixed project).
* This file should be at the root of your project.
*
* This can then be used in combination with Karma as well
* Just load this file and pass it to karma.webpack key
* (see https://github.com/webpack/karma-webpack#alternative-usage)
*
* This example is a bit extreme. Typically in webpack, you don't need much
* configuration if you have nicely behaving code and work with correctly
@vitorbritto
vitorbritto / add_apache_brew.md
Last active March 4, 2019 10:30
Install Apache with Homebrew

Install Apache with Homebrew

Installing Apache

# Start by stopping the built-in Apache, if it's running, and prevent it from starting on boot.
# This is one of very few times you'll need to use sudo:
sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

# We need to tap homebrew-dupes because "homebrew-apache/httpd22" relies on "homebrew-dupes/zlib"

and install Apache 2.2 with the event MPM, and we'll use Homebrew's OpenSSL library