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
void OnUSDCurrencyExchange(long? transactionId, double usDollars, string purchasedCurrencyType, double amountPurchased){ | |
if(!transactionId.HasValue){ | |
//transactionId has no value so generate one | |
transactionId = GetRandomLong(); | |
} | |
var currencies = new TransactionCurrency[2]; | |
currencies[0] = TransactionCurrency.createReal(Math.Abs(usDollars) * -1, CurrencyType.USD); | |
currencies[1] = TransactionCurrency.createVirtual(Math.Abs(amountPurchased), purchasedCurrencyType); | |
Playnomics.instance.transaction(transactionId, TransactionType.CurrencyConvert, currencies, null, null, null); |
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
while(taskQueue.Count > 0) | |
{ | |
WebRequest httpRequest = null; | |
HttpWebResponse response = null; | |
Stream stream = null; | |
bool requestSucceeded = false; | |
var request = taskQueue.Dequeue(); | |
request.Attempts ++; | |
try{ |
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
using System; | |
using System.Collections.Generic; | |
namespace PlaynomicsPlugin | |
{ | |
internal class ConcurrentQueue<T>{ | |
private readonly object syncLock = new object(); | |
private Queue<T> queue; |
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
void Update() | |
{ | |
//the http worker has a method which returns (dequeues) | |
//an IEnumerable set of completed requests, | |
//internall it is enqueueing the completed requests | |
foreach(ApiResponse response in httpWorker.GetCompletedResponses()) | |
{ | |
if(response.Request.RequestCompleteHandler != null) | |
{ | |
//we want to notify an object that we have completed the request |
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
private IEnumerator ProcessRequests() | |
{ | |
if(isProcessing || taskQueue.Count == 0){ | |
yield break; | |
} | |
isProcessing = true; | |
//get a temp variable, otherwise we could be stuck in an infinite-loop (offline scenario) | |
int itemsToProcess = taskQueue.Count; | |
while(itemsToProcess > 0){ |
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
<?xml version="1.0"?> | |
<cross-domain-policy> | |
<allow-access-from domain="*"/> | |
</cross-domain-policy> |
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
<!-- Start Playnomics API --> | |
<script type="text/javascript"> | |
_pnConfig={}; | |
_pnConfig.userId="<USER-ID>"; | |
var _pnAPIURL=document.location.protocol+"//js.a.playnomics.net/v1/api?a=<APPID>", | |
_pnAPI=document.createElement("script"); | |
_pnAPI.type="text/javascript";_pnAPI.async=true;_pnAPI.src=_pnAPIURL;document.body.appendChild(_pnAPI); | |
</script> | |
<!-- End Playnomics API --> |
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
brew update | |
brew versions FORMULA | |
cd `brew --prefix` | |
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions" | |
brew install FORMULA | |
brew switch FORMULA VERSION | |
git checkout -- Library/Formula/FORMULA.rb # reset formula | |
## Example: Using Subversion 1.6.17 | |
# |
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
import logging | |
from termcolor import colored | |
class ColorLog(object): | |
colormap = dict( | |
debug=dict(color='grey', attrs=['bold']), | |
info=dict(color='white'), | |
warn=dict(color='yellow', attrs=['bold']), |
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
static public bool JsonDataContainsKey(JsonData data,string key) | |
{ | |
bool result = false; | |
if(data == null) | |
return result; | |
if(!data.IsObject) | |
{ | |
return result; | |
} | |
IDictionary tdictionary = data as IDictionary; |