Monday, March 9, 2015

Best AdMob alternatives

MoPub
Axonix (requires Google Play Services)
MobFox (requires Google Play Services, but has custom API)
InMobi (requires Google Play Services)
LeadBolt (only full screen ads)
MMedia (requires Google Play Services)
 
(pickup which one is lesser evil)

Sunday, October 26, 2014

Show longest continuous block of code not covered by tests

Usage: nocov.py
import fileinput
count = 0
lengths = {}
first = 0
for line in fileinput.input():
    if first and ('stm mis' in line or 'pln' in line):
        lengths[first] += 1
    else:
        t = line.split("id='t")
        if len(t) < 2:
            continue
        first = t[-1].split("'")[0]
        lengths[first] = 1

for x in sorted(lengths.items(), key=lambda (x, y): y):
    print x

Profiling C++ scopes

The following simple class measure time spent in scope it is declared in:
class profile {
    // usage: profile __profile(__FILE__, __LINE__);
    static map < pair, clock_t> __total;
    string _file;
    unsigned _line;
    clock_t _start;
public:
    profile(const char* file, unsigned line) :
        _file(file), _line(line), _start(clock()) {
    }
    ~profile() {
        clock_t d = clock() - _start;
        clock_t t = __total[make_pair(_file, _line)] += d;
        OutputDebugStringA(((string)_file + ':' + to_string(_line) + "+=" + to_string(d) + " = " + to_string(t) + '\n').c_str());
    }
};
map < pair, clock_t> profile::__total;
Example:
void foo() {
profile __profile(__FILE__, __LINE__); // measure time in foo
// other code
while (something) {
profile __profile(__FILE__, __LINE__); // measure time in while loop
}
}

Friday, May 30, 2014

Why I hate fxsol.co.uk?

Short answer: you can not get your money back. Once you send it to FX Solutions consider them lost. They will find 1000 reasons but will not process your withdrawal request.
Long answer: just look at this:

Case #1

I have request to withdraw to another bank since my previous bank shut down:

Date: Mon, 31 Mar 2014 16:03:41 +0100
From: funding@fxsol.co.uk
To: <yurii....@gmail.com>

Dear Mr Z. MT650629 
  
 
Thank you for your recent withdrawal request. Unfortunately, we are unable to process your request as we are required to return the funds to the source bank account ending 3840 at Loyal Bank. 
  
Please reply to our email confirming the following information: 
 
 
ABA/SWIFT/BSB/BIC/IBAN/Sort Code - Please select as appropriate  
 
Bank Name 
 
Bank Address 
 
Beneficiary Name 
 
Bank Account Number 
 
Sort Code if applicable                                 
If you require any further assistance please contact us during opening hours on the contact details below.
 
 
Regards, 
Pedro Bennasar

Date: Tue, 1 Apr 2014 06:41:04 +0100
From: funding@fxsol.co.uk
To: <yurii....@gmail.com>

Dear customer, 
  
If this account ending 3840 is closed, you will need to provide a close proof so that we can return the fund to your other bank account. Thanks. 
  
 
Regards, 
Jiachen Shen

Date: Tue, 1 Apr 2014 07:15:59 +0100
From: funding@fxsol.co.uk
To: <yurii....@gmail.com>

Dear customer, 
  
If bank does not accept USD wire, does it mean that they will convert the USD into other currency when they receive the fund? Please confirm with your bank. Thanks. 
  
 
Regards, 
Jiachen Shen

Date: Tue, 1 Apr 2014 13:28:59 +0700
From: "Yurii Z." <yurii....@gmail.com>
To: funding@fxsol.co.uk

No they do not accept incoming wire transfers at all since December 2013.
All incoming transfers will be put on hold or reversed.
PLEASE DO NOT SEND MONEY TO LOYALBANK! IT WILL BE LOST!

Please send to local bank account I've provided. See attachment for the
proof I'm owner of this account as well.

Date: Tue, 1 Apr 2014 10:55:14 +0100
From: funding@fxsol.co.uk
To: <yurii....@gmail.com>

Dear Mr Z. MT 650629 
  
We are in receipt of your withdraw request, however to be in compliance with our Anti Money Laundering  policy, we must send funds back to your original bank account with which you funded your account.  
  
Please provide the swift code, bank name, address and account number for the account ending in 3840 in order for us to proceed with your request.  
  
If your bank is not accepting incoming wires please provide us a confirmation on a headed paper from your bank, we are not allowed to call your bank due to the  Data Protection Act to check this. 
  
If we send the funds to Loyal Bank and they return it to us then we can check for alternative options. 
  
We look forward to hearing from you soon. 
 
Regards, 
Katya de Rios

