This file contains 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
def compare_user | |
%w{uid gid comment home shell password}.any? do |att| | |
!@new_resource.send(att).nil? && @new_resource.send(att) != @current_resource.send(att) | |
end | |
end |
This file contains 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
Author.find_by_sql "SELECT * FROM authors INNER JOIN extensions ON authors.id = extensions.author_id GROUP BY extensions.author_id HAVING COUNT(extensions.author_id) > 0" | |
# Had to add the :group key to produce a unique set. | |
# Removing `:include => :extensions` also reduced this from two queries to one. |
This file contains 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(test_helper). | |
-export([riak_test/1]). | |
riak_test(Fun) -> | |
start_riak(), | |
{ok, Riak} = riak:local_client(), | |
Ret = (catch Fun(Riak)), | |
stop_riak(), | |
case Ret of |
This file contains 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 Resources::Assets < Webmachine::Resource | |
def content_types_provided | |
path = request.uri.path | |
@asset = Application.assets[path] | |
if @asset.present? | |
[[@asset.content_type, :to_asset]] | |
else | |
# Better to simply provide a content-type you CAN provide, even if it's not acceptable. | |
# Since the asset is not there, it'll bail anyway at resource_exists? |
This file contains 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 'ffi' | |
require 'jnr-enxio-0.1.jar' | |
module Open | |
extend FFI::Library | |
ffi_lib 'c' | |
attach_function :open, [:string, :int], :int | |
end |
This file contains 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
# Emulates the QuickCheck ?SOMETIMES macro. | |
module Sometimes | |
def run_with_retries(example_to_run, retries) | |
self.example.metadata[:retries] ||= retries | |
retries.times do |t| | |
self.example.metadata[:retried] = t + 1 | |
self.example.instance_variable_set(:@exception, nil) | |
example_to_run.run | |
break unless self.example.exception |
This file contains 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
production: | |
#protocol: http | |
http_port: 8000 | |
pb_port: 8087 | |
http_backend: Excon | |
ssl: true | |
nodes: | |
- | |
host: 10.183.38.200 # prod-riak-r01 | |
- |
This file contains 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 InvoiceFinders | |
def paid | |
klass.find_by_index(:business_paid, "#{owner.key}-true") | |
end | |
def unpaid | |
klass.find_by_index(:business_paid, "#{owner.key}-false") | |
end | |
end |
This file contains 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(bench). | |
-export([run/1]). | |
run(Count) -> | |
Me = self(), | |
timer:tc(fun() -> run(Me, Count) end). | |
run(Me, Count) -> | |
F = spawn(fun() -> worker(Me, Count) end), |
This file contains 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
storing 10000 objects | |
done storing | |
Rehearsal ---------------------------------------------- | |
individual 3.170000 0.250000 3.420000 ( 8.162000) | |
threaded/2 4.780000 0.350000 5.130000 ( 5.546000) | |
threaded/4 5.220000 0.410000 5.630000 ( 3.777000) | |
threaded/8 5.210000 0.430000 5.640000 ( 3.187000) | |
------------------------------------ total: 19.820000sec | |
user system total real |
OlderNewer