This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'bundler' | |
| require 'yaml' | |
| def format(hash) | |
| Hash[hash.keys.map(&:to_s).zip(hash.values)].to_yaml | |
| end | |
| Bundler.load.specs.each do |spec| | |
| puts format({ | |
| name: spec.name, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module PunditExampleGroup | |
| extend ::RSpec::Matchers::DSL | |
| matcher :permit do |action| | |
| match do |policy| | |
| policy.public_send("#{action}?") | |
| end | |
| failure_message do |policy| | |
| "#{policy.class} does not permit #{action} on #{policy.record} for #{policy.user.inspect}." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| export IMAGE_NAME=my_app | |
| CONTAINER_ID=$(docker run -d $IMAGE_NAME bundle $@) | |
| docker logs -f $CONTAINER_ID | |
| docker commit $CONTAINER_ID $IMAGE_NAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" | |
| "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | |
| <head> | |
| <title>Navigator.plugins</title> | |
| </head> | |
| <body> | |
| <script type="text/javascript" charset="utf-8"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Sub | |
| def name_please | |
| self.class.name | |
| end | |
| end | |
| class Super < Sub | |
| end | |
| super_man = Super.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| arr = [{:a => 1}, {:a => 2}, {:a => 3}, {:a => 4}, {:b => 3}, {:b => 4}, {:a => 5}] | |
| # I want to get ... | |
| # | |
| # [ | |
| # {:a => [1,2,3,4]}, | |
| # {:b=> [3,4]}, | |
| # {:a => [5]} | |
| # ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Polls the server for new JSON data at a defined interval. Requests are garunteed to not stack up on each other. | |
| Example Usage: | |
| var poller = $.poller({ | |
| url: function(head){ | |
| var base = '/messages/'; | |
| return (head) ? (base + '?since_id=' + head.result.id) : base; | |
| }, | |
| receive: function(set){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A hacky way to put files in Capistrano with sudoer permissions | |
| def sudo_put(data, target) | |
| tmp = "#{shared_path}/~tmp-#{rand(9999999)}" | |
| put data, tmp | |
| on_rollback { run "rm #{tmp}" } | |
| sudo "cp -f #{tmp} #{target} && rm #{tmp}" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ActiveRecord::Base.connection.execute %{ | |
| UPDATE memberships, accounts | |
| SET memberships.is_owner = true | |
| WHERE memberships.user_id = accounts.owner_id AND memberships.is_user = true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %{Hey I'm a string} | |
| %(Hey I'm another string) | |
| %[Hey its me, yep... another string!] |
OlderNewer