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
def add_cached_hits(cache_results, start, size) | |
number_to_pull_from_cache = [0, (cache_results.length - start)].max | |
# DO the search | |
if (number_to_pull_from_cache > 0) | |
# Take number_to_pull from the *END* of the cache_results | |
results = cache_results[ ...??] + search_results | |
# Then slice that # off the end of the results |
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
{ | |
"rank" =>"NOT_CARE", | |
"match-expr" =>"NOT_CARE", | |
"hits" => { | |
"found" =>5, | |
"start" =>0, | |
"hit" => [ | |
{ | |
"id" =>373 | |
}, |
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
/Users/cfitzhugh/.rvm/gems/ruby-1.9.3-p385@ziplist/gems/sass-3.2.1/lib/sass/cache_stores/filesystem.rb:21: [BUG] Segmentation fault | |
ruby 1.9.3p385 (2013-02-06 revision 39114) [x86_64-darwin11.4.2] | |
-- Control frame information ----------------------------------------------- | |
c:0117 p:0065 s:0503 b:0503 l:000502 d:000502 METHOD /Users/cfitzhugh/.rvm/gems/ruby-1.9.3-p385@ziplist/gems/sass-3.2.1/lib/sass/cache_stores/filesystem.rb:21 | |
c:0116 p:0024 s:0495 b:0495 l:000494 d:000494 METHOD /Users/cfitzhugh/.rvm/gems/ruby-1.9.3-p385@ziplist/gems/sass-3.2.1/lib/sass/cache_stores/base.rb:62 | |
c:0115 p:0017 s:0488 b:0488 l:000473 d:000487 BLOCK /Users/cfitzhugh/.rvm/gems/ruby-1.9.3-p385@ziplist/gems/sass-3.2.1/lib/sass/cache_stores/chain.rb:25 | |
c:0114 p:---- s:0483 b:0483 l:000482 d:000482 FINISH | |
c:0113 p:---- s:0481 b:0481 l:000476 d:000480 IFUNC | |
c:0112 p:---- s:0479 b:0479 l:000478 d:000478 CFUNC :each |
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 StoredProcedure | |
include Mongoid::Document | |
store_in collection: "system.js" | |
field :value, type: Moped::BSON::Code | |
field :name, type: String | |
field :_id, type: String, default: lambda { name } | |
def self.method_missing(name, *args) | |
arg_names = (1..args.length).map {|i| "a#{i}"}.join(',') | |
eval_str = "return function(#{arg_names}) { return #{name}(#{arg_names});}(#{args.map {|v| v.to_json}.join(',')});" |
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
working/ziplist ‹master✗›$ dig @192.168.1.1 ns zlcdn.com | |
; <<>> DiG 9.7.3-P3 <<>> @192.168.1.1 ns zlcdn.com | |
; (1 server found) | |
;; global options: +cmd | |
;; Got answer: | |
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44752 | |
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 2 | |
;; QUESTION SECTION: |
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
balance = float (raw_input ('What is your current balance? ')) | |
interest = float (raw_input ('What is your interest rate? ')) | |
monthly_interest_rate = interest / 12.0 | |
# Monthly payment lower bound = Balance / 12.0 | |
# Monthly payment upper bound = (Balance * (1 + (Annual interest rate / 12.0)) ** 12.0) / 12.0 | |
lower_bound = balance / 12.0 | |
upper_bound = ( balance * ( 1 + (monthly_interest_rate)) ** 12.0 ) / 12.0 |
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
Inputs: | |
{ | |
"foo" => [{ start: 1, end: 10}], | |
"bar" => [{ start: 3, end: 6}], | |
"baz" => [{ start: 4, end: 5}], | |
"bap" => [{ start: 8, end: 9}] | |
] | |
# Would with some magic, become: |
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
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<script src="http://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"></script> | |
<script> | |
/** | |
* A Simple Vector Shape Drawing App with RaphaelJS and jQuery | |
* copyright 2010 Kayla Rose Martin - Licensed under the MIT license | |
* Inspired by http://stackoverflow.com/questions/3582344/draw-a-connection-line-in-raphaeljs | |
**/ |
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
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> | |
<script src="http://yandex.st/raphael/1.5.2/raphael.min.js"></script> | |
<script> | |
/** | |
* A Simple Vector Shape Drawing App with RaphaelJS and jQuery | |
* copyright 2010 Kayla Rose Martin - Licensed under the MIT license | |
* Inspired by http://stackoverflow.com/questions/3582344/draw-a-connection-line-in-raphaeljs | |
**/ |
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
// I'm a dork of sorts, and like to make my xhr requests mime type .js in rails. | |
// It makes action files really easy to separate (.js files are for xhr, .html files are for html) | |
// | |
// I guess it could cause issues - maybe we should be creating an XHR/html mime type | |
// Regardless, it's what we do at my company... I guess b/c I wrote it. | |
// | |
// So that .js view file should return HTML. You can always execute the html if you need: | |
// <script> alert('this xhr response has JS!'); </script> | |
// | |
// Whereas you can't really do HTML inside JS very well. |