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
@thinkphp
thinkphp / gist:1642099
Created January 19, 2012 19:40
Insertion Sort in Python
'''
Insertion Sort
Twitter : http://twitter.com/thinkphp
Website : http://thinkphp.ro
Google Plus : http://gplus.to/thinkphp
MIT Style License
'''
def insertionSort(arr):
@thinkphp
thinkphp / gist:1642162
Created January 19, 2012 19:51
Insertion Sort pseudocode
/*
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)
@thinkphp
thinkphp / gist:1862867
Created February 19, 2012 09:51
sin(x) in Python
'''
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)
@thinkphp
thinkphp / gist:1862871
Created February 19, 2012 09:52
cos(x) in Python
'''
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)
@thinkphp
thinkphp / gist:1862877
Created February 19, 2012 09:54
sin(x) in PHP
/*
* 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) {
@thinkphp
thinkphp / gist:1862882
Created February 19, 2012 09:54
cos(x) in PHP
<?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) {
@thinkphp
thinkphp / gist:1940001
Created February 29, 2012 11:01
creating a custom widget using Dijit
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
},
@thinkphp
thinkphp / gist:1940020
Created February 29, 2012 11:03
Create your own custom widget using Dojo
/**
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
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() {
@thinkphp
thinkphp / gist:1977900
Created March 5, 2012 11:14
yqlquery usage
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()