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
const char * niceTime(time_t targetTime, time_t now = time(0)) { | |
const char *periods[8] = {"second", "minute", "hour", "day", "week", "month", "year", "decade"}; | |
float lengths[7] = {60.0, 60.0, 24.0, 7.0, 4.35, 12.0, 10}; | |
int difference = now > targetTime ? now - targetTime : targetTime - now; | |
int i = 0; | |
for (; difference >= lengths[i] && i < 7; i++) { | |
difference /= lengths[i]; | |
} |
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
CCTableViewCell *CCTableView::dequeueCellWithTag(int nTag) | |
{ | |
CCTableViewCell *cell = NULL; | |
for (int i = 0, len = m_pCellsFreed->count(); i < len; i++) { | |
CCTableViewCell *tempCell = (CCTableViewCell*)m_pCellsFreed->objectAtIndex(i); | |
if (tempCell->getTag() == nTag) { | |
cell = tempCell; | |
cell->retain(); | |
m_pCellsFreed->removeObjectAtIndex(i); |
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
// | |
// GameViewController.swift | |
// | |
import UIKit | |
import SpriteKit | |
class GameViewController: UIViewController { | |
override func viewDidLoad() { |
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
body { | |
padding: 0; | |
margin: 0; | |
} | |
.body { | |
opacity: .3; | |
position: absolute; | |
left: 0; | |
right: 0; | |
top: 0; |
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
body { | |
background: #222; | |
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif; | |
} | |
.comment-box { | |
border: transparent 1px solid; | |
height: 90px; | |
position: relative; | |
} |
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 CDN ($config) { | |
this.protocol = $config.protocol; | |
this.domain = $config.domain; | |
this.alias = $config.alias; | |
this.total = $config.total; | |
} | |
CDN.prototype = { | |
getURL: function (path) { | |
return this.protocol + '://' + this.alias + (this._stringToNumber(path) % this.total) + '.' + this.domain + path; | |
}, |
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 () { | |
function date (format, timestamp) { | |
// http://kevin.vanzonneveld.net | |
// + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com) | |
// + parts by: Peter-Paul Koch (http://www.quirksmode.org/js/beat.html) | |
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) | |
// + improved by: MeEtc (http://yass.meetcweb.com) | |
// + improved by: Brad Touesnard | |
// + improved by: Tim Wiel | |
// + improved by: Bryan Elliott |
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 getScriptsSource (scripts, checksum) { | |
function loadScript (path) { | |
var file, | |
hasLocalStorage = window.localStorage; | |
if (!hasLocalStorage || !(file = localStorage.getItem('file:' + path))) { | |
var request = new XMLHttpRequest(); | |
request.open('GET', path, false); | |
request.send(null); |
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
/* | |
USE: | |
1) copy this code | |
javascript:var chat=document.getElementById('nChat'),chatRect=chat.getBoundingClientRect(),interval=1000;function refresh(){var request=new XMLHttpRequest();request.open('GET','/',true);request.onreadystatechange=function(){if(request.readyState==4){var container=document.createElement('div');container.innerHTML=request.responseText;var messages=Array.prototype.slice.call(container.querySelectorAll('#nChat p.chatmessage'));messages.forEach(function(message){if(!chat.querySelector('#'+message.id)){chat.appendChild(message)}});chat.scrollTop=chat.scrollHeight-chatRect.height;setTimeout(refresh,interval)}};request.send(null)}refresh(); | |
2) paste it into the address bar of btc-e and press return | |
*/ |
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 AsyncTaskThrottle () { | |
this._queued = null; | |
this._busy = false; | |
} | |
AsyncTaskThrottle.prototype = { | |
do: function (task) { | |
if (!this._busy) { | |
this._queued = task; | |
return this._call(); |