Alexander Anikin's blog

My personal blog

Мошенники на Avito

with 2 comments

Может кому поможет…

Собрался я тут фотик продать. Подал объявление на AVITO.ru.

Пришло письмо от некоего гражданина Нигерии- “micheal pavil” < michea.pavil2014@yandex.com >  с текстом:

Hello thank you for the quick response, … I’m actually buying it for my Son …. and it is unfortunate that I’m not there to pick it up …I’m at sea right now … I work as an Oceanographer … so I do not have time to send something to my Son, that’s why I do this online shopping …. please let me know your payment method .. I can easily do business with PayPal or Bank transfer .. i will pay for the article $ 300 and $ 130 for shipping EMS …… hope you accept my offer…hope to read back from you soon
Даже адрес есть:

Name: James Wale
Address: No 5 Dugbe
City: Ibadan
Zip Code: 23402
State: Oyo State
Country:Nigeria

Навестить бы гордого африканского “морячка”… Люлей бы за такое не мешало…

Вот тут уже кто-то попадался…. Все один-в-один…

В общем, схема проста – типа получаете деньги в обмен на квитанцию об отправке EMS. Но там все польностью – липа.

Будьте аккуратнее!

 

 

Written by Alex Anikin

February 20, 2014 at 7:57 pm

Install bunch of DLL files to Windows Server 2012 GAC

leave a comment »

Thanks to http://devlicio.us/blogs/christopher_bennage/archive/2010/08/25/powershell-gac-and-build-servers.aspx

1. Create ps1 script with contents:

if ( $null -eq ([AppDomain]::CurrentDomain.GetAssemblies() |? { $_.FullName -eq “System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” }) ) {

[System.Reflection.Assembly]::Load(“System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”) | Out-Null
}

$publish = New-Object System.EnterpriseServices.Internal.Publish

Foreach ($file in Get-Childitem “*.dll” -recurse -force)
{
Write-Host $file

$assembly = $null

if ( $file -is [string] ) {
$assembly = $file
} elseif ( $file -is [System.IO.FileInfo] ) {
$assembly = $file.FullName
} elseif ( $file -is [System.IO.DirectoryInfo] ) {
Continue
} else {
#throw (“The object type ‘{0}’ is not supported.” -f $file.GetType().FullName)
}

if ( -not (Test-Path $assembly -type Leaf) ) {
throw “The assembly ‘$assembly’ does not exist.”
}

if ( [System.Reflection.Assembly]::LoadFile( $assembly ).GetName().GetPublicKey().Length -eq 0 ) {
throw “The assembly ‘$assembly’ must be strongly signed.”
}

Write-Output “Installing: $assembly”

$publish.GacInstall( $assembly )
}

2.  Place it to folder with DLLs and start.

PS You can use set-executionpolicy remotesigned to switch running scripts on.

Written by Alex Anikin

September 13, 2013 at 7:57 am

Posted in .Net, Windows Server

Monodroid: WebView input/textarea never get virtual keyboard focus

leave a comment »

Today I found a very strange issue.

This looks like here.

But we can reproduce this on 1-2 of our devices like Nexus, Xoom… (May depends on Android 4.1.x version)

So – WebView creating, opening html, but no one input/textarea get virtual keyboard focus.

I tried every solution for that link, and just only #35 helps me (big thanks to author):

For those who encountered this issue on Jelly Beans:
When you use one of the WebView constructors with more then 2 arguments applying the defStyle parameter, the default style com.android.internal.R.attr.webViewStyle will not be applied! For me the fix was to set the defStyle parameter to android.R.attr.webViewStyle.

e.g. to init a WebView with private browsing use

new WebView(this, null, android.R.attr.webViewStyle, true)

where this is a Context.

Hope to have saved somebody days of investigation (as in my case)..

 

But my project is on Monodroid. I couldn’t find  android.R.attr.webViewStyle value in Monodroid and just find it in SDK 

My constructor now  looks like:

const int WEVVIEWSTYLE = 16842885;

public MyWebView (Context context) : base(context, null, WEVVIEWSTYLE)

Awesome, but why?!

 

Written by Alex Anikin

April 11, 2013 at 10:00 am

Posted in C#, Monodroid

Preventing backup files on iCloud in your iPhone applications in Monotouch

leave a comment »

