Skip to content

Instantly share code, notes, and snippets.

View kathgironpe's full-sized avatar

Katherine Giron Pe kathgironpe

  • SEA
  • 15:50 (UTC +08:00)
View GitHub Profile
@mpouleijn
mpouleijn / shared_example.rb
Created July 25, 2012 07:41
Minitest shared example
class MiniTest::Spec
def self.shared_examples
@shared_examples ||= {}
end
end
module MiniTest::Spec::SharedExamples
def shared_examples_for(desc, &block)
MiniTest::Spec.shared_examples[desc] = block
end
@schmurfy
schmurfy / gist:3199254
Created July 29, 2012 14:33
Install pandoc Mac OS X 10.8
# Install MacTex: http://mirror.ctan.org/systems/mac/mactex/mactex-basic.pkg
$ sudo chown -R `whoami` /usr/local/texlive
$ tlmgr update --self
$ tlmgr install ucs
$ tlmgr install etoolbox
# Install pandoc view homebrew
@kathgironpe
kathgironpe / ruby-1.9-tips.rb
Created August 11, 2012 16:15 — forked from igrigorik/ruby-1.9-tips.rb
Ruby 1.9 features, tips & tricks you may not know about...
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@ojii
ojii / index.html
Created August 14, 2012 13:40
phantomjs qunit
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>QUnit Example</title>
<link rel="stylesheet" href="/qunit.css">
</head>
<body>
<div id="qunit"></div>
<script src="/qunit.js"></script>
@kathgironpe
kathgironpe / es_install.md
Created September 6, 2012 05:43
Elasticsearch Installation

#Debian Option 1

aptitude update
aptitude install openjdk-7-jre-headless

mkdir ~/src && cd ~/src
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.9.deb
dpkg -i elasticsearch-0.19.9.deb

#Ubuntu/ Debian Option 2

@tsmango
tsmango / deploy.rb
Last active November 6, 2015 21:22
Rails Rumble 2013 - Official Linode StackScript - Capistrano Deployment Recipe
require 'bundler/capistrano'
# This capistrano deployment recipe is made to work with the optional
# StackScript provided to all Rails Rumble teams in their Linode dashboard.
#
# After setting up your Linode with the provided StackScript, configuring
# your Rails app to use your GitHub repository, and copying your deploy
# key from your server's ~/.ssh/github-deploy-key.pub to your GitHub
# repository's Admin / Deploy Keys section, you can configure your Rails
# app to use this deployment recipe by doing the following:
@jrochkind
jrochkind / Explanation.md
Created October 15, 2012 17:19
Truncating html with nokogiri, with/without Rails

Rails has a handy truncate helper (which is actually mostly a method added to String ), but it warns you it's not safe to use on html source, it'll cut off end tags and such.

What if you want an HTML safe one? There are a variety of suggested solutions you can google, none of which were quite robust/powerful enough for me.

So I started with my favorite, by Andrea Singh, using nokogiri.

But:

  • I modified it to not monkey-patch Nokogiri, but be a static method instead (sadly making already confusing code yet more confusing, but I didn't want to monkey patch nokogiri)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/home/travis/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb
checking for vm_core.h... no
checking for vm_core.h... no
Makefile creation failed
**************************************************************************
No source for ruby-1.9.3-p327 provided with debugger-ruby_core_source gem.
**************************************************************************
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
end
@amatsuda
amatsuda / deploy.rb
Created November 15, 2012 06:55
perform precompile only when any of the asset files has changed since the last deploy
# do not shallow_clone from Git repo
namespace :deploy do
namespace :assets do
# perform precompile only when any of the asset files has changed since the last deploy
task :precompile, :roles => :web, :except => {:no_release => true} do
from = source.next_revision(current_revision)
asset_changing_files = ['vendor/assets/', 'app/assets/', 'lib/assets', 'Gemfile', 'Gemfile.lock'].select {|f| File.exists? f}
if capture("cd #{latest_release} && #{source.local.log(from)} #{asset_changing_files.join(' ')} | wc -l").to_i > 0