Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar
💭
If I have seen further it is only by standing on the shoulders of giants. Newton

Adrian Statescu thinkphp

💭
If I have seen further it is only by standing on the shoulders of giants. Newton
View GitHub Profile
source "https://rubygems.org"
gem 'sinatra'
gem 'binger'
@thinkphp
thinkphp / gist:5185631
Created March 18, 2013 07:41
A client JavaScript for Microsoft's Bing Search API REST.
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,
@thinkphp
thinkphp / gist:5185637
Created March 18, 2013 07:43
A client wrapper for Microsoft's Bing Search API v2.2 on Node.js.
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})
@thinkphp
thinkphp / gist:5185642
Last active December 15, 2015 02:09
A PHP class client for Microsoft's Bing API REST GET
<?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
*/
@thinkphp
thinkphp / gist:5185651
Created March 18, 2013 07:47
A simple client for Microsoft's Bing API Search.
import urllib
import urllib2
import json
from xml.dom.minidom import parse
class Bing:
ENDPOINT = 'http://api.bing.net/format.aspx'
#
# 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.
@thinkphp
thinkphp / gist:5269668
Created March 29, 2013 09:03
Project Euler problem 21
<?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.
*
@thinkphp
thinkphp / gist:5269678
Created March 29, 2013 09:04
Project Euler problem 21
#
# 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
@thinkphp
thinkphp / gist:5286684
Created April 1, 2013 18:25
factorial using prog
;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)
)
)
@thinkphp
thinkphp / gist:5344990
Last active December 16, 2015 00:08
Project Euler problem 2 in Common LISP
;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)))