This is pretty simple. You just need to: 

NSFileManager.SetSkipBackupAttribute(filePath, true);

Written by Alex Anikin

April 1, 2013 at 8:30 pm

Posted in Uncategorized

How to implement Scroll To Top functionality for UIWebView in Monotouch

leave a comment »

Someone can say – this is by default! But I have a case when it’s not.

Imagine – we have a UIWebView within content and it’s almost full fills screen size without needs to be scrolled. But content inside scrolling using Javascript (something like iScroll extension). So iOS thinking: “I shouldn’t  scroll anything for this view.”.  I this case you’ll never get scroll to top event. It’s not firing!

But I found a workaround for this issue. All you need to do just:

1.  Create a fullscreen ScrollView with content size much greater than screen size  – let iOS thinks: “I should support scrolling for this huge view”.

2. Put you UIWebView at random number of pixel below the top of the screen.

3. Switch off handling of ScrollToTop for UIWebView.ScrollView. This must be done because if two controls handle ScrollToTop – nothing works.

4. SetContentOffset to this random number of pixes – to make you UIWebView looks like it placed full-screen.

5. Create ScrollViewDelegate to handle firings of ScrollToTop Event.

That’s it!

Here is the sample code:

const int scrollOffset = 100;

var contentSize = new SizeF (320, 3000);

var scrollToPoint = new PointF (0, scrollOffset);

ScrollView = new UIScrollView();

UI = new DesignedFileManager(Settings);

// UI placed 100px (scrollOffset) lower than top of the screen

UI.Frame = new RectangleF(0, scrollOffset, Window.Frame.Width, Window.Frame.Height+scrollOffset);

// this lines must be there because iOS can’t choose who will support scrolling to top

// so UI web view will not handle scroll to top

UI.ScrollView.ScrollEnabled = false;

UI.ScrollView.ScrollsToTop = false;

// set scroll view frame like window frame

ScrollView.Frame = Window.Frame;

// let scrollview handle scrolling to top

ScrollView.ScrollEnabled = true;

ScrollView.ScrollsToTop = true;

// set scroll view content size bigger than window frame to support scrolling

ScrollView.ContentSize = contentSize;

ScrollView.ShowsVerticalScrollIndicator = false;

ScrollView.ShowsHorizontalScrollIndicator = false;

// scroll to 100px lower, so wevview fills full screen

ScrollView.SetContentOffset(scrollToPoint, false);

ScrollView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;

ScrollView.Delegate = new ScrollViewDelegate(UI);

ScrollView.AddSubview(UI);

_mainView.AddSubview(ScrollView);

And delegate:

class ScrollViewDelegate : UIScrollViewDelegate

{

DesignedFileManager UI;

public ScrollViewDelegate(DesignedFileManager ui) : base()

{

UI = ui;

}

public override bool ShouldScrollToTop(UIScrollView scrollView)

{

Trace.WriteLine(“Scroll to Top invoked.”);

UI.ScrollToTop();

return false;

}

}

Written by Alex Anikin

February 15, 2013 at 6:45 am

Posted in iOS, Mac, Monodevelop, Monotouch

Extranet Collaboration Manager 2010

leave a comment »

Written by Alex Anikin

August 8, 2012 at 9:17 am

Posted in Sharepoint

Memory Warning Received and PushViewController

leave a comment »

It was really  great investigation about why iOS application goes to black screen and craches sometimes.

Fisrst of all, I saw this: Received memory warning. Level 1

After that it goes to black screen. This is very interesting, application was working fine if no applications was started in background (I imagined – there are no free memory… but strange…). But, as I can see later, this is view was unloaded only. Several articles wrote – if view has no SuperView it will be unloaded when UIViewController receive memory warning. But this was obviously our fault. After huge  changes in UI we decided to use only one UIWebView. But some code was moved to new version, and  PushViewController invoke too. This is not clear for me now what exactly change this method, but it do something and view unloading after memory warning receive.  So we just remove this line and no black screen (means unloaded view) now.

Written by Alex Anikin

August 4, 2012 at 7:53 pm

Posted in C#, iOS, Mac, Monodevelop, Monotouch

TFS Addin for Monodevelop – error adding repository

leave a comment »

Found strange issue when trying to add new repository using TFS Addin in Monodevelop (ver 4.0.3.4) on my Mac.

After I setup repository and click button to add – get this error:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Xml.XmlException: Document element did not appear. Line 1, position 1. at Mono.Xml2.XmlTextReader.Read () [0x00000] in <filename unknown>:0 at System.Xml.XmlTextReader.Read () [0x00000] in <filename unknown>:0 at System.Xml.XmlReader.MoveToContent () [0x00000] in <filename unknown>:0 at MonoDevelop.Core.Serialization.XmlConfigurationReader.Read (System.Xml.XmlReader reader) [0x0000d] in /Users/builder/data/lanes/monodevelop-mac-monodevelop-3.0.3-branch/43da787a/source/monodevelop/main/src/core/ MonoDevelop.Core/MonoDevelop.Core.Serialization/XmlDataSerializer.cs:238 at MonoDevelop.Core.Serialization.XmlDataSerializer.Deserialize (System.Xml.XmlReader reader, System.Type type) [0x00000] in /Users/builder/data/lanes/monodevelop-mac-monodevelop-3.0.3-branch/43da787a/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Serialization/XmlDataSerializer.cs:102 at MonoDevelop.VersionControl.VersionControlService.GetConfiguration () [0x00034] in /Users/builder/data/lanes/monodevelop-mac-monodevelop-3.0.3-branch/43da787a/source/monodevelop/main/src/addins/VersionControl/ MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs:597 at MonoDevelop.VersionControl.VersionControlService.AddRepository (MonoDevelop.VersionControl.Repository repo) [0x00000] in /Users/builder/data/lanes/monodevelop-mac-monodevelop-3.0.3-branch/43da787a/source/monodevelop/main/src/addins/VersionControl/ MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs:577 at TeamAddins.VersionControl.TFS.GUI.RepositoryMenu.AddRepositoryHandler (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 — End of inner exception stack trace — at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0 at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0 at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <filename unknown>:0 at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0 at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0 at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) [0x00000] in <filename unknown>:0

 

Solution is easy – you should open the directory: /Users/<Your Login>/Library/Preferences/MonoDevelop-3.0 and look into the file ‘VersionControl.config’. In my case it was empty. This means – corrupted. Just delete it and Monodevelop will recreate it. This will be fixed as bug in future releases.

Written by Alex Anikin

July 26, 2012 at 10:31 pm

Posted in Mac, Monodevelop

Predictable memory disposing in Monotouch

leave a comment »

I have tasks:

– do huge memory block allocation in iOS (using Monotouch) application (like list with ~20Mb strings);

– clear list and have predictable memory disposing (using Garbage Collector, it should do this in time, or when we need more mem or etc).

This tasks was born from another big task. I should open huge txt files using QLPreviewController. But all I can see – memory was allocating and never disposing (but this story not about it, this leak Xamarin planning to fix it in 5.3.5 or 5.3.6 release – will wait ).

To check this allocations I used XCode -> Instruments -> Activity Monitor (btw very useful tool – highly recommended!)

My tests :

1. Alloc 20Mb -> check it in Activity Monitor (+20Mb)-> Dispose variable -> Wait and do something with app (alloc more, add, delete items) -> Check -> nothing changes – 20Mb still.

2. Alloc 10*20 Mb items-> Check – my app has almost the memory (if i will try to get more ~10-20Mb  – iOS will close my app) -> Dispose 5 items (~100Mb) -> Waiting (thinking about GC) + do something (thinking about GC again) -> Check  – nothing – ~200Mb

3. The same with 2, but start use GC.Collect (GC.MaxGeneration, GCCollectionMode.Forced); after disposing – Waiting (thinking about GC) + do something (thinking about GC again) -> Check  – nothing – ~200Mb

4. …

n. Wow! -> The same with 3, but after allocation I add GC. AddMemoryPressure (size); and after disposing GC. RemoveMemoryPressure (size); -> Activity monitor shows me that I have memory cleared and available for future allocations.

I can be wrong somewhere and please let me know my mistakes.

Written by Alex Anikin

July 10, 2012 at 9:46 pm

Posted in C#, iOS, Monotouch

Hacking .Net

leave a comment »

Great video about hacking .Net applications: http://vimeo.com/43536532

More details here: http://www.digitalbodyguard.com

Written by Alex Anikin

July 10, 2012 at 9:06 pm

Posted in .Net