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
#include<bits/stdc++.h> | |
using namespace std; | |
/*** Optimization ***/ | |
#pragma GCC optimize("Ofast,no-stack-protector") | |
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") | |
#pragma GCC optimize("unroll-loops") | |
/*** Typedef ***/ |
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
var JSONP = (function(){ | |
/*private members*/ | |
var counter = 0, | |
query, | |
key, | |
head, | |
context = this; | |
/*private method that becomes public method through return object*/ |
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
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
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}' | |
$(function(){ | |
$.yql(url, | |
{username: 'asd', api: '2993c6e15c91a2890c2f11fa95673067'}, | |
function(data){ | |
document.getElementById('result').innerHTML = data.query.results.result |
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($){ | |
$.extend({ | |
_prepareParams: function(query, params) { | |
$.each(params,function(key){ | |
var name = "#{"+ key +"}", |
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 yqlcache=function(){var cacheid,cb,cancache=(("localStorage" in window)&&(window.localStorage!==null));function get(transaction){if(!transaction.id||!transaction.callback||!transaction.yql||!transaction.cacheage){return}var current,data;cb=transaction.callback;cacheid=transaction.id;if(!cancache){loadYQL(transaction.yql)}if(cancache){current=JSON.parse(localStorage.getItem(cacheid));if(current!==null){if((new Date().getTime()-current.time)<transaction.cacheage){cb({type:"cached",data:current.data})}else{loadYQL(transaction.yql)}}else{loadYQL(transaction.yql)}}}function loadYQL(yql){var old=document.getElementById("yqloadscript");if(old){old.parentNode.removeChild(old)}var YQL="http://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent(yql)+"&diagnostics=false&format=json&callback=yqlcache.cache";var s=document.createElement("script");s.setAttribute("type","text/javascript");s.id="yqloadscript";s.setAttribute("src",YQL);document.getElementsByTagName("head")[0].appendChild(s)}function cache(data){if(da |
NewerOlder