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
$url = 'http://twitter.com/statuses/public_timeline.rss';
$twitterdata = get($url);
preg_match_all("/<description>([^<]+)<\/description>/msi",$twitterdata,$descriptions);
$descriptions[1] = preg_replace("/^([\w]+)\:/","<strong>$1</strong>",$descriptions[1]);
foreach($descriptions[1] as $key=>$desc) {
if(typeof asyncRequest == 'undefined') {
asyncRequest = {};
}
asyncRequest.REQUEST = function() {
function handleReadyState(o,callback) {
o.onreadystatechange = function() {
@thinkphp
thinkphp / gist:575151
Created September 11, 2010 12:35
Example code for getting an OAuth 1.0a access_token from Twitter @anywhere users.
<?php
// Download TwitterOAuth from http://github.com/abraham/twitteroauth.
require_once('twitteroauth/twitteroauth.php');
// Get consumer keys from http://dev.twitter.com/apps.
$consumer_key = '';
$consumer_secret = '';
$oauth_bridge_code = '';
function loadScript(url,callback){var script=document.createElement("script");script.type="text/javascript";if(script.readyState){script.onreadystatechange=function(){if(script.readyState=="loaded"||script.readyState=="complete"){script.onreadystatechange=null;callback();}};}else{script.onload=function(){callback();};}script.src=url;document.getElementsByTagName("head")[0].appendChild(script);}
LazyLoad=function(){var f=document,g,b={},e={css:[],js:[]},a;function j(l,k){var m=f.createElement(l),d;for(d in k){if(k.hasOwnProperty(d)){m.setAttribute(d,k[d])}}return m}function h(d){var l=b[d];if(!l){return}var m=l.callback,k=l.urls;k.shift();if(!k.length){if(m){m.call(l.scope||window,l.obj)}b[d]=null;if(e[d].length){i(d)}}}function c(){if(a){return}var k=navigator.userAgent,l=parseFloat,d;a={gecko:0,ie:0,opera:0,webkit:0};d=k.match(/AppleWebKit\/(\S*)/);if(d&&d[1]){a.webkit=l(d[1])}else{d=k.match(/MSIE\s([^;]*)/);if(d&&d[1]){a.ie=l(d[1])}else{if((/Gecko\/(\S*)/).test(k)){a.gecko=1;d=k.match(/rv:([^\s\)]*)/);if(d&&d[1]){a.gecko=l(d[1])}}else{if(d=k.match(/Opera\/(\S*)/)){a.opera=l(d[1])}}}}}function i(r,q,s,m,t){var n,o,l,k,d;c();if(q){q=q.constructor===Array?q:[q];if(r==="css"||a.gecko||a.opera){e[r].push({urls:[].concat(q),callback:s,obj:m,scope:t})}else{for(n=0,o=q.length;n<o;++n){e[r].push({urls:[q[n]],callback:n===o-1?s:null,obj:m,scope:t})}}}if(b[r]||!(k=b[r]=e[r].shift())){return}g=g||f.getElement
if(typeof asyncRequest == 'undefined') {
asyncRequest = {};
}
asyncRequest.REQUEST = function() {
function handleReadyState(o,callback) {
o.onreadystatechange = function() {
Algorithm B (Bubble Sort). Records R(1),...,R(N) are rearranged
in place; after sorting is complete their keys will be in
order, K(1)<=K(2)<= ...<=K(N).
1. Set BOUND <-- N (BOUND is the highest index for which
the record is known to be in its final position).
2. Set t <-- 0, Perform step 3 for j=1,2,...,BOUND - 1, and then go to step 4
3. If K(j) > K(j+1) , interchange R(j) <--> R(j+1) and set t <-- j.
var FancySlide=new Class({initialize:function(params){this.items=params.items;this.startItem=params.startItem||0;this.mode=params.mode||"horizontal";this.modes={horizontal:["left","width"],vertical:["top","height"]};this.size=params.size||300;this.box=params.box.setStyle(this.modes[this.mode][1],(this.size*this.items.length)+"px");this.button_event=params.button_event||"click";this.handle_event=params.handle_event||"click";this.onWalk=params.onWalk||null;this.currentIndex=null;this.nextIndex=null;this.previousIndex=null;this.interval=params.interval||4000;this.autoPlay=params.autoPlay||false;this._play=null;this.handles=params.handles||null;if(this.handles){this.addActionHandles(this.handles)}this.buttons={next:[],previous:[],play:[],stop:[],playback:[]};if(params.addButtons){for(action in params.addButtons){this.addActionButtons(action,$type(params.addButtons[action])=="array"?params.addButtons[action]:[params.addButtons[action]])}}var prop=this.modes[this.mode][0];this.fx=new Fx.Tween(this.box,Object.merge(
@thinkphp
thinkphp / gist:1384012
Created November 21, 2011 21:31
Inheritance ruby-style
def ("Human") ({
init: function(name) {
this.name = name;
this.isAlive = true;
this.energy = 1;
},
eat: function(){
this.energy++;
}
});
@thinkphp
thinkphp / gist:1388565
Created November 23, 2011 12:33
Class.extend Inheritance
var Human = Class.extend({
init: function(name) {
this.name = name;
this.energy = 1;
this.isAlive = true;
},
eat: function() {
this.energy++;
}