Date: Tue, 1 Apr 2014 17:20:09 +0700
From: "Yurii Z." <yurii....@gmail.com>
To: funding@fxsol.co.uk

If I add funds to account using another bank can I use it for
withdrawals after this?

Date: Tue, 1 Apr 2014 11:42:23 +0100
From: funding@fxsol.co.uk
To: <yurii....@gmail.com>

Dear Mr Z. MT 650629 
  
Could you please get a confirmation from your bank that they can not accept incoming wires so we see an alternative solution for you. 
  
If you deposit new funds we will only return this funds to the new bank account that you will use. 
  
Thank you. 
 
Regards, 
Katya de Rios


Date: Wed, 2 Apr 2014 10:57:59 +0700
From: "Yurii Z." <yurii....@gmail.com>
To: funding@fxsol.co.uk

That is ok I want to use this account in future. I've sent funds. Details:

Dear Valued Customer

International Fund Transfer Transaction

Instruction Date : 02/04/2014 09:55
Transfer Date : 02/04/2014
Reference No : 14464
Payer A/C Name : IURII Z. , A/C No.: XXXXXXXXXX
Payee A/C Name : CITY INDEX LIMITED TRADING , A/C No.: GB47CHAS60924241408410
Address : PARK HOUSE, 16 FINSBURY CIRCUS
    LONDON EC2M 7EB
    UNITED KINGDOM
Receiver Bank : JPMORGAN CHASE BANK, N.A. , Branch :
Bank Code : CHASGB2L
Transfer Amount : USD 50.00
Exchange Rate : 32.4900000
Deduct Amount : THB 1,624.50
Fee : THB 1,100.00
Short Note : -
Remark : Your transaction may be declined due to a problem of the
destination bank.
    Please check your statement
Remittance Information : AC NO 650629 - - -

Date: Wed, 2 Apr 2014 08:03:28 +0100
From: funding@fxsol.co.uk
To: <yurii....@gmail.com>

Dear Sir, 
  
Per previously advised, funds will need to be withdrawn back to the source bank account. 
As you have advised that Loyal Bank no longer accepts incoming USD, and your account is still open with Loyal Bank. We will require you to provide confirmation from Loyal Bank that they are no longer able to accept USD into your bank account with them. 
  
Please advise so that we may proceed further. 
  
  
 
Regards, 
Anthony Chia

Date: Wed, 2 Apr 2014 15:44:16 +0100
From: funding@fxsol.co.uk
To: <yurii....@gmail.com>

Dear Mr Z. MT651310 
  
Kindly be informed that your $50 wire transfer has been now returned back to the remitter bank account since funds were originated from a different Country where you reside. Please note that in order to comply with our AML policy, funds must come from your Country of Residence. 
  
If you require any further assistance please contact us during opening hours on the contact details below.
 
 
Regards, 
Pedro Bennasar

Date: Thu, 3 Apr 2014 14:00:25 +0700
From: "Yurii Z." <yurii....@gmail.com>
To: funding@fxsol.co.uk

Then please send 1 USD to LoyalBank to verify it will not be processed.

Beneficiary:
Name: Z. Iurii
Address: XXX
Account number: XXXXXXXXX

Beneficiary Bank:
Name: Loyal Bank Limited
Address: Cedar Hill Crest, Villa, VC0100, Kingstown, St. Vincent and
the Grenadines, West Indies
SWIFT code: LOYAVCVX

This situation is an absurd. I'm very disappointed by your withdrawal service...

Date: Thu, 3 Apr 2014 14:08:44 +0700
From: "Yurii Z." <yurii....@gmail.com>
To: funding@fxsol.co.uk

Attached the proof my Country of Residence is Thailand.

Date: Thu, 3 Apr 2014 08:09:26 +0100
From: funding@fxsol.co.uk
To: <yurii....@gmail.com>

Dear customer, 
  
We cannot process 1 USD withdraw to LoyalBank. You will need to get the bank provide proof that they cannot accept USD wire. Thanks. 
  
 
Regards, 
Jiachen Shen

Date: Thu, 3 Apr 2014 14:18:14 +0700
From: "Yurii Z." <yurii....@gmail.com>
To: funding@fxsol.co.uk

Are you kidding me?! In the email before you said you can process
withdrawals to LoyalBank only. Now you say you will not send my money
anywhere.
I can not provide the proof they do not accept anything. Their customer
support is not answering. They do not reply by email and by phone they
promised they will send it but didn't send anything. 

...more than  one month has passed and I still haven't returned my money.

Case #2

Another attempt to withdraw my money:



Date: Thu, 15 May 2014 19:20:34 +0700
From: "Yurii Z." <yurii....@gmail.com>
To: funding@fxsol.co.uk

Hello,

Please send another withdrawal of $400 using same instructions to same bank
account.

Date: Thu, 15 May 2014 14:04:25 +0100
From: funding@fxsol.co.uk
To: <yurii....@gmail.com>

Dear Mr Z.,  MT650629 
  
We have noticed that your form states a different address to the one we have on file. 
Kindly complete and submit the attached form if you have changed your Country of Residence. 
Your withdrawal request will be processed upon receipt of your confirmation. 
  
 
Regards, 
Pedro Bennasar

Date: Fri, 16 May 2014 06:41:31 +0700
From: "Yurii Z." <yurii....@gmail.com>
To: funding@fxsol.co.uk

I see no attachment.

Date: Fri, 16 May 2014 00:53:54 +0100
From: funding@fxsol.co.uk
To: <yurii....@gmail.com>

Dear Client MT650629, 
  
Please see attached to update your contact information. 
Thank you. 
  
 
Regards, 
Siyuan Chang

Date: Sat, 17 May 2014 18:49:40 +0700
From: "Yurii Z." <yurii....@gmail.com>
To: funding@fxsol.co.uk

Please see attachments.

Date: Mon, 19 May 2014 10:26:38 +0100
From: "FX Solutions" <accounts@fxsol.co.uk>
To: <yurii....@gmail.com>

Dear Iurii Z. 
  
Thank you very much for your email. 
  
Unfortunately, we are unable to update your address because the proof of address document you sent to us is not in English. 
  
Please re-send us one of the below documents in English. If the document is not in English, please have the document be translated in to English or verified by a certified accountant, lawyer or a notary public. 
  
1. copy of credit card statement dated within the last three months 
2. copy of bank statement dated within the last three months 
3. copy of utility bill dated within the last three months 
  
Kindly take note that e-statement and mobile bill are not accepted. 
  
We will update your record as soon as receipt of the above document. 
  
Feel free to let us know if you have any enquiry. 
  
 
Regards, 
Mei-Ling Chan

Date: Tue, 20 May 2014 16:52:42 +0700
From: "Yurii Z." <yurii....@gmail.com>
To: FX Solutions <accounts@fxsol.co.uk>

Please see attachment for bank statement dated today. Address in top left
corner.

https://maps.google.ru/maps?f=q&source=s_q&hl=en&geocode=+&q=ao+nang&ie=UTF8&hq=&hnear=Ao+Nang,+Mueang+Krabi+District,+Krabi,+Thailand&t=m&z=12&vpsrc=0&iwloc=A

https://maps.google.ru/maps?f=q&source=s_q&hl=th&geocode=+&q=ao+nang&ie=UTF8&hq=&hnear=Ao+Nang,+Mueang+Krabi+District,+Krabi,+Thailand&t=m&z=12&vpsrc=0&iwloc=A

Date: Wed, 21 May 2014 09:37:18 +0100
From: "FX Solutions" <accounts@fxsol.co.uk>
To: <yurii....@gmail.com>

Dear Iurii Z. 
  
As mentioned in my previous email, we are unable to verify documents which is not in English. Please have the document be translated in to English or verified by a certified accountant, lawyer or a notary public. 
  
Or you can request your bank to issue a letter to you which states your name, address and the account your are maintaining with the bank. 
  
Feel free to let us know if you have any enquiry. 
 
Regards, 
Mei-Ling Chan

Date: Thu, 22 May 2014 14:29:37 +0700
From: "Yurii Z." <yurii....@gmail.com>
To: FX Solutions <accounts@fxsol.co.uk>

OK. Certified translation costs $30-50 per page. If you credit it to my
account I will send you certified translation.

Date: Thu, 22 May 2014 09:42:00 +0100
From: "FX Solutions" <accounts@fxsol.co.uk>
To: <yurii....@gmail.com>

Dear Iurii Z. 
  
I am afraid this translation cost shall be beared by client. 
  
As mentioned, you can request a letter in English from your bank stating your name, address and account number maintaining with the bank. We can accept this letter as the proof of address.   
  
 
Regards, 
Mei-Ling Chan 

Oh, I have to pay $50 for some papers just because FX Solutions UK decided they need it and I have to pay for it. Great.
So I strongly discourage anybody from putting their money to FX Solutions UK. If you want a good broker try Alpari or Pepperstone. They process withdrawals in 48 hours with no bureaucracy.

Wednesday, April 9, 2014

Python cache dictionary

class cachedict(dict):
    def __init__(self, factory):
        self.factory = factory

    def __missing__(self, key):
        value = self[key] = self.factory(key)
        return value
USAGE:
d = cachedict(lambda x: x ** 2)
print d[2]  # 4