Skip to content

Instantly share code, notes, and snippets.

#include <Rcpp.h>
using namespace Rcpp;
double distance(double x, double y) {
double temp = x - y;
return temp * temp;
}
// [[Rcpp::export]]
int bestLeftEdge(NumericVector sorted_values) {
@rudyl313
rudyl313 / gist:1112395
Created July 28, 2011 19:52
Fetching n random members
# this scope is used to select n random members given a max offset
named_scope :n_random, lambda { |n, max_offset|
offset = rand(max_offset + 1)
{:limit => "#{offset}, #{n}"}
}
# This is the method I call from the controller
# all_members and with_avatar are the scopes that hold the where conditions
def self.random_avatar_members(n)
max_offset = [0, self.all_members.with_avatar.count - n].max
2011-07-14T17:48:34+00:00 app[web.1]: Processing GiftsController#show (for 119.63.196.19 at 2011-07-14 10:48:34) [GET]
2011-07-14T17:48:34+00:00 app[web.1]: Parameters: {"action"=>"show", "id"=>"9052", "controller"=>"gifts", "locale"=>"en"}
2011-07-14T17:48:34+00:00 app[web.1]: Rendering template within layouts/gifts
2011-07-14T17:48:34+00:00 app[web.1]: Rendering gifts/show
2011-07-14T17:48:35+00:00 app[web.1]: Completed in 267ms (View: 44, DB: 217) | 200 OK [http://www.lottay.com/gifts/9052?locale=en]
2011-07-14T17:48:35+00:00 app[web.1]: /!\ FAILSAFE /!\ Thu Jul 14 10:48:35 -0700 2011
2011-07-14T17:48:35+00:00 app[web.1]: Status: 500 Internal Server Error
2011-07-14T17:48:35+00:00 app[web.1]: undefined local variable or method `f' for #<NewRelic::Rack::BrowserMonitoring:0x7f3428d9cc28>
2011-07-14T17:48:35+00:00 app[web.1]: /app/vendor/plugins/rpm/lib/new_relic/rack/browser_monitoring.rb:33:in `autoinstrument_source'
2011-07-14T17:48:35+00:00 app[web.1]: /app/.gems/gems/actionpack-2.3.2/lib/a
def self.filter(params)
self.with_cpts(params).with_payers(params).with_mrns(params).
with_classifications(params).with_exception_codes(params).in_date_ranges(params)
end
Started GET "/" for 76.89.178.124 at Sun Jan 30 15:11:14 -0800 2011
Processing by SongsController#index as HTML
Rendered songs/index.haml within layouts/application (23.3ms)
Completed in 29ms
ActionView::Template::Error (Permission denied - /disk1/home/slugs/0e99dc04-f8d6-4ca4-8f9d-f48d8e46a2db/mnt/public/javascripts/.permissions_check.23513335124280.23879.89542):
31: %body
32: =yield
33: - ["soundmanager2","jquery-1.4.2.min","application"].each do |js_file|
34: =javascript_include_tag js_file, :cache => true
var Channel = new Class({
jQueryEach: 'songChannel',
initialize: function(element) {
this.element = element;
},
computeWidth: function(x, scroll, C) {
return Math.floor(scroll/C) + this.unitStep(x - (scroll % C) - 1);
},
var Channel = new Class({
jQuery: 'songChannel',
initialize: function(element) {
this.element = $(element);
},
computeWidth: function(x, scroll, C) {
return Math.floor(scroll/C) + this.unitStep(x - (scroll % C) - 1);
},
# Database administrative login by UNIX sockets
local all postgres ident
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all ident
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections: