Skip to content

Instantly share code, notes, and snippets.

<p class="MsoNormal">
<span lang="EN-US"><span style="position:relative;top:12.0pt"><img width="45" height="41" src="test12_files/image002.gif" v:shapes="_x0000_i1025" /></span><m:math style="background-color:#">
<m:semantics>
<m:mi>,</m:mi>
<m:annotation encoding="MathType-MTEF">MathType@MTEF@5@5@+=feaagCart1ev2aqatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYbItLDharqqtubsr4rNCHbWexLMBbXgBd9gzLbvyNv2CaeHbl7mZLdGeaGqiVu0Je9sqqrpepC0xbbL8F4rqqrFfpeea0xe9Lq=Jc9vqaqpepm0xbba9pwe9Q8fs0=yqaqpepae9pg0FirpepeKkFr0xfr=xfr=xb9adbaqaaeGaciGaaiaabeqaamaabaabauaakeaaiuaajugubabaaaaaaaaapeGaa8hd=daa@4198@</m:annotation>
</m:semantics>
</m:math><span style="position:relative;top:6.0pt"><img width="43" height="24" src="test12_files/image004.gif" v:shapes="_x0000_i1026" /></span><m:math style="background-color:#">
<m:semantics>
<m:mi>,</m:mi>
@katat
katat / topcoder-challenges-webtask.js
Last active February 20, 2016 08:26
Hack the use of the topcoder API to get the latest challenge data, and create RSS string in the desired format to be consumable in any RSS reader.
'use latest';
var request = require('request@2.56.0');
var xmlbuilder = require('xmlbuilder@2.6.4');
module.exports = function(context, req, res) {
request({
method: 'GET',
uri: 'https://api.topcoder.com/v2/challenges/active?review=COMMUNITY,INTERNAL&type=develop'
}, function(error, response, body) {
@katat
katat / sync-set
Created November 1, 2016 04:54
sync-set
a
await wallet.approveTokenDeposit(depositAmount, tokenInfo.symbol);
await wallet.completeTokenDeposit(depositAmount, tokenInfo.symbol);
//specify the currency, amount and the recipient address
const payMonetaryAmount = nahmii.MonetaryAmount.from({
currency: {
ct: tokenInfo.currency,
id: '0'
},
amount: ethers.utils.parseUnits(payAmount, tokenInfo.decimals)
});
const payment = new nahmii.Payment(payMonetaryAmount, wallet.address, recipientAddress, wallet);
await settlementFactory.calculateRequiredSettlements(wallet.address, stageMonetaryAmount);
const settlements = await settlementFactory.getAllSettlements(wallet.address, tokenInfo.currency);
//settlement.type indicates which type the settlement is.
//settlement.isStageable indicates if the settlement is qualified and ready to be staged (marked as completed)
//settlement.isOngoing indicates if the settlement is still within the challenge period.
//settlement.expirationTime indicates the end time of the challenge period.
const {hash} = await settlement.start(wallet, {gasLimit, gasPrice});
const settlements = await settlementFactory.calculateRequiredSettlements(wallet.address, stageMonetaryAmount);
for (const settlement of settlements) {
const {hash} = await settlement.start(wallet, {gasLimit, gasPrice});
//wait until the transaction is mined on chain
await provider.getTransactionConfirmation(hash);
}
//approve the deposit amount for the ClientFund contract
await wallet.approveTokenDeposit(depositAmount, tokenInfo.symbol);
//deposit to the ClientFund contract
await wallet.completeTokenDeposit(depositAmount, tokenInfo.symbol);