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
<?php | |
/** | |
* by Adrian Statescu <adrian@thinkphp.ro> | |
* Twitter: @thinkphp | |
* G+ : http://gplus.to/thinkphp | |
* MIT Style License | |
*/ |
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
''' | |
sin(x) = x-x^3/3!+x^5/5!-x^7/7!+..- | |
''' | |
import math | |
def fact(n): | |
if n==0: | |
return 1 | |
else: | |
return n*fact(n-1) |
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
''' | |
Computes SQuare RooT in Python SQRT | |
s = (s+nr/s)1/2 | |
Twitter : http://twitter.com/thinkphp | |
Website : http://thinkphp.ro | |
Google Plus : http://gplus.to/thinkphp | |
MIT Style License | |
''' |
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
''' | |
by Adrian Statescu <adrian@thinkphp.ro> | |
Twitter: @thinkphp | |
G+ : http://gplus.to/thinkphp | |
MIT Style License | |
''' | |
''' | |
Binary Search Tree | |
------------------ |
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
package main | |
func Swap(a, b int) int { | |
a = a ^ b | |
b = b ^ a | |
a = a ^ b | |
return a | |
} |
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
var tpl = "<li><a href='http://twitter.com/{from_user}'>{from_user}</a> {text}<span>{created_at}</span></li>"; | |
var url = 'http://search.twitter.com/search.json'; | |
JSONP.get(url, {q: 'mootools', rpp: 10}, function(data){ | |
var result = data.results, | |
out = '<ul>' | |
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
var JSONP=(function(){var counter=0,query,key,head,context=this;function jsonp(url,params,callback){query="?";params=params||{};for(var key in params){if(params.hasOwnProperty(key)){query+=encodeURIComponent(key)+"="+encodeURIComponent(params[key])+"&";}}var fnHandler="JSONP_"+(new Date().getTime())+"_"+(++counter);context[fnHandler]=function(data){callback(data);try{delete context[fnHandler];}catch(e){}context[fnHandler]=null;};url=url+query+"callback="+fnHandler;loadScript(url);}function loadScript(url){var s=document.createElement("script");s.src=url,s.async=true,done=false;s.onload=s.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;s.onload=s.onreadystatechange=null;if(s&&s.parentNode){s.parentNode.removeChild(s);}}};if(!head){head=document.getElementsByTagName("head")[0];}head.appendChild(s);}return{get:jsonp};})(); |
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
Request.YQL = new Class({ | |
Extends: Request.JSONP, | |
_endpoint: 'http://query.yahooapis.com/v1/public/yql', | |
_formats: ['json','xml'], | |
initialize: function(query, options, vars) { |
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
(function(){ | |
var url = 'use "http://thinkphp.ro/apps/lastfm/YQL-open-data-table/recentlastfm.xml" as lastfm; select * from lastfm where username=#{username} and api_key=@api' | |
new Request.YQL(url, { | |
onSuccess: function(data){ | |
$('result').set('html', data.query.results.result) | |
}}, | |
{'username': 'olivboy','api': '2993c6e15c91a2890c2f11fa95673067'} | |
).send(); | |
})(document.id); |
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
var JSONP = (function(){ | |
/*private members*/ | |
var counter = 0, | |
query, | |
key, | |
head, | |
context = this; | |
/*private method that becomes public method through return object*/ |
NewerOlder