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
| source "https://rubygems.org" | |
| gem 'sinatra' | |
| gem 'binger' |
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
| var bing = Bing( {appid: 'your-api-key'} ); | |
| bing.search(q.value, function( data ){ | |
| var res = data.SearchResponse.Web.Results; | |
| if(res && res.length > 0) { | |
| var all = res.length, |
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
| var bing = require('binger') | |
| var b = bing({appId:"your-api-key"}) | |
| b.search("MooTools", function(error, response, body){ | |
| console.log(body.SearchResponse.Web.Results[0]) | |
| },{limit: 30}) |
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
| <?php | |
| /** | |
| * @class | |
| * @description - A simple class wrapper for Microsoft's Bing API REST. | |
| * @author - Adrian Statescu <mergesortv@gmail.com> | |
| * @license - MIT | |
| * @public methods - constructor, search, getJSON, getHTML | |
| * @private methods - request and prepareHTML | |
| */ |
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
| import urllib | |
| import urllib2 | |
| import json | |
| from xml.dom.minidom import parse | |
| class Bing: | |
| ENDPOINT = 'http://api.bing.net/format.aspx' |
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
| # | |
| # Project Euler | |
| # | |
| # Factorial digit sum | |
| # Problem 20 | |
| # | |
| # n! means n x (n - 1) x ... x 3 x 2 x 1 | |
| # For example, 10! = 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 3628800, | |
| # | |
| # and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. |
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
| <?php | |
| /** | |
| * Project Euler | |
| * | |
| * Problem 21 | |
| * | |
| * Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). | |
| * If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers. | |
| * |
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
| # | |
| # Project Euler | |
| # | |
| # Amicable numbers | |
| # Problem 21 | |
| # | |
| # Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). | |
| # if d(a) = b and d(b) = a, where a!=b, then a and b are an amicable pair and each of a and b are called amicable numbers. | |
| # | |
| # For example, the proper divisors of 220 are 1,2,4,5,10,11,20,22,44,55 and 110; therefore d(220) = 284. The proper divisors of |
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
| ;factorial using prog | |
| (defun f(n) | |
| (prog ((i 0)(f 1)) | |
| hello | |
| (setf i (+ i 1) f (* f i)) | |
| (if (<= n i) (return f)) | |
| (go hello) | |
| ) | |
| ) |
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
| ;Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: | |
| ;1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... | |
| ;1 2 3 5 8 13 21 44 65 | |
| ;By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. | |
| ;Output: 4613732 | |
| (defun fibeven(limit)(labels ((fib (a b limit sum) (if (> a limit) sum (fib b (+ a b) limit (if (evenp a) (+ sum a) sum) )) ))(fib 1 2 limit 0))) |