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
| ''' | |
| Insertion Sort | |
| Twitter : http://twitter.com/thinkphp | |
| Website : http://thinkphp.ro | |
| Google Plus : http://gplus.to/thinkphp | |
| MIT Style License | |
| ''' | |
| def insertionSort(arr): |
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
| /* | |
| Pseudocode of the complete algorithm | |
| Twitter : http://twitter.com/thinkphp | |
| Website : http://thinkphp.ro | |
| Google Plus : http://gplus.to/thinkphp | |
| MIT Style License | |
| */ | |
| INSERTION-SORT(V) |
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
| ''' | |
| 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 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
| ''' | |
| cos(x) = 1-x^2/2!+x^4/4!-x^6/6!+..- | |
| ''' | |
| import math | |
| def fact(n): | |
| if n==0: | |
| return 1 | |
| else: | |
| return n*fact(n-1) |
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
| /* | |
| * Twitter @thinkphp | |
| * | |
| * Approximate the function sin with series Taylor! | |
| * sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ....(-1)^n+1*x^(2n+1)/(2n+1)!; | |
| * | |
| */ | |
| function fact($n) { |
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 | |
| /* | |
| * @thinkphp | |
| * | |
| * Approximate the function sin with series Taylor! | |
| * cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + ....(-1)^n*x^(2n)/(2n)!; | |
| * | |
| */ | |
| function fact($n) { |
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
| require(["dojo/io/script","dojo/dom","dojo/_base/array","custom/widget"],function(jsonp,dom,util,Widget){ | |
| var container = dom.byId("twitterbadge"), | |
| jsonpArgs = { | |
| url: "http://twitter.com/statuses/user_timeline.json", | |
| callbackParamName: "callback", | |
| content: { | |
| screen_name: "thinkphp", | |
| count: 8 | |
| }, |
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
| /** | |
| In this recipe, we'll be covering how to leverage pieces of Dojo and the Dijit framework to create your own custom widgets, specifically covering use of Dijit/_WidgetBase and Dijit/_TemplatedMixin to quickly and easily set up your widget. | |
| */ | |
| define(["dojo/_base/declare","dijit/_WidgetBase","dijit/_TemplatedMixin","dojo/text!./widget/templates/template.html","dojo/dom-style", "dojo/_base/fx", "dojo/_base/lang"], | |
| function(declare,WidgetBase,TemplatedMixin, template, domStyle, fx, lang){ | |
| return declare([WidgetBase,TemplatedMixin],{ | |
| //some default values for our author |
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
| function YQLQuery(query,callback,format,diagnostics) { | |
| this.query = query; | |
| this.format = format || 'json'; | |
| this.diagnostics = diagnostics || false; | |
| this.callback = callback || function(){}; | |
| } | |
| YQLQuery.prototype.fetch = function() { |
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 username = 'yelf'; | |
| function callback(data) { | |
| document.getElementById('result').innerHTML = data.query.results.result; | |
| } | |
| var yql = 'use "http://thinkphp.ro/apps/lastfm.js/YQL-open-data-table/recentlastfm.xml" as lastfm;select * from lastfm where username="'+ username +'" and api_key="2993c6e15c91a2890c2f11fa95673067"'; | |
| new YQLQuery(yql,callback).fetch